Skip to content
Business logic Write-up Intermediate

Parameter Pollution - Zero Day

The Discourse poll feature accepted multiple values for the same option parameter, so a user could vote for several poll options in one request. An attacker could cast multiple votes in a single poll, skewing the results.

Jerry Shah Follow

Published on shahjerry33.medium.com

HTTP Parameter Pollution (HPP) means to pollute the HTTP parameters of a web application for achieving a specific malicious task. It refers to manipulating how a website treats parameters it receives during HTTP requests.

Jerry Shah (Jerry), on shahjerry33.medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

HTTP Parameter Pollution (HPP) is the manipulation of how a web application treats the parameters it receives in an HTTP request. The code that parses those parameters runs on the server, so the process itself is a black box to the client, but its effects are visible in the response. The term query string refers to the part between the ? and the end of the URI as defined in RFC 3986: a series of field-value pairs separated by & or ;, the semicolon being a W3C recommendation to avoid escaping. RFC 2396 defines two classes of characters:

  1. Unreserved: a-z, A-Z, 0-9 and _ . ! ~ * ' ( )
  2. Reserved: ; / ? : @ & = + $ ,

The zero day described in this write-up was assigned CVE-2021-43793. The researchers were hunting on a Bugcrowd program that used Discourse. Discourse is an open source Internet forum and mailing list management software application founded in 2013 by Jeff Atwood, Robin Ward and Sam Saffron. It has a poll feature, a voting system in which a topic can carry a poll with several options. The bug was in Discourse itself, a third party from the perspective of the Bugcrowd program, so it was reported on Discourse's main program on HackerOne. The vulnerability had been resolved four months before the write-up.

Setup

The testing was done on try.discourse.org, the public Discourse instance, with a logged-in account. The only precondition stated is that the poll feature must be enabled. The affected versions are Discourse 2.8.0.beta8 and below. The interception tool used was Burp Suite, including its Do intercept > response to this request option.

Finding it

The researchers built a poll with four different options and voted for option 1, intercepting the request. They noticed that the parameter value of the selected option was a long string, but that it was possible to obtain that long string on the client side. While intercepting the response they also noticed that the option parameter was an array. Those two observations prompted them to try manipulating the request.

Exploitation

Step 1: open a new topic

They logged into the Discourse website and clicked the +New Topic button on try.discourse.org.

try.discourse.org From the original on shahjerry33.medium.com

Step 2: choose the poll builder

Among the composer options they found Build Poll.

Build Poll Option From the original on shahjerry33.medium.com

Step 3: create a poll with four values

They created a poll with four options.

Creating Poll From the original on shahjerry33.medium.com
Creating Poll - 4 Options
Poll Created

Step 4: vote for options 1 and 2 and capture the values

They voted for option 1 and option 2, intercepting each request to copy the values of both parameters.

Option 1 - Request From the original on shahjerry33.medium.com
Option 2 - Request

The two captured values were pasted into a notepad for reuse.

Parameter values copied and pasted in notepad From the original on shahjerry33.medium.com

Step 5: vote for option 4 and intercept

They then clicked on option 4 and intercepted the request in order to perform the parameter pollution attack.

Option 4 - Request From the original on shahjerry33.medium.com

Step 6: append the copied parameters

After clicking option 4 they intercepted the request with Burp and appended the parameters with the values of option 1 and option 2. The shape of the polluted request is given in the report as:

Text
optionC=value&optionB=value

That is, the request that legitimately carried the vote for option 4 was extended with the parameter names and values belonging to the other two options, so the same parameter name appears several times in one request.

Appended From the original on shahjerry33.medium.com

Step 7: intercept the response

To see what the server did with the request they used Do intercept > response to this request and forwarded it.

Checking Response From the original on shahjerry33.medium.com

Step 8: the parameter becomes an array

The response showed that the parameter had become an array, and that all the values of the same parameter (option 1, option 2 and option 4) were processed by that array without any error.

Response - Becomes an array From the original on shahjerry33.medium.com
Response - Becomes an array

Step 9: the result on the page

After turning interception off, the page showed the result of the request.

Voted From the original on shahjerry33.medium.com

Step 10: confirm in another browser

To double check, they reloaded the page and also opened the URL in another browser, and the votes were still intact: both options had equal votes by one person.

Only 1 Voter From the original on shahjerry33.medium.com
Another Browser - Chrome

Root cause

The server parsed repeated occurrences of the same parameter into an array and processed every element of it, rather than accepting a single value per parameter. The report frames this as the fourth parsing behaviour in its anatomy of parameter pollution: whatever the client sends, the server parses it into an array and displays it, which the report calls the most vulnerable case. In the abstract example given for this behaviour, a request carrying id=100 returns a single-element array:

HTTP
POST /details HTTP/1.1
Host: site.target.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0

id=100
HTTP
HTTP/1.1 200 OK
server: nginx
content-type: application/json
cache-control: no-cache, private

{

"email":["[redacted]"],"phoneNumber":[[redacted]]

}

while a request carrying id=100&id=101 returns both values in the array:

HTTP
POST /details HTTP/1.1
Host: site.target.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0

id=100&id=101
HTTP
HTTP/1.1 200 OK
server: nginx
content-type: application/json
cache-control: no-cache, private

{

"email":["[redacted]","[redacted]"],"phoneNumber":[[redacted],[redacted]]

}

In the Discourse case the same behaviour meant that a single vote request could carry the identifiers of several poll options, and the application recorded a vote for each of them. The report does not describe the server-side code, so the exact validation gap is not shown; what it establishes is that the vote handler accepted and acted on every value of the repeated parameter. The report's mitigation advice is extensive and proper input validation, and encoding of all user-supplied data reflected in the HTML source of the response according to the context in which it is reflected.

Impact

Any user can choose more than one option for voting by manipulating the request using parameter pollution. In the demonstrated case one account had voted for more than one option in the same poll. The report notes that the poll feature must be enabled for the issue to apply.

Fix

The report does not describe the code change that resolved the issue. It states that the vulnerability was resolved four months before the write-up, that affected versions are Discourse 2.8.0.beta8 and below, and links the GitHub security advisory GHSA-jq7h-44vc-h6qx, where the researchers are credited. The general recommendation given is proper input validation and context-appropriate encoding of reflected user data.

Variants to test

The report lays out the parsing behaviours that determine how a polluted parameter is handled, and each is a concrete thing to try elsewhere.

  1. All occurrences checked, single use enforced. Send the same parameter twice, for example id=100&id=101. If the backend allows a parameter only once, this returns an error, as in the report's example where it produced a 403. A positive result is that the same parameter can then be supplied with several values in one field using a comma, id=100,101, and the server returns 200 with both values processed.
  2. First occurrence validated. Send a benign value first and the payload second, for example q=Hello&q="><svg/onload=alert(1)>. A positive result is a 200 response in which only the first occurrence was checked and the second was not sanitised, so the payload triggers XSS.
  3. Last occurrence validated. Send the payload first and the benign value second, for example q="><svg/onload=alert(1)>&q=Hello. A positive result is a 200 response in which only the last occurrence was checked and the first was not sanitised, again triggering XSS.
  4. Parameter becomes an array. Send a single value and then the same parameter repeated with additional values, and inspect the response. A positive result is that the response contains an array holding every supplied value, as in the email and phoneNumber examples above, which is the behaviour that made the poll vote work.
Table of web technology parsing different values From the original on shahjerry33.medium.com

Table of web technology parsing different values

From the original on shahjerry33.medium.com

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

Imagine a form at a polling station where you write your name and tick one box. The clerk reads the form and records your vote. Now imagine you hand in a form where your name appears three times, each time with a different box ticked. A careful clerk would reject the form. A careless clerk might read every line and record a vote for every box, all under your name. That is essentially what happened here, but on a website.

A website receives information from your browser in small pieces called parameters. When you click a button, your browser sends a request to the server with parameters such as which poll option you chose. Normally each parameter appears once. The researchers found that if they made the same parameter appear several times in one request, the Discourse forum software accepted all of them and recorded a vote for each option. One person could vote for several options in the same poll.

This kind of manipulation is called HTTP Parameter Pollution, often shortened to HPP. The word pollution here just means adding extra, unexpected copies of a parameter to a request. The server-side code that reads the parameters is invisible to you, like a black box: you cannot see inside it, but you can see what comes out on your screen. The researchers could see the effect because the page showed that several options had received a vote from the same account.

The bug was given the identifier CVE-2021-43793. A CVE is a public catalogue number for a known security flaw, so that people can refer to the same bug unambiguously. The researchers found it while testing a bug bounty program on Bugcrowd, a platform where companies invite people to test their systems and report problems. The program used Discourse, an open source forum and mailing list software started in 2013 by Jeff Atwood, Robin Ward and Sam Saffron. Because the flaw was in Discourse itself rather than in the Bugcrowd customer's own code, the researchers reported it to Discourse's own program on HackerOne, another bug bounty platform. The report says the vulnerability had been resolved four months before the write-up was published.

Before going further, two small pieces of web vocabulary help. A URL is the address of a page, for example https://try.discourse.org. The part of a URL after a question mark is called the query string. It carries parameters in pairs of a name and a value, separated by & or ;. For example, ?q=hello&page=2 sends two parameters: q with value hello, and page with value 2. The report cites RFC 3986, the document that defines this structure, and notes that the semicolon as a separator is a W3C recommendation made to avoid escaping problems. It also cites RFC 2396, which divides characters into two classes:

  1. Unreserved: a-z, A-Z, 0-9 and _ . ! ~ * ' ( ). These can appear as they are.
  2. Reserved: ; / ? : @ & = + $ ,. These have special meanings in a URL, so they often need to be encoded (written in a special form such as %3B) when they are meant as ordinary text.

You do not need to memorise these lists. The point is that a URL has a strict grammar, and parameters are part of that grammar. Parameter pollution plays with that grammar by repeating a name that the grammar allows only once in practice.

The setup

The researchers tested on try.discourse.org, a public Discourse site anyone can use, with a normal logged-in account. The only precondition the report states is that the poll feature must be enabled on the forum. A poll in Discourse is a voting box attached to a forum topic: the author writes a question and several options, and readers click one option to vote. The affected versions are Discourse 2.8.0.beta8 and below. To watch and change the traffic between the browser and the server, they used Burp Suite, a tool that sits between your browser and the website and lets you pause, read and edit each request and response. One Burp option they used is called Do intercept > response to this request: it tells Burp to also pause the server's reply, not just the outgoing request, so you can read what the server sent back.

Finding it

The first thing the researchers did was ordinary use of the feature. They built a poll with four different options and voted for option 1, pausing the request in Burp. Two observations made them curious. First, the parameter value for the chosen option was a long string, but that long string could be obtained on the client side, meaning the browser already knew it and could send it. Second, when they paused the response, the option parameter came back as an array. An array is simply a list of values kept together under one name, like a shopping list with several items on it. A parameter that is normally one value was being treated by the server as a list. A value the browser controls plus a server-side list is exactly the combination worth experimenting with: if the list can hold more than one item, perhaps the server will act on every item.

Exploitation

Step 1: open a new topic

They logged into the Discourse website and clicked the +New Topic button on try.discourse.org. A topic is a discussion thread in a forum. Starting a new topic is how you get to the editor where a poll can be added.

try.discourse.org From the original on shahjerry33.medium.com

Step 2: choose the poll builder

Among the composer options they found Build Poll. The composer is the text editor where a forum post is written; Build Poll is a button that inserts a poll into the post.

Build Poll Option From the original on shahjerry33.medium.com

Step 3: create a poll with four values

They created a poll with four options. Four options give enough room to test whether one request can carry votes for more than one of them.

Creating Poll From the original on shahjerry33.medium.com
Creating Poll - 4 Options
Poll Created

Step 4: vote for options 1 and 2 and capture the values

They voted for option 1 and option 2, pausing each request so they could copy the values of both parameters. The reason is practical: to add extra votes to a later request, you first need to know exactly what a legitimate vote for those options looks like. Copying the real values gives the exact parameters a legitimate vote for those options carries.

Option 1 - Request From the original on shahjerry33.medium.com
Option 2 - Request

The two captured values were pasted into a notepad so they could be reused later.

Parameter values copied and pasted in notepad From the original on shahjerry33.medium.com

Step 5: vote for option 4 and intercept

They then clicked on option 4 and paused that request in Burp, intending to turn it into the polluted request. They clicked option 4 and intercepted that request to perform the parameter pollution attack.

Option 4 - Request From the original on shahjerry33.medium.com

Step 6: append the copied parameters

After clicking option 4 they paused the request with Burp and appended the parameters with the values of option 1 and option 2. The report gives the shape of the polluted request as:

Text
optionC=value&optionB=value

Line by line: optionC=value is one parameter, a name (optionC) and a value (value) joined by =. The & separates it from the next parameter. optionB=value is a second parameter with a different name. In the real request the names and values were the ones copied from the genuine votes for the other options, so the request that legitimately carried the vote for option 4 was extended with the parameter names and values belonging to the other two options. The result is that the same kind of parameter appears several times in one request, which is the pollution.

Appended From the original on shahjerry33.medium.com

Step 7: intercept the response

To see what the server did with the request, they used Do intercept > response to this request and forwarded it. Forwarding means letting Burp send the edited request on to the server. Pausing the response means they could read the server's answer before the browser displayed it, which is how they could tell whether the server had accepted the extra values or rejected them.

Checking Response From the original on shahjerry33.medium.com

Step 8: the parameter becomes an array

The response showed that the parameter had become an array, and that all the values of the same parameter (option 1, option 2 and option 4) were processed by that array without any error. In other words, the server did not complain about the repeated parameter. It collected every value into a list and acted on each one, recording a vote for each option.

Response - Becomes an array From the original on shahjerry33.medium.com
Response - Becomes an array

Step 9: the result on the page

After turning interception off, the page showed the result of the request. Turning interception off lets the browser and server talk normally again, so the page reflects what the server actually stored.

Voted From the original on shahjerry33.medium.com

Step 10: confirm in another browser

To double check, they reloaded the page and also opened the URL in another browser, and the votes were still intact: both options had equal votes by one person. Reloading rules out a display glitch, and a second browser rules out something cached or stored only in the first browser. The stored result on the server was the same either way.

Only 1 Voter From the original on shahjerry33.medium.com
Another Browser - Chrome

Root cause

The server parsed repeated occurrences of the same parameter into an array and processed every element of it, rather than accepting a single value per parameter. The report frames this as the fourth parsing behaviour in its anatomy of parameter pollution: whatever the client sends, the server parses it into an array and displays it, which the report calls the most vulnerable case. In the abstract example given for this behaviour, a request carrying id=100 returns a single-element array:

HTTP
POST /details HTTP/1.1
Host: site.target.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0

id=100

Line by line: POST /details HTTP/1.1 is the first line of an HTTP request. HTTP is the language browsers and servers use to talk. POST is the method, used when you send data to the server, as opposed to GET, which asks for a page. /details is the path being requested, and HTTP/1.1 is the version of the protocol. Host: site.target.com tells the server which site the request is for. User-Agent: ... identifies the browser; here it claims to be Firefox 98 on 64-bit Windows. The blank line separates the headers from the body. id=100 is the body: one parameter named id with value 100.

HTTP
HTTP/1.1 200 OK
server: nginx
content-type: application/json
cache-control: no-cache, private

{

"email":["[redacted]"],"phoneNumber":[[redacted]]

}

Line by line: HTTP/1.1 200 OK is the status line. 200 means success. server: nginx says the web server software is nginx. content-type: application/json says the body is in JSON, a text format for structured data that uses curly braces for objects and square brackets for lists. cache-control: no-cache, private tells browsers and proxies not to store the response. The body is a JSON object with two fields: email holds a list containing one address, and phoneNumber holds a list containing one number. The square brackets are what make them lists, or arrays.

A request carrying id=100&id=101 returns both values in the array:

HTTP
POST /details HTTP/1.1
Host: site.target.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0

id=100&id=101

Line by line: this is the same request as before, except the body now has id=100&id=101. The name id appears twice, separated by &. That is the pollution: one parameter name, two values.

HTTP
HTTP/1.1 200 OK
server: nginx
content-type: application/json
cache-control: no-cache, private

{

"email":["[redacted]","[redacted]"],"phoneNumber":[[redacted],[redacted]]

}

Line by line: the status is still 200, so the server did not reject the repeated parameter. The email list now holds two addresses, and the phoneNumber list holds two numbers. The server took both values and put them in the list. That is the behaviour that, in the Discourse poll, meant a single vote request could carry the identifiers of several poll options and the application recorded a vote for each of them. The report does not describe the server-side code, so the exact validation gap is not shown; what it establishes is that the vote handler accepted and acted on every value of the repeated parameter. The report's mitigation advice is extensive and proper input validation, and encoding of all user-supplied data reflected in the HTML source of the response according to the context in which it is reflected. In plain terms: check what users send, and when you show it back on a page, escape it in the way that suits where it appears.

Impact

Any user can choose more than one option for voting by manipulating the request using parameter pollution. In the demonstrated case one account had voted for more than one option in the same poll. The report notes that the poll feature must be enabled for the issue to apply.

Fix

The report does not describe the code change that resolved the issue. It states that the vulnerability was resolved four months before the write-up, that affected versions are Discourse 2.8.0.beta8 and below, and links the GitHub security advisory GHSA-jq7h-44vc-h6qx, where the researchers are credited. The general recommendation given is proper input validation and context-appropriate encoding of reflected user data.

Variants to test

The report lays out the parsing behaviours that determine how a polluted parameter is handled, and each is a concrete thing to try elsewhere. Parsing means reading a request and deciding what its parts mean. Different server technologies make different choices when a name repeats, and the choice decides whether pollution does anything.

Table of web technology parsing different values From the original on shahjerry33.medium.com

Table of web technology parsing different values

  1. All occurrences checked, single use enforced. Send the same parameter twice, for example id=100&id=101. If the backend allows a parameter only once, this returns an error, as in the report's example where it produced a 403. A 403 is the HTTP status for forbidden. A positive result is that the same parameter can then be supplied with several values in one field using a comma, id=100,101, and the server returns 200 with both values processed.
  2. First occurrence validated. Send a benign value first and the payload second, for example q=Hello&q="><svg/onload=alert(1)>. A positive result is a 200 response in which only the first occurrence was checked and the second was not sanitised, so the payload triggers XSS. XSS, cross-site scripting, is when an attacker gets their own code, usually JavaScript, to run in another user's browser on the site. The payload here is a small SVG image tag whose onload attribute runs alert(1), a pop-up box, when the image loads. Sanitised means cleaned of dangerous characters before being used.
  3. Last occurrence validated. Send the payload first and the benign value second, for example q="><svg/onload=alert(1)>&q=Hello. A positive result is a 200 response in which only the last occurrence was checked and the first was not sanitised, again triggering XSS.
  4. Parameter becomes an array. Send a single value and then the same parameter repeated with additional values, and inspect the response. A positive result is that the response contains an array holding every supplied value, as in the email and phoneNumber examples above, which is the behaviour that made the poll vote work.
From the original on shahjerry33.medium.com

Glossary

  • Array: a list of values stored together under one name, written with square brackets in JSON.
  • Black box: a system whose internal workings you cannot see, only its inputs and outputs.
  • Bug bounty program: an arrangement where an organisation invites people to test its systems and pays or credits them for reporting flaws.
  • Burp Suite: a tool that sits between browser and server and lets you pause, read and edit requests and responses.
  • CVE: a public catalogue number for a known security vulnerability.
  • Discourse: open source forum and mailing list software, started in 2013 by Jeff Atwood, Robin Ward and Sam Saffron.
  • Encoding: writing a character in a special form, such as %3B for a semicolon, so it is treated as ordinary text.
  • GET: an HTTP method that asks the server for a page or resource.
  • HPP (HTTP Parameter Pollution): adding extra or repeated parameters to a request to change how the server interprets it.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • JSON: a text format for structured data, using curly braces for objects and square brackets for lists.
  • Parameter: a named value sent with a request, such as q=hello.
  • Parsing: reading a request and deciding what its parts mean.
  • Poll: a voting box attached to a forum topic, with a question and several options.
  • POST: an HTTP method used to send data to the server.
  • Query string: the part of a URL after the ?, made of name-value pairs separated by & or ;.
  • Request: the message a browser sends to a server asking for something or sending data.
  • Response: the message a server sends back to a browser.
  • Sanitise: clean input of dangerous characters before using it.
  • Status code: a number in the response saying what happened, such as 200 for success or 403 for forbidden.
  • Topic: a discussion thread in a forum.
  • URL: the address of a page on the web.
  • User-Agent: a request header identifying the browser and system making the request.
  • XSS (cross-site scripting): getting attacker-supplied code to run in another user's browser on a website.

More by Jerry Shah

View all

1 more disclosed report, best first.

More from Discourse

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.