CORS Misadventures: How Misconfigured Origins Turned Me Into an Accidental Admin
The API reflected arbitrary origins in its CORS headers while allowing credentials, so any website could read authenticated responses. An attacker could steal user profiles and admin data, and even change passwords, leading to account takeover.
infosecwriteups.com
Published on infosecwriteups.com
Free Link🎈
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 echoed back any Origin header and set Access-Control-Allow-Credentials to true, instead of checking against a strict allowlist.
Impact
An attacker could read authenticated user data, access admin endpoints, and change passwords, resulting in full account takeover.
What the attacker needed
Victim visits attacker page; victim logged in; attacker controls a website
The fix
The server should only allow a strict allowlist of trusted origins and must not reflect arbitrary or null origins when credentials are allowed.
How it was found
- Send requests with various Origin headers, including null and attacker domains, and observe the CORS response headers.
- Notice that the server reflects the supplied origin and allows credentials.
- Host a malicious page that makes credentialed requests to the API and exfiltrates the responses.
- Use the stolen access to call admin endpoints and change the victim's password.
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 normally stops one website from reading data from another. Here the server told the browser to allow any website, even while sending the user's login cookies, so a malicious page could read private data. The author also found that a 'null' origin was accepted, which is easy to fake.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.