Alert Function Hijacking
The author found an XSS vulnerability on a page with many inputs but could not identify which input was vulnerable because the page was a single-page app with obfuscated JavaScript. By overriding the alert function with a custom one that calls debugger, they could pause execution and inspect the call stack to pinpoint the vulnerable input.
digi.ninja
Published on digi.ninja
When I'm testing a site for Cross-Site Scripting, if I come across a page with a large number of inputs, or inputs that are redisplayed across the rest of the site, I usually use alert boxes with the name of the input, or some other unique identifier, so when an alert pops up I know the source and can tie the input to…
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 page had multiple inputs and the XSS payload was reflected in one of them, but the dynamic JavaScript made it hard to identify which input was vulnerable without debugging.
Impact
This technique helps identify the exact vulnerable input, aiding in fixing the XSS; the XSS itself could allow an attacker to execute scripts in the victim's browser.
What the attacker needed
Ability to intercept responses; Chrome browser
How it was found
- Enable response interception in Burp or ZAP.
- Inject a custom alert function at the start of the page response.
- Trigger the XSS so the alert is called.
- The debugger statement pauses execution.
- Examine the call stack to find the vulnerable input.
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.
This is about a technique to find where an XSS (cross-site scripting) vulnerability is on a complex web page. The author replaced the browser's alert function with their own that pauses the page when called, so they could see which part of the code triggered it. This helps developers fix the right spot.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.