Skip to content
CORS Write-up Beginner

$5,000 Bug Bounty: Stealing Private API Keys via Arbitrary Origin Reflection in CORS

The API reflected any Origin header value in Access-Control-Allow-Origin while also allowing credentials, so any website could read authenticated responses. An attacker could host a page that fetches the victim's private API keys and exfiltrates them.

T4nv1 Follow

Published on medium.com

Cross-Origin Resource Sharing (CORS) misconfigurations remain one of the most reliable bug bounty findings. While many modern frameworks enable strict security by default, custom dynamic origin-parsing backend scripts often introduce critical logic flaws.

T4nv1, on medium.com

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

The backend dynamically reflected the inbound Origin header into Access-Control-Allow-Origin without checking it against a static whitelist, and also set Access-Control-Allow-Credentials to true.

Impact

An attacker could read a victim's private API keys and other account data from the API, leading to account compromise.

What the attacker needed

Victim is authenticated; victim visits attacker-controlled page; attacker can host a page

The fix

The backend should check the Origin header against a static whitelist and only reflect allowed origins, and should not allow credentials with arbitrary origins.

How it was found

  1. Observe the API endpoint returning user billing profiles and API access tokens with an Origin header.
  2. Test common origin validation bypasses such as prefix bypass and null origin.
  3. Send an arbitrary domain in the Origin header and see it reflected in Access-Control-Allow-Origin with credentials allowed.
  4. Host a JavaScript payload on an external site that fetches the target endpoint with credentials included.
  5. When an authenticated victim loads the attacker page, the browser sends the request with cookies and the script reads the response.
  6. Exfiltrate the response data to the attacker server.

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.

Websites use a rule called the Same-Origin Policy to stop one site from reading data from another. CORS is a way for a site to say 'these other sites are allowed to read my data'. Here the site said 'any site is allowed', so a malicious page could read the victim's secret API keys.

What is CORS?

A permissive cross-origin policy lets another site read responses with the user's credentials.

More by T4nv1

View all

113 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

CORS misconfiguration

The lesson behind this report.

A permissive cross-origin policy lets another site read responses with the user's credentials.