Skip to content
XSS Write-up Intermediate

Reflections of Doom: How a Tiny DOM XSS Turned Into Complete Account Takeover

A DOM-based XSS in the search function allowed an attacker to execute JavaScript by breaking out of a quoted string. The attacker could steal session cookies via DNS exfiltration and hijack user accounts.

iski Follow

Published on medium.com

Free link 🎈

Iski, on medium.com

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 client-side JavaScript used innerHTML to insert the search term without sanitising it, even though the server-side encoding was correct.

Impact

An attacker could take over any user's account who clicks a malicious link, gaining access to personal and payment information.

What the attacker needed

Victim clicks a malicious link; cookies not marked HttpOnly; CSP allows image loads

The fix

The site should use textContent instead of innerHTML and mark session cookies as HttpOnly.

How it was found

  1. Enter a search term and observe it reflected in the results header.
  2. Try a basic script payload and see it encoded by the server.
  3. Inspect the JavaScript to find the use of innerHTML with the q parameter.
  4. Craft a payload that breaks out of double quotes and injects an SVG with an onload handler.
  5. Use an image tag with an onerror handler to exfiltrate cookies via DNS.
  6. Set the stolen session cookie in the browser to hijack the account.

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 search page took the user's input and inserted it into the page without cleaning it, so an attacker could make the page run their own code. This let the attacker steal the user's login cookie 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.

More by iski

View all

186 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.