Skip to content
XSS Write-up Intermediate

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.

Rehan Ansari Follow

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.

Rehan Ansari, on 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.

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

  1. Inject test input into the 'embedded view' parameter and observe it reflected twice: in a value attribute and in a JavaScript block.
  2. Try common payloads like alert(), prompt(), and event handlers such as onload, onerror, onclick; all are sanitised.
  3. Notice that the string 'alert' without parentheses reflects as-is.
  4. Analyse the surrounding JavaScript code and craft input that balances the JavaScript syntax without using <, >, or double quotes.
  5. Find that the onauxclick event handler is not blocked by the filter.
  6. 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.

More by Rehan Ansari

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.