How I Bypassed a Naive XSS Filter Using Parameter Pollution in Ex
The server assumed a query parameter was always a string and only applied its XSS filter when it was. By sending the parameter twice, it became an array, the filter was skipped, and the unsanitised value was inserted into the page, allowing script execution and cookie theft.
Published on medium.com
Most devs think they’ve prevented XSS if they block < and > in user input. I thought so too… until I discovered a way to bypass such filters using a simple trick in Express.js.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code assumed the query parameter would always be a string and only sanitised it in that case, so a repeated parameter became an array and bypassed the filter.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser and read cookies, potentially leading to account compromise.
What the attacker needed
Victim clicks a crafted link
The fix
The code should reject non-string parameter types before sanitising, or handle the else case by returning an error.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A web page can include a value from the address bar in its HTML. The developer tried to clean that value by removing dangerous characters, but only when the value was a single piece of text. Sending the same parameter twice made it a list instead, so the cleaning was skipped and the dangerous value reached the page.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.