Skip to content
XSS Write-up Intermediate

Stored XSS Leading to Full Account Takeover (The Art of Content-T

The profile update endpoint returned responses with a text/html content type, allowing stored HTML injection via the fullName field. An attacker could execute JavaScript in the victim's browser and steal the session token from localStorage, leading to account takeover.

Parsa Riyahi Follow

Published on medium.com

So, I was hunting a target and monitoring requests with their payloads while doing narrow recon. Something strange caught my eye: the API request’s content type was multipart/form-data, but the response content type was text/html.

Parsa Riyahi, 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

Impact

An attacker could execute arbitrary JavaScript in a victim's browser and steal the session token from localStorage, leading to full account takeover.

What the attacker needed

Victim views the injected profile; attacker can set fullName field; WAF bypass required

The fix

The application should set the response Content-Type to application/json and properly encode or sanitise user-supplied data before rendering.

How it was found

  1. Send a profile update request with a benign HTML tag in the fullName field and observe that it is parsed as HTML.
  2. Inject an image tag with an onerror handler to confirm script execution.
  3. Fuzz HTML tags to find one that bypasses the WAF, such as an element with an autofocus and onfocus handler.
  4. Craft a JavaScript payload using string concatenation to bypass WAF restrictions on parentheses and the word 'location'.
  5. Use the URL fragment (location.hash) to bypass the 120-character input limit and execute the final payload.
  6. Read the session token from localStorage and send it to an attacker-controlled server.

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.

When a website sends data back to your browser, it tells the browser what kind of data it is using a 'Content-Type' header. If it says 'text/html', the browser treats the data as a web page and runs any scripts in it. Here, the site saved user input and later showed it as a web page, so an attacker could put a script in their profile name and it would run when viewed.

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 Parsa Riyahi

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.