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.

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

hunters training
711

hunters training

labs from real reports
55

labs from real reports

completions
1,205

completions

in bounties practiced
$213,970

in bounties practiced

46 flags captured this week·Real reports from HackerOne · Bugcrowd · Intigriti·No commitment·Free Academy