Skip to content
XSS Write-up Intermediate

From CSPT to DOM XSS: Chaining an Open Redirect with Malicious JS

A client-side path traversal in the profile-page loader lets an attacker redirect a JSON API request to an open redirect endpoint, which then points to an attacker-controlled JSON response. That response is rendered with innerHTML, leading to DOM-based XSS.

AstroKrypTech Follow

Published on medium.com

A client-side path traversal vulnerability in the application’s profile-page loader allows an attacker to influence the URL used for a JSON API request. By supplying traversal sequences in a query parameter, the request can be redirected from the expected API endpoint to an open redirect.

AstroKrypTech, 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 concatenates user-controlled input directly into a fetch URL without validation, and later inserts the fetched data into the DOM using innerHTML.

What the attacker needed

Victim opens a crafted URL; attacker hosts a JSON response with CORS; open redirect endpoint exists

The fix

The application should validate and sanitise the id parameter before using it in a fetch URL, restrict the redirect endpoint to allowed origins, and avoid inserting untrusted data with innerHTML.

How it was found

  1. The attacker hosts a JSON response matching the expected profile schema, with an HTML payload in the hobbies array.
  2. The attacker serves the JSON with Content-Type: application/json and an Access-Control-Allow-Origin: * header.
  3. The attacker crafts a profile-page URL with a traversal sequence in the id parameter that points to the open redirect endpoint, which in turn points to the attacker's JSON.
  4. The victim opens the crafted URL in a browser.
  5. The browser normalises the fetch URL, escaping the API route and reaching the redirect endpoint.
  6. The redirect is followed, the attacker's JSON is parsed, and the hobbies entry is inserted with innerHTML, executing the payload.

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 profile page takes an ID from the URL and puts it straight into a request to the server. By adding special path characters, an attacker can make that request go to a different endpoint that redirects to a server the attacker controls. The attacker's server returns data that the page then inserts as HTML, so a script runs in the victim's browser.

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 AstroKrypTech

View all

1 more disclosed report, 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.