2013-08-26

← Older revision

Revision as of 06:50, 26 August 2013

Line 9:

Line 9:

 

<br>

 

<br>

 

 



Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. For instance, [http://www.ietf.org/rfc/rfc3986.txt RFC 3986] simply defines the ''Query String'' as a series of field-value pairs and [http://www.ietf.org/rfc/rfc2396.txt  RFC 2396] defines classes of reversed and unreserved characters. Without a standard in place, web application components handle this edge case in a variety of ways (see the table below for details).  

+

Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. For instance, [http://www.ietf.org/rfc/rfc3986.txt RFC 3986] simply defines the
term
''Query String'' as a series of field-value pairs and [http://www.ietf.org/rfc/rfc2396.txt  RFC 2396] defines classes of reversed and unreserved
query string
characters. Without a standard in place, web application components handle this edge case in a variety of ways (see the table below for details).  

 

By itself, this is not necessarily an indication of vulnerability. However, if the developer is not aware of the problem, the presence of duplicated parameters may produce an anomalous behavior in the application that can be potentially exploited by an attacker. As often in security, unexpected behaviors are a usual source of weaknesses that could lead to HTTP Parameter Pollution attacks in this case.

 

By itself, this is not necessarily an indication of vulnerability. However, if the developer is not aware of the problem, the presence of duplicated parameters may produce an anomalous behavior in the application that can be potentially exploited by an attacker. As often in security, unexpected behaviors are a usual source of weaknesses that could lead to HTTP Parameter Pollution attacks in this case.

 

 



To better introduce this class of vulnerabilities and the outcome of HPP attacks, it is interesting to analyze some real-life
vulnerabilities
that have been discovered in the past.

+

To better introduce this class of vulnerabilities and the outcome of HPP attacks, it is interesting to analyze some real-life
examples
that have been discovered in the past.

 

 

 

=== Input Validation and filters bypass ===

 

=== Input Validation and filters bypass ===

 

<br>

 

<br>



In 2009, immediately after the publication of the first research on HTTP Parameter Pollution,
this
technique received
large
attention from the security community as a possible way to bypass web application firewalls.

+

In 2009, immediately after the publication of the first research on HTTP Parameter Pollution,
the
technique received attention from the security community as a possible way to bypass web application firewalls.

 

 

 

One of these flaws, affecting ''ModSecurity SQL Injection Core Rules'', represents a perfect example of the impedance mismatch between applications and filters.  The ModSecurity filter would correctly blacklist the following string: <code>select 1,2,3 from table</code>, thus blocking this example URL from being processed by the web server: <code>/index.aspx?page=select 1,2,3 from table</code>. 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 <code>/index.aspx?page=select 1&page=2,3</code> from table would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.

 

One of these flaws, affecting ''ModSecurity SQL Injection Core Rules'', represents a perfect example of the impedance mismatch between applications and filters.  The ModSecurity filter would correctly blacklist the following string: <code>select 1,2,3 from table</code>, thus blocking this example URL from being processed by the web server: <code>/index.aspx?page=select 1,2,3 from table</code>. 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 <code>/index.aspx?page=select 1&page=2,3</code> from table would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.

Line 34:

Line 34:

 

</code>

 

</code>

 

 



The flaw resided in the authentication mechanism used by the web application, as the
validation
was performed on the first parameter, whereas the actual operation used the second occurrence.

+

The flaw resided in the authentication mechanism used by the web application, as the
security check
was performed on the first
<code>blogID</code>
parameter, whereas the actual operation used the second occurrence.

 

<br>

 

<br>

 

 

Line 76:

Line 76:

 

== Black Box testing and example ==

 

== Black Box testing and example ==

 

<br>

 

<br>



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. However, as in-depth business logic knowledge is
required
, testing HPP requires manual testing
and automatic
tools can only partially assist auditors. In addition, HPP can manifest itself in client-side and server-side components.

+

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. However, as in-depth business logic knowledge is
necessary
, testing HPP requires manual testing
. Automatic
tools can only partially assist auditors
as they tend to generate too many false positives
. In addition, HPP can manifest itself in client-side and server-side components.

 

 

 

=== Server-side HPP ===

 

=== Server-side HPP ===

Line 98:

Line 98:

 

Analyze the response page to determine which value(s) were parsed. In the above example, the search results may show <code>kittens</code>, <code>puppies</code>, some combination of both (<code>kittens,puppies</code> or <code>kittens~puppies</code> or <code>['kittens','puppies']</code>), may give an empty result, or error page.

 

Analyze the response page to determine which value(s) were parsed. In the above example, the search results may show <code>kittens</code>, <code>puppies</code>, some combination of both (<code>kittens,puppies</code> or <code>kittens~puppies</code> or <code>['kittens','puppies']</code>), may give an empty result, or error page.

 

<br>

 

<br>



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 and other security mechanisms 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, different web application components use different occurrences or testing
generate
an error, there is an increased likelihood of being able to use parameter pollution to trigger security vulnerabilities.

+

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 and other security mechanisms 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, different web application components use different occurrences or testing
generates
an error, there is an increased likelihood of being able to use parameter pollution to trigger security vulnerabilities.

 

 

 

 

Line 104:

Line 104:

 

# Submit an HTTP request containing the standard parameter name and value, and record the HTTP response. E.g. <code>page?par1=val1</code>

 

# Submit an HTTP request containing the standard parameter name and value, and record the HTTP response. E.g. <code>page?par1=val1</code>

 

# Replace the parameter value with a tampered value, submit and record the HTTP response. E.g. <code>page?par1=HPP_TEST1</code>

 

# Replace the parameter value with a tampered value, submit and record the HTTP response. E.g. <code>page?par1=HPP_TEST1</code>



# Send a new request combining step (1) and (2). Again,
record
the HTTP
responses
. E.g. <code>page?par1=val1&par1=HPP_TEST1</code>

+

# Send a new request combining step (1) and (2). Again,
save
the HTTP
response
. E.g. <code>page?par1=val1&par1=HPP_TEST1</code>

 

# Compare the responses obtained during all previous steps. If the response from (3) is different from (1) and the response from (3) is also different from (2), there is an impedance mismatch that may be eventually abused to trigger HPP vulnerabilities.

 

# Compare the responses obtained during all previous steps. If the response from (3) is different from (1) and the response from (3) is also different from (2), there is an impedance mismatch that may be eventually abused to trigger HPP vulnerabilities.

 

 

Line 111:

Line 111:

 

=== Client-side HPP ===

 

=== Client-side HPP ===

 

<br>

 

<br>



Similarly to server-side HPP, manual testing is the only reliable technique to audit web applications in order to detect parameter pollution vulnerabilities affecting client-side components. While in the server-side variant the attacker leverages a vulnerable web application to access protected data or perform actions that either not permitted or not supposed to be executed, client-side attacks
aims
at
tampering
client-side components and technologies.  

+

Similarly to server-side HPP, manual testing is the only reliable technique to audit web applications in order to detect parameter pollution vulnerabilities affecting client-side components. While in the server-side variant the attacker leverages a vulnerable web application to access protected data or perform actions that either not permitted or not supposed to be executed, client-side attacks
aim
at
subverting
client-side components and technologies.  

 

<br>

 

<br>

 

To test for HPP client-side vulnerabilities, 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).  

 

To test for HPP client-side vulnerabilities, 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).  

Show more