Alternative link
The CORS policy reflected any subdomain in the Access-Control-Allow-Origin header and allowed credentials, so a malicious page on any subdomain could read the victim's email address. Combined with a stored XSS on a subdomain, an attacker could steal the email and a CSRF token to change the victim's email address, leading to account takeover.
hazanasec.github.io
Published on hazanasec.github.io
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 CORS configuration reflected the Origin header without validating it against a strict allowlist, and also set Access-Control-Allow-Credentials to true, allowing any subdomain to make credentialed cross-origin requests.
Impact
An attacker could take over a victim's account by changing their email address, but the attack required the victim to click a stored XSS payload on a subdomain.
What the attacker needed
Victim clicks a stored XSS link; attacker can host a page on a subdomain; victim is logged in
The fix
The CORS policy should use a strict allowlist of trusted domains and subdomains instead of reflecting any origin, and the XSS should be fixed by properly sanitising the input.
How it was found
- Visit the account page and notice a request to /details/account returning JSON with the user's email.
- Use a Burp live task to inject an Origin header with a random subdomain and observe the server reflecting it back with credentials allowed.
- Find a stored XSS on a subdomain by bypassing a javascript: URI filter with decimal encoding.
- Build a payload that uses CORS to read the victim's email, scrapes the CSRF token from the email settings page, and posts to the change email endpoint.
- Deliver the stored XSS payload to the victim; when clicked, it changes the victim's email to the attacker's.
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 ask another website for data. Here the second website said 'yes' to any address that ended with the same company name, and also allowed the request to carry the user's login cookies. That meant a page on any company subdomain could read the user's email address. The attacker also found a way to run their own code on a company subdomain, so they could make the victim's browser do both steps and change the victim's email.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.