Skip to content
XSS Write-up Beginner

Day-2 Bypassing No Brackets XSS Filter

A page injected the search parameter into innerHTML after stripping everything from the first opening parenthesis, so a basic XSS payload was truncated. The author bypassed the filter by encoding the parentheses as HTML numeric character references, which the browser decoded after the filter ran, allowing script execution and access to document.cookie.

medium.com

Published on medium.com

Hey guys, so today I was solving an XSS lab and I got stuck for way longer than I expected But I learned something really important, so I’m writing this down before I forget.

zero_day, 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 filter removed raw parenthesis characters before the browser decoded HTML entities, and the input was then written to innerHTML without proper output encoding.

Impact

An attacker could execute arbitrary JavaScript in the victim's browser and read document.cookie, though the text does not state whether cookies were HttpOnly or otherwise protected.

What the attacker needed

Victim visits a crafted URL; search parameter reflected into innerHTML

The fix

The input should be HTML-encoded on output, or inserted with textContent instead of innerHTML, rather than relying on character blacklisting.

How it was found

  1. Inspect the page source and find the tracking function that splits input on '(' and writes it to innerHTML.
  2. Try a basic image onerror payload and observe it is truncated at the parenthesis.
  3. Try backticks and quoted attributes to call alert without parentheses.
  4. Realise the goal requires document.cookie, which needs parentheses.
  5. Use HTML numeric character references for the parentheses in the onerror handler.
  6. Observe the alert with document.cookie and the lab is solved.

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 page took text from the URL and placed it directly into the page's HTML, which lets an attacker run their own JavaScript. The site tried to block this by removing the '(' character, but the attacker wrote the parenthesis in a coded form that the browser still understands, so the block was skipped.

What is XSS?

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

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.