CORS Misconfiguration Leads to Exposing User Data
The site reflected an attacker-controlled origin in the Access-Control-Allow-Origin header while also allowing credentials, so a malicious page could read authenticated API responses. An attacker could steal a victim's API keys and other profile data and then act within the victim's account.
- Triaged in 2 days
- Fixed in 3 months
- Disclosed after 6 months
Vulnerable Asset: https://██████/█████████/
Discovery:
- Upon accessing the site we discover two specific response headers which indicates that a cross-domain request for sensitive information might be possible
- Access-Control-Allow-Origin: injectable
- Access-Control-Allow-Credentials: true
- We craft a POC below and exploit the misconfigurations present by exposing the users API key, email, first name, last name, etc.
███
POC:
- This is hosted on http://█████████
<html>
<script>
var xhttp = new XMLHttpRequest();
<!-- the below endpoint lists API tokens previously generated by the user -->
xhttp.open("GET", "https://█████/████/api/token/list", true);
xhttp.withCredentials = true;
xhttp.send(null);
</script>
</html>
Demo:
███████
Remediations:
- Do not allow the Access-Control-Allow-Origin to be arbitrarily set by the user; the domain should be whitelisted that is allowed access to CORS, or the wildcard operator
*should be used instead, which will disallow the Allow-Credentials header
Impact
This attack works similarly to a CSRF attack in that an attacker would need to have a victim visit the attacker's website in order to trigger the exploit. If the victim is logged in, then the result is full access to API keys which serve in lieu of username/password as shown in the demo. The attacker then can perform any action within the user's account that the API allows.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application reflected an arbitrary Origin header into Access-Control-Allow-Origin while setting Access-Control-Allow-Credentials to true, instead of checking the origin against a fixed allowlist.
Impact
If a logged-in victim visits the attacker's page, the attacker could read API keys and profile data and then perform any action the API allows in that account.
What the attacker needed
Victim is logged in; victim visits attacker's page
The fix
The origin should be checked against a fixed allowlist, or a wildcard should be used without allowing credentials.
How it was found
- Notice the two CORS response headers on the site.
- Host a page that sends a credentialed cross-origin request to the token list endpoint.
- Get a logged-in victim to visit the attacker's page.
- Read the API keys and profile data returned in 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 report 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 may read its responses. Here the site trusted whatever origin asked, and also allowed logged-in cookies to be sent, so any website could read private data from the victim's account. The attacker only needed the victim to open a page they controlled.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.