DOM-Based XSS: From Browser Logic to Bounty
A login page used the URL hash to build and execute JavaScript via eval, allowing an attacker to run arbitrary code in the victim's browser. The attacker could steal cookies or perform actions as the victim.
medium.com
Published on medium.com
In my previous blog, I talked about HTTP Request Smuggling, and if you liked that one, I hope you’ve already smuggled your first request into a backend server by now.
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
The application took the URL hash, split it into parts, and passed the result to eval without sanitisation, allowing arbitrary JavaScript execution.
What the attacker needed
Victim clicks a crafted link
How it was found
- Visit the login page with a redirect parameter and no hash.
- Add a value after the # and reload the page.
- Open DevTools and search for location.hash in the JavaScript.
- Set a breakpoint where the hash is processed.
- Change the hash and observe the breakpoint hit, tracing how the hash becomes a function call string.
- Trigger the payload by setting the hash to alert(document.cookie).
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 website took part of the web address (the bit after the # symbol) and used it to run code in your browser without checking it. This let an attacker run their own code when you visited a specially crafted link, which could steal your login cookies or do things as you.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.