How I Leaked Sensitive User Data Using CORS in a HackerOne Progra
The server reflected any supplied Origin header in Access-Control-Allow-Origin and also set Access-Control-Allow-Credentials to true, allowing cross-origin requests with credentials. An attacker could host a malicious page that makes authenticated requests to a protected endpoint and reads sensitive data such as shopping cart contents.
A while ago, while visiting my hometown on holiday, I felt that familiar itch: the urge to test something. With no gear on me, I borrowed my nephew’s dusty laptop, pulled an old monitor from my parents’ closet, and logged into HackerOne.
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
Impact
An attacker could read sensitive data from a victim's authenticated session, such as shopping cart contents, and potentially exfiltrate it; other tested endpoints were not affected.
What the attacker needed
Victim logged in; victim visits attacker page
How it was found
- Log in to the target site with a valid account in one browser tab.
- Save a malicious HTML page that makes a credentialed fetch request to the protected cart endpoint.
- Host the page locally using a simple web server.
- In the same browser session, open a new tab and navigate to the hosted page.
- Observe that the page successfully retrieves and displays sensitive response data.
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 websites may read its responses. Here the site trusted every website, so a page on any domain could ask for the user's private data using their logged-in cookies. The attacker just needed the victim to visit a malicious page while logged in.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.