Skip to content
CORS Write-up Intermediate

How a Flawed CORS Policy on an API Gateway Led to a $13,000 Priva

The API gateway's CORS policy used a loose prefix check on the Origin header, so any domain starting with the legitimate domain was trusted. An attacker could register such a domain, host a malicious page, and steal a logged-in user's private booking token.

T4nv1 Follow

Published on medium.com

Cross-Origin Resource Sharing (CORS) is a browser security mechanism designed to break down the strict walls of the Same-Origin Policy (SOP). It allows trusted external domains to make requests to an API and read the responses.

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

Likely the origin validation used a prefix string match without a trailing slash or strict domain boundary, so any domain beginning with the trusted name was accepted.

Impact

A logged-in user who visited the attacker's page could have their private booking token stolen, allowing the attacker to authenticate ride bookings as that user.

What the attacker needed

Victim is logged in; victim visits attacker's page; attacker registers lookalike domain

The fix

The CORS configuration was fixed by replacing the dynamic string matching with a strict, absolute whitelist of allowed origins.

How it was found

  1. Send a request to the profile token endpoint with an Origin header set to an arbitrary domain and observe no CORS headers.
  2. Send a request with an Origin of the trusted domain followed by a dot and an attacker domain and observe no CORS headers.
  3. Send a request with an Origin of the trusted domain followed by a hyphen and an attacker domain and observe the origin reflected with credentials allowed.
  4. Register the matching attacker domain and host a script that fetches the token endpoint with credentials included.
  5. Trick a logged-in user into visiting the attacker page so the script reads the response and exfiltrates the token.

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 at one address read data from another address, but only if the second site explicitly says it is allowed. Here the API said 'yes' to any address that merely started with the real site's name, so a lookalike address got full access. A victim only had to visit the attacker's page while logged in, and their secret token was taken.

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.