Skip to content
XSS Write-up Intermediate

Weaponizing Useless XSS: How Path Traversal Turned Reflection int

A reflected XSS in the search parameter was initially useless because it only fired when the attacker visited their own URL. A broken report endpoint allowed path traversal to inject the XSS payload into the search parameter, enabling cookie theft and session hijacking.

Prasannasalunkhe Follow

Published on medium.com

So there I was, poking around this shopping website with your standard product listings and search functionality. You know the drill: click around, search for random stuff, see what breaks.

Prasannasalunkhe, 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

Likely the report endpoint failed to validate the 'id' parameter, allowing path traversal to reach the search parameter, and the search results were rendered without proper output encoding, while the session cookie lacked HttpOnly and Secure flags.

Impact

An attacker could steal a victim's session cookie (a JWT containing admin privileges) and hijack their session, leading to full account compromise.

What the attacker needed

Victim clicks a crafted link; attacker has a webhook to receive data

The fix

The report endpoint should validate the 'id' parameter with an allowlist, the search results should be rendered using safe methods like textContent or sanitised with DOMPurify, and cookies should be set with HttpOnly, Secure, and SameSite=Strict flags.

How it was found

  1. Find a reflected XSS in the search functionality.
  2. Notice a broken 'Report Product' button that navigates to /report?id=1 without validation.
  3. Craft a payload using path traversal (../../) to redirect from the report endpoint to the search parameter with an XSS payload.
  4. URL-encode the payload and send the request.
  5. The payload executes, exfiltrating cookies to a webhook, revealing a JWT with admin session data.

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 had a search box that would run any script you typed into it, but only for the person who typed it, so it was harmless on its own. A separate 'Report Product' button was broken and let you jump to other parts of the site using '../' in the address. By combining these two flaws, the attacker could make the search box run a script for anyone who clicked a crafted link, stealing their login cookie.

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.