XSS without parentheses and semi-colons
A site filtered parentheses and semicolons, so the author adapted a known trick that calls a function through the JavaScript error handler to work without those characters. An attacker who can inject script into the page could still run arbitrary JavaScript despite the filter.
portswigger.net
Published on portswigger.net
A few years ago I discovered a technique to call functions in JavaScript without parentheses using onerror and the throw statement. It works by setting the onerror handler to the function you want to call and the throw statement is used to pass the argument to the function:
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
Impact
Script injected into the page could still execute in the victim's browser, so the character filter did not prevent cross-site scripting.
What the attacker needed
Injection point that accepts script; filter blocks parentheses and semicolons
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.
Websites often try to stop attacks by blocking certain characters in what users type. Here the site blocked round brackets and semicolons, which are normally needed to call a function in JavaScript. The author found other ways to trigger the same function using the browser's error handling, so the filter did not stop script from running.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.