Web cache deception
Web cache deception makes the cache store sensitive responses due to path normalization differences between cache and origin server.
Material
Web cache deception exploits the difference between how a cache and an origin server interpret the same path. By appending a suffix that looks like a static asset, the attacker makes the proxy store a private response under a URL no other user ever visits.
How it works
Cache rules usually carry a list of patterns that may be stored. Applications often load paths ending in an asset extension such as .css, .js, or .png, while the origin server keeps routing that same request to a dynamic page such as a user profile.
The origin server returns HTML full of private data, but the proxy stores it because the URL matches the asset pattern. The response now sits in the shared cache and can be fetched by anyone who knows the URL.
GET /product/1 HTTP/1.1
Host: target.website
Accept: text/html
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: private, no-storeGET /product/1/pixel.css HTTP/1.1
Host: target.website
Accept: text/css
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: public, max-age=3600
X-Cache: HITThe decisive difference between the two responses is the Cache-Control header. The page originally asked the cache to keep it private, and once the suffix was added the response came back public and cacheable, so the deception only works while the cache rule keeps accepting the extra path segment.
Attack forms
- Fake asset suffix: a path like /akun/1/xyz.css gets the profile page cached along with it.
- Divergent normalization: %2e%2e, a semicolon, or a double slash is translated differently by the cache and the origin.
- Exact-match rules: only /static/ is allowed, but path rewriting opens a gap on page URLs crafted to look similar.
- Path delimiters: a delimiter such as .json or a slash ends the cache segment, so the origin sees a different segment.
- Refetching: once stored in a shared cache, the same URL can be pulled by someone else, including with parameters that mimic the session.
Prevention
- Do not use the file extension as the only cacheability signal; cache rules should follow the real content type.
- Send Cache-Control: private, no-store on every page that renders per-user data.
- Normalize paths at the proxy with exactly the same rules as the origin, covering dots, double slashes, and %2e.
- Add Vary: Cookie so the cache never serves one user's response to another user.
- Monitor cache hit ratios on URLs with unusual suffixes as an attack signal.
cache_rules:
- match: "^/static/"
cacheable: true
ttl: 86400
- match: "^/assets/"
cacheable: true
ttl: 86400
- match: "^/(account|profile|order)"
cacheable: false
headers:
Cache-Control: "private, no-store"
vary:
- Cookie# bandingkan header cache untuk path normal dan path bersufiks
curl -sD - -o /dev/null "https://target.website/product/1"
curl -sD - -o /dev/null "https://target.website/product/1/aaa.css"
# request kedua ke URL yang sama: perhatikan status baris X-Cache
curl -sD - -o /dev/null "https://target.website/product/1/aaa.css"Cache deception is most likely on sites that sit behind a large CDN in front of a dynamic application, because the cache rules live in a different layer from the application's routing rules.
Labs in this topic
Labs run on a domain separate from this site, so a payload cannot reach your account session.
Labs for this category land in Phase 2. The material is readable now.
Challenges in this category
Challenges from the PortSwigger Web Security Academy. The original labs run on PortSwigger domains, so the link opens there.