When the Blacklist Failed: How I Triggered XSS with a Middle Cli
An application reflected a parameter in both an HTML attribute and a JavaScript block, but used a blacklist filter that blocked common characters and event handlers. The author found that the onauxclick event handler was not blocked and, by balancing JavaScript syntax, triggered XSS with a middle-click.
Published on medium.com
🧠 TL;DR During a security assessment, I discovered an XSS vulnerability in an application that used a blacklist filter. The app blocked<, >, “, and all common event handlers — but missed one sneaky handler: onauxclick.
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
Likely the application relied on a blacklist filter that blocked common characters and event handlers but failed to block the less common onauxclick handler, and it did not use context-aware output encoding for the JavaScript context.
Impact
An attacker could execute arbitrary JavaScript in the context of the victim's browser when the victim middle-clicks, potentially leading to session theft or other client-side attacks.
What the attacker needed
Victim middle-clicks; input reflected in HTML and JS contexts
The fix
The application should use context-aware output encoding for each reflection context, avoid inline event handlers by using addEventListener(), and implement a strong Content Security Policy that blocks inline scripts.
How it was found
- Inject test input into the 'embedded view' parameter and observe it reflected twice: in a value attribute and in a JavaScript block.
- Try common payloads like alert(), prompt(), and event handlers such as onload, onerror, onclick; all are sanitised.
- Notice that the string 'alert' without parentheses reflects as-is.
- Analyse the surrounding JavaScript code and craft input that balances the JavaScript syntax without using <, >, or double quotes.
- Find that the onauxclick event handler is not blocked by the filter.
- Combine the balanced JavaScript input with onauxclick and trigger the XSS by middle-clicking.
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.
The application put user input into two places on the page: an HTML attribute and a JavaScript block. It tried to block dangerous input by banning a list of known bad words and characters, but missed one event handler called onauxclick. By carefully crafting input that fit the JavaScript syntax, the author made the page run their code when the victim middle-clicked.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.