DOM-inated! How a Tiny JS Sink Turned Into Critical XSS
A JavaScript file read the URL fragment and inserted it into the page as HTML without sanitisation, allowing an attacker to run script in the victim's browser. The author claims this could steal session cookies and lead to account takeover.
medium.com
Published on medium.com
Free Link🎈
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 code took user-controlled input from the URL fragment and assigned it to innerHTML without any sanitisation.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser, potentially stealing session cookies and leading to account takeover; the text notes there was no Content Security Policy to limit the attack.
What the attacker needed
Victim clicks a crafted link
How it was found
- Find the JavaScript file that contains the vulnerable code.
- Craft a URL with a script payload in the fragment.
- Open the URL in a browser and observe the script executing.
- Use a payload that sends document.cookie to an attacker-controlled server.
- Confirm the cookie is received on the server.
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.
When a website takes something you type or control (like the part of the address after #) and puts it directly into the page as HTML, it can run hidden code. Here, the site did that without cleaning it first, so an attacker could make a link that runs their own script when clicked. That script could then read the user's cookies and send them to the attacker.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.