Cors Blimey: The power of chaining CORS
A CORS misconfiguration reflected any subdomain in the Access-Control-Allow-Origin header with credentials enabled, letting a script on any subdomain read the victim's email address. Combined with a stored XSS on a subdomain and a CSRF token scraped from a settings page, an attacker could change the victim's email address and take over the account.
For those that don’t know about CORS (Cross-Origin Resource Sharing), it’s a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a…
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 server reflected the request's Origin header into Access-Control-Allow-Origin without checking it against a strict allowlist, and also set Access-Control-Allow-Credentials to true.
Impact
An attacker could read a victim's email address and change it to their own, leading to account takeover, but the attack required the victim to click a stored XSS payload.
What the attacker needed
Victim clicks a stored XSS link; attacker can store input on a subdomain; victim is logged in
The fix
The CORS policy should use a strict allowlist of trusted origins rather than reflecting any subdomain, and the XSS and CSRF issues should also be fixed.
How it was found
- Notice a request to /details/account returning the user's email in JSON.
- Send a request with an Origin header set to a random subdomain and observe it reflected in Access-Control-Allow-Origin with credentials allowed.
- Find a stored XSS on a subdomain where a javascript: URI was blocked but bypassed with decimal encoding.
- Use the XSS to make a credentialed CORS request to read the victim's email.
- Use the XSS to load the email settings page and scrape the CSRF token.
- Send a POST to the change email endpoint with the stolen email and token, setting the attacker's email as the new one.
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 at one address read data from another address, but only if the second site explicitly allows it. Here the second site allowed any subdomain of the target, and also allowed the browser to send the user's login cookies, so a script placed on any subdomain could read the user's email. The researcher then found a way to run script on a subdomain and used it to change the victim's email, which is a step towards taking over the account.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.