Skip to content
XSS Write-up Intermediate

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.

Jayesh kunwal, 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 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

  1. Visit the login page with a redirect parameter and no hash.
  2. Add a value after the # and reload the page.
  3. Open DevTools and search for location.hash in the JavaScript.
  4. Set a breakpoint where the hash is processed.
  5. Change the hash and observe the breakpoint hit, tracing how the hash becomes a function call string.
  6. 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.

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.