$5,400 for a Regex That Trusted the Wrong Domain: CORS Misconfigu
The account API validated the request Origin header with a prefix-style check, so an attacker-owned domain that merely began with the trusted domain string was accepted as an allowed origin. Because credentials were also allowed, a page on that attacker domain could read a logged-in user's account summary, balances and transaction data.
Some vulnerabilities take real cleverness to find. This one took reading a single response header carefully enough to notice it was doing something a header like that should never do, and then about twenty minutes of methodically trying to break a regular expression I couldn’t see but could infer the shape of from how…
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 origin validation checked whether the Origin header began with the trusted domain string without anchoring the match, so an attacker domain using the trusted string as a subdomain prefix passed the check.
Impact
Any user with an active session who visits a malicious page on suitably structured attacker infrastructure could have their authenticated account and transaction data silently read, with no interaction beyond loading the page.
What the attacker needed
Victim logged in to the service; victim visits attacker page; attacker owns a matching domain
The fix
The regex-based check was replaced with an exact-match allowlist of fully qualified trusted origins, and the team audited other services using the same library.
How it was found
- Send a request to the account API with an unrelated Origin header and observe the origin reflected back with credentials allowed.
- Send a different unrelated origin and note it is rejected, showing some validation exists.
- Try a series of origin values to map which ones are accepted and which are rejected.
- Note that an origin using the trusted domain as a prefix of an attacker-owned domain is accepted.
- Register a domain matching the accepted pattern, host a page there that fetches the account summary with credentials, and load it while logged in.
- Confirm the page displays the account summary data, then take the page down.
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.
Browsers normally stop one website from reading data returned by another website. A server can deliberately allow specific other sites to read its responses by naming them in a response header, and the browser then permits it. Here the server checked the name only loosely, so a site the attacker owned was treated as trusted and could read the victim's financial data while they were logged in.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.