Advanced levelPremium

CloudFront cache deception — exfiltrate PII via other users' cached responses

How to abuse CloudFront cache rules with fake extensions (.css, .js, .png) to serve cached authenticated responses to other users. Real-world PII leakage.

Gorka El BochiMay 11, 202613 min

Quick answer

Web Cache Deception (Omer Gil, 2017) exploits the fact that CDNs cache by file extension (.css, .js, .png) regardless of the response's real Content-Type. The attacker requests /account/me.css → the app responds with the HTML of the victim's profile → CloudFront sees .css and caches it → an anonymous attacker requests the same URL → receives the cached private page. It works against default CloudFront + apps with permissive routing. Recurring bounties in Series B+ SaaS.


1. The concept as a mental image

css
[Víctima autenticada]
   ↓ GET /account/me.css
[App] → routing matchea /account/me → renderiza HTML privado con PII
   ↓ 200 OK, body = HTML del perfil
[CloudFront] → "ah, .css, cacheable" → guarda response en cache key (path)
   ↓ devuelve a víctima

[Atacante anónimo]
   ↓ GET /account/me.css
[CloudFront] → cache HIT → devuelve HTML privado SIN ir al origin

The flaw is the combination of two separately benign behaviors:

  1. The app does permissive routing: /account/me.css matches /account/me and returns private HTML.
  2. CloudFront caches by extension without validating Content-Type or cookies.

Neither piece is vulnerable on its own. Together → massive leak.


2. Prerequisites for it to work

ComponentCondition
App routing/path/anything.css resolves to /path or /path/anything (catch-all, optional segments)
CloudFront cache rulesCaches *.css, *.js, *.png, *.jpg etc. by extension without checking cookies
App responseReturns 200 with a sensitive body (not a 301 redirect to /login)
Vary headerMissing Vary: Cookie or Cache-Control: private

Condition #1 is what varies the most. Frameworks with a catch-all router (Express with *, Flask with path:, Rails with globbing routes, Next dynamic routes) are top candidates.


Keep reading the full chain

The remaining part includes the step-by-step PoC, exploitation code and the full chain that led to impact. Available to subscribers.

Free · no account

The checklist I run on every new target

47 checks ordered by cost: first what can get you in trouble, then the cheap stuff, and finally the expensive stuff — which is where the big bounties are. I'll send it to your inbox right now.

Unsubscribe in one click, from any email.

Practice this in a lab

Cloudfront Cache Deception

Solve

Keep learning · free account

Save your progress, unlock advanced payloads and rank your flags.

Create account

Related articles

2,482

hunters training

62

labs from real hacks

1,629

completions

$14,790

paid out for these bugs

11 flags captured this week·Real hacks from HackerOne · YesWeHack · Bugcrowd·No commitment·Free Academy