Account Takeover via Unsafe CORS | Cyber Tamarin
The application reflected arbitrary Origin headers with credentials allowed and used weak substring matching for Referer validation, enabling cross-origin requests from attacker-controlled domains. An attacker could change a victim's email address and then reset the password to take over the account.
medium.com
Published on medium.com
How a misconfigured CORS policy combined with weak Referer validation allowed authenticated account compromise
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 any Origin in Access-Control-Allow-Origin with credentials enabled and validated the Referer using a simple substring match instead of exact hostname comparison.
What the attacker needed
Victim logged into the application; victim visits attacker's webpage; attacker controls a domain containing the trusted name
The fix
The application should validate the Origin against an exact allowlist and compare the Referer hostname exactly, not by substring, and should require additional verification for sensitive actions like email changes.
How it was found
- The attacker hosts a malicious webpage on a domain containing the trusted domain name.
- The victim logs into the application.
- The victim visits the attacker's website.
- The malicious page issues a credentialed cross-origin request to the profile update endpoint.
- The request changes the victim's registered email address to an attacker-controlled email.
- The attacker initiates a password reset and sets a new 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 lets a website ask another site for data. If a site trusts any origin and also allows cookies, a malicious page can read or change your data while you are logged in. Here, the site also checked the Referer header but only looked for the trusted name anywhere in the address, so a domain like trusted.com.evil.com passed.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.