How we MITM'd a crypto exchange platform via cache poisoning
The OpenID autoconfiguration endpoint reflected the unkeyed X-Forwarded-Prefix header into its URLs and was cached by Cloudflare, allowing an attacker to poison the cache so that OAuth endpoints pointed to an attacker-controlled server. An attacker could then intercept the authorization code and exchange it for an access token, effectively performing a man-in-the-middle attack.
Davwwwx included in Bug Bounty
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 cache did not include the X-Forwarded-Prefix header in its cache key, so a request with a crafted header value was cached and served to other users.
Impact
An attacker could steal users' OAuth access tokens by intercepting the authorization code, though the report notes that Firefox users saw a prompt asking them to confirm navigation to the website.
What the attacker needed
Victim uses the affected client application; attacker can send requests with custom headers; cache must not key on X-Forwarded-Prefix
The fix
The issue was fixed within a day after confirmation.
How it was found
- Send a request to the OpenID configuration endpoint with a crafted X-Forwarded-Prefix header.
- Confirm the response is cached and served to subsequent requests.
- Set up a server that forwards authorization requests to the real server and captures the token exchange.
- Poison the cache so the configuration points to the attacker's server.
- When a victim logs in, the client uses the poisoned endpoints, sending the authorization code to the attacker.
- The attacker exchanges the code for a token and returns a valid token to the victim to remain invisible.
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.
A cache stores a copy of a web page so it loads faster for everyone. The site built its OpenID configuration page using a header that visitors can set, and the cache did not treat that header as part of the page's identity, so one visitor could poison the cached copy for others. The poisoned page told login apps to send secret login codes to the attacker's server instead of the real one.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.