Web Cache Deception
A caching layer stores a personalised page as if it were a static file, so another person can retrieve a signed-in user's private content from the cache.
| Severity | Medium |
| CVSS 3.1 | 5.3 CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N Open in the calculator |
| CVSS 4.0 | 5.9 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-524: Use of Cache Containing Sensitive Information |
| Category | Information Disclosure |
Description
Web cache deception arises when a cache in front of the application, such as a content delivery network, reverse proxy or load balancer, decides what to store from the shape of the address, for example a static file extension or a static directory, while the application maps the same address to a dynamic, personalised page. A request for an address such as /account/settings/logo.css is answered by the application with the user's account page, because it ignores or tolerates the extra path segment, and the cache stores that response as if it were a public stylesheet.
An attacker sends a signed-in user a link to such an address. When the user follows it, their page is cached, and the attacker then requests the same address and receives the cached copy without any session. In this way the attacker can read any page a victim is lured into requesting: personal details, account and order information, and any tokens embedded in the page, such as anti-CSRF tokens or API keys, which may allow further actions as the victim. Each victim exposes only their own pages, and the copy is only available until the cache entry expires, but a shared cache at a content delivery network makes collecting victims' pages straightforward, and the issue is worse where personalised pages carry long-lived secrets.
The weakness can be confirmed by requesting a personalised page with a static-looking suffix while signed in, checking that the personalised content is returned and that cache headers such as Age, X-Cache or a provider-specific cache status show it was stored, then requesting the same address with no session. Variants rely on other differences in how the cache and the application read an address: delimiters such as ; or an encoded ? or #, encoded path separators, dot segments that one side normalises and the other does not, and cache rules keyed on static directories or well-known file names.
Remediation
Make the cache decide what to store from the application's own response rather than from the address, and make the application refuse addresses it does not recognise:
- Send
Cache-Control: no-store(or at leastprivate) on every authenticated or personalised response, and configure the cache to respect the origin's caching headers rather than overriding them with rules based on file extension. - Configure the application's routing to return 404 for paths that do not exactly match a defined route, rather than serving the nearest dynamic page for extra path segments, delimiters or encoded characters.
- Limit caching to dedicated static paths that only ever serve static files and, where the cache supports it, only cache a response when its
Content-Typematches the file extension requested. - Make the cache and the application decode and normalise paths in the same way, including encoded characters and dot segments.
As an interim measure, add cache rules that bypass caching for the affected routes and purge cached copies of personalised pages. Confirm the fix by repeating the original requests: each should either return 404 or come back uncached, and an unauthenticated request should never return personalised content.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.