Chaining CORS by Reflected XSS to Steal Sensitive Data
A subdomain had a CORS misconfiguration that allowed any origin to read authenticated API responses, and a login page reflected a JavaScript URL in its 'next' parameter, enabling XSS. By chaining these, an attacker could steal a logged-in user's personal data from the API.
infosecwriteups.com
Published on infosecwriteups.com
Hello, everyone. I hope you are doing well.
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 API reflected the Origin header in Access-Control-Allow-Origin while allowing credentials, and the login page failed to sanitise the 'next' parameter before using it as a redirect target.
Impact
An attacker could execute JavaScript in the context of the vulnerable subdomain and read the victim's personal information from the API, but the exploit required the victim to log in and interact with a crafted link.
What the attacker needed
Victim must be logged in; victim clicks a crafted link; attacker needs a subdomain to host the exploit
The fix
The CORS configuration should not reflect arbitrary origins when credentials are allowed, and the 'next' parameter should be validated to prevent JavaScript URLs.
How it was found
- Enumerate subdomains using Google dorking and passive tools.
- Use httpx and EyeWitness to find live web services and take screenshots.
- Apply a Logger++ filter to find endpoints that return CORS headers when an Origin header is sent.
- Send a suspicious endpoint to Repeater and confirm it reflects the Origin with credentials allowed.
- Find a login page with a 'next' parameter and test it for open redirect and XSS.
- Craft a JavaScript URL that makes a credentialed request to the vulnerable API and shows the response.
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 sites can read its data. Here, the site wrongly allowed any site to read private data, and a login page also ran JavaScript from a link. Together, an attacker could make a victim's browser fetch and show the victim's own information to the attacker.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.