Skip to content
XSS Write-up Intermediate

Unexploitable CORS can lead to Stored XSS?

An endpoint reflected the user's name in a JSON response served as text/html, allowing self-XSS. A permissive CORS policy let an attacker send a JSON request with a custom content-type to change the victim's name to an XSS payload, then open the vulnerable page to execute it.

Mohamed Sayed Follow

Published on flex0geek.blogspot.com

on October 23, 2020

Mohamed Sayed (Flex), on flex0geek.blogspot.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 endpoint accepted cross-origin requests with credentials and reflected user-controlled data in a response served as text/html without sanitisation.

Impact

An attacker could change a victim's name to a script payload and then cause that script to run in the victim's browser when the victim visits the user info page.

What the attacker needed

Victim visits attacker page; victim logged in; attacker knows victim's user id

How it was found

  1. Find an endpoint that changes the user's name and has a permissive CORS policy.
  2. Notice that the endpoint requires the request content-type to be application/json.
  3. Use CORS to send a request with that content-type and change the name to an XSS payload.
  4. Open the user info endpoint, which returns text/html, so the payload executes.

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.

CORS is a browser rule that lets a website say which other sites may read its responses. Here the site allowed any origin, so an attacker's page could send a request to change the victim's display name. Because the name was later shown on a page that the browser treated as HTML, a script hidden in the name would run.

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 Mohamed Sayed

View all

9 more disclosed reports, 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.