Solving DOM XSS Puzzles
Two DOM XSS vulnerabilities were found: one via a postMessage handler that lacked origin checks and led to eval, and another via an unsanitised introduction field combined with a CSP bypass using an open redirect. An attacker could execute arbitrary JavaScript and steal session tokens.
Published on spaceraccoon.dev
DOM-based Cross-site scripting (XSS) vulnerabilities rank as one of my favourite vulnerabilities to exploit. It’s a bit like solving a puzzle; sometimes you get a corner piece like $.html(), other times you have to rely on trial-and-error.
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 missing origin validation on postMessage handlers and unsanitised data insertion, combined with an overly permissive CSP and an open redirect.
Impact
An attacker could execute arbitrary JavaScript in the context of the vulnerable iframe and steal the user's session token, leading to account takeover.
What the attacker needed
Victim visits attacker-controlled page; victim is logged in
The fix
The vulnerabilities were fixed by adding origin checks and sanitising input, as implied by the companies awarding bonuses.
How it was found
- Open the vulnerable page that contains the iframe.
- Send a crafted postMessage to the iframe to set settingsSync with a malicious region.
- Host a malicious response on an attacker-controlled domain to control config and trigger eval.
- Use the XSS to send a postMessage to the parent window and leak the session token.
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.
DOM XSS happens when a website's own JavaScript takes data from the URL or from messages and puts it into the page without cleaning it, so an attacker's code runs in the victim's browser. Here, one page listened for messages from any website and later ran part of that message as code, and another page inserted text from a remote server without cleaning it. The attacker could then read the user's session token and take over their account.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.