Skip to content
Cache bugs Write-up Advanced

Web Cache Poisoning to Account Takeover

A web cache poisoning vulnerability allowed an attacker to inject XSS into every page by combining two unkeyed headers, and an OAuth flow flaw allowed redirecting the authorization code to an arbitrary location via a cookie. Chaining these with a cookie overriding technique enabled account takeover.

Josh Fam Follow

Published on jsecu.github.io

Starting off,this is a vulnerability that I found during a bug bounty engagement.I would split this into two parts, or two separate vulnerabilities. The First part was a web cache poisoning via X Headers.This part allowed me to achieve XSS on every endpoint with a combination of two Headers.The next part was a Oauth…

Josh Fam (@Pullerze), on jsecu.github.io

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 application reflected unkeyed headers (X-Forwarded-Host and X-Rewrite-Url) into responses and cached them, and the OAuth callback handler used a cookie value to redirect the authorization code without proper validation.

Impact

An attacker could take over user accounts by stealing OAuth authorization codes, and the cache poisoning allowed XSS on every page, though the cache lasted only about 3 minutes.

What the attacker needed

Victim visits a poisoned page; attacker can send crafted headers; OAuth flow uses a cookie for redirect

How it was found

  1. Identify that the site supports X-Forwarded-Host and X-Rewrite-Url headers and reflects X-Forwarded-Host in a JavaScript variable.
  2. Poison the cache using both headers to achieve XSS on every page.
  3. Use the XSS to set a cookie with a specific path that overrides the HTTPOnly OAuth callback cookie.
  4. Poison two endpoints: one to set the malicious cookie and redirect to OAuth, another to handle the callback and exfiltrate the code.
  5. The attacker receives the OAuth code and exchanges it for an access 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.

Web cache poisoning is when an attacker tricks a website's cache into storing a malicious response that is then served to other users. Here, the attacker used special headers to make the cache store a response containing malicious JavaScript, and then combined it with a flaw in the login flow to steal user accounts.

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.

More by Josh Fam

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Web cache poisoning and deception

The lesson behind this report.

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.