HTTP parameter pollution: one name, two values, two readings
HTTP parameter pollution (HPP) is the practice of sending the same parameter name more than once, such as color=red&color=blue, and relying on two parts of a system to read the pair differently. An HPP attack works when a filter checks one occurrence and the application uses another, or when duplicates are joined into a value nobody validated. The request is well formed; the problem is that nothing in the standards says which reading is right.
Quick facts
- What it is
- Repeated parameter names that different components interpret differently
- Testing guide
- OWASP WSTG-INPV-04, test WSTG-INPV-04
- Attack pattern
- CAPEC-460, HTTP Parameter Pollution (HPP)
- Weakness
- CWE-235, Improper Handling of Extra Parameters
- Standards position
- RFC 3986 defines no meaning for repeated keys in a query
- Main fix
- Decide per parameter whether it takes one value or a list, and reject duplicates of the single-value ones
Claims on this page follow the OWASP Web Security Testing Guide entry above, the CAPEC and CWE records, and RFC 3986. Where a behaviour depends on your stack, the page says so rather than guessing.
What a duplicate parameter is
A query string is a list of names and values after the question mark. The same name can appear twice: ?color=red&color=blue. Forms posted as application/x-www-form-urlencoded use the same shape in the request body.
The URI standard does not give such a pair a meaning. Section 3.4 of RFC 3986 describes the query as non-hierarchical data and says only that it is often used to carry identifying information as key=value pairs. It does not say what a repeated key means. OWASP puts the consequence plainly: because the standards are silent, each framework decides for itself. Keys that rewrite an object are covered under prototype pollution.
That silence is useful in practice, since many frameworks use repeated names to carry a list, for example several selected checkboxes. It is also the opening for pollution. OWASP is careful on one point: duplicates are not a vulnerability by themselves. Trouble starts when two components handle them differently.
How stacks read duplicates
The OWASP testing guide tabulates what several server-side stacks return for color=red&color=blue. The pattern in that table has three shapes:
- Joined. ASP and ASP.NET on IIS concatenate all occurrences with a comma, giving
red,blue. - First wins. JSP and servlets on Apache Tomcat, Oracle Application Server 10g and Jetty, plus IBM HTTP Server and several Perl and Python modules on Apache, return the first occurrence,
red. - Last wins. PHP on Apache and on Zeus, and IBM Lotus Domino, return the last occurrence,
blue. Zope returns a list of all values.
Treat this as an illustration of the spread, not as a reference for your deployment. The table is a snapshot in a testing guide; frameworks change, and a proxy, an API gateway or a framework layer in front of the code can change the result again. The only dependable answer for your application is a test request against it.
Why the filter and the backend disagree
A request on its way to your application is read more than once. A filter at the edge reads it to decide whether to let it through; the framework reads it again to build the values the code uses. If the two readings differ, a check can pass on one value while the code acts on another. OWASP calls this an impedance mismatch.
The same guide describes a concrete case. A ModSecurity rule set for SQL injection stopped a malicious string sent in one parameter. The string could be split across two parameters with the same name, so that each fragment looked harmless to the filter. A backend that joined the occurrences then rebuilt the string. The guide also lists cases in Apple CUPS and Blogger where a security check read one occurrence of a parameter and the application used another.
The CAPEC entry describes the same family in general terms: duplicate GET or POST parameters can override fixed values, change application behaviour, and bypass input validation or WAF rules. This page does not reproduce working strings. What matters for a defender is the structure: validation and use read different things.
The effect is not limited to injection. A duplicate can also change business logic, for example where a checkout reads a price or a role parameter. That puts HPP close to business logic flaws as well as to SQL injection, whose filters it is often aimed at.
Server-side and client-side pollution
The OWASP guide separates two variants. Server-side pollution is the case above: the backend receives duplicates and acts on one of them or on a joined value. Client-side pollution concerns pages that build links or form actions from request parameters. If a parameter value that contains an encoded ampersand and a new name is copied into a URL or an attribute without encoding, the page now carries a parameter the developer never wrote. The next request then arrives with an extra name.
The second variant is why output encoding belongs in any HPP defence, not only input checks. It is a cousin of the header-building flaws covered under CRLF injection: both start from a value that was trusted as one thing and turned out to carry structure.
Chains of components make the first variant worse. A reverse proxy, a gateway and an application server each parse the request once. The more parsers a request meets, the more chances for disagreement, which is also why HTTP request smuggling exists at the message level. Pollution is the same kind of problem one layer up, inside the query.
How it is tested
OWASP notes that testing is largely manual, because the result depends on what the application does with the value. The guide recommends three requests per parameter: the original value, a changed value, and both together. If the combined response differs from the other two, an impedance mismatch may exist and deserves a closer look. For the client side, the guide appends an encoded marker to inputs and checks whether it appears in generated links or attributes.
Two practical points follow for a site owner. First, run this against your own application only, on a staging copy where possible. Second, the useful output is a table: for each parameter that matters, which occurrence the application uses and whether anything in front of it agrees. That table is what the defences below are built on.
Where a WAF helps, and where it does not
Where it helps. A filter in front of the application sees every request before the framework does. That position allows two things. It can inspect every occurrence of a repeated name, and the joined form as well, so a value split across duplicates does not slip through as harmless fragments. And it can flag repeated names on parameters that should appear once, which is often a more telling signal than any single value. How far a given rule set goes on this depends on its design, so check what your rules do with duplicates before you rely on it.
Where it does not. A filter does not know which occurrence your code will use unless that is encoded in its configuration. Parameters that legitimately repeat, such as list fields, make a blanket rejection of duplicates risky. And a filter cannot repair an application that reads the same name in two places with two different rules. That decision lives in the code, in the same way that safe header construction does in the CRLF case. See the limits described for command injection for the general version of this point.
The order of work. Bridge WAF has three modes: off, monitor and block. Begin in monitor mode. Matches are recorded in the activity log and every request is still served, so you can see which requests carry repeated names and whether any are legitimate. Review the entries against your own list of single-value and list parameters, handle genuine hits through false positive review, and move to block only for what you have confirmed, following a staged rollout.
How to defend against HPP
- Parse in one place. Read request parameters through a single layer and pass typed values on. Code that reaches into the raw query string in several places invites two readings.
- Declare each parameter as single or list. A single-value parameter that arrives twice is an error, not a choice between first and last.
- Reject duplicates of single-value parameters. Return a client error and log it. Rejecting is safer than picking an occurrence.
- Validate what the code uses. Run checks on the final value, after any joining, decoding and type conversion, not on the raw input.
- Encode output. When links or form actions are built from request values, encode every value so a copied ampersand cannot add a parameter.
- Align the chain. Find out how each proxy, gateway and framework between the client and the code treats duplicates, and make them agree or let one component normalise the request first.
- Do not take sensitive values from the query. Prices, roles and account identifiers should come from server-side state, which removes the need to defend them against repetition.
This list is guidance assembled from the OWASP findings above, not a prescription from the guide itself, which does not include a remediation section. It sits alongside the broader injection controls in OWASP Top 10 injection.
Questions
What is HTTP parameter pollution?
HTTP parameter pollution (HPP) is sending the same parameter name more than once in a request. HTTP standards do not say how duplicates are handled, so two components can read the same request differently, and an attacker can use that gap to bypass validation or change application variables.
Is a repeated parameter a vulnerability by itself?
No. OWASP states that duplicates are not a vulnerability on their own. The risk appears when single inputs are validated but components disagree about which occurrence counts, when duplicates are joined into one value, or when duplicates cause errors.
Which occurrence does my framework use?
It depends on the stack. The OWASP testing guide lists some backends that join all values with a comma, some that keep the first occurrence and some that keep the last. That table is a starting point; confirm the behaviour of your own framework and versions with a test request.
Can a WAF stop HPP attacks?
Partly. A filter that inspects every occurrence, and the combined value as well, narrows the gap. A filter cannot know which occurrence your application will use unless it is told, so single-value parameters should also be enforced in the application. Start in monitor mode and read the activity log before block.
How do you prevent HTTP parameter pollution?
Parse requests in one place, decide per parameter whether it takes one value or a list, reject or flag duplicates of single-value parameters, validate the value the application actually uses, and make every component in the chain read the same occurrence.