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.
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.
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
- Send a profile update request with a benign HTML tag in the fullName field and observe that it is parsed as HTML.
- Inject an image tag with an onerror handler to confirm script execution.
- Fuzz HTML tags to find one that bypasses the WAF, such as an element with an autofocus and onfocus handler.
- Craft a JavaScript payload using string concatenation to bypass WAF restrictions on parentheses and the word 'location'.
- Use the URL fragment (location.hash) to bypass the 120-character input limit and execute the final payload.
- 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.