You test web cache security by checking whether sensitive or personalised responses can be cached and replayed to the wrong user. Inspect cache-control behaviour, vary handling, cache keys, and purge processes, then confirm that authenticated content, tokens, and private data are not stored or served from shared caches.
What web cache security testing is trying to prove
web cache security testing asks a simple question: can a cache serve the wrong response to the wrong person? The goal is to prove that shared caches, browser caches, reverse proxies, and CDN layers do not store or replay personalised, authenticated, or sensitive content across users, sessions, or roles. That includes checking cache directives, cache keys, and invalidation behaviour under real traffic patterns.
It is not enough to look for “cache hits” or “cache misses.” A safe result depends on whether the application marks responses correctly, whether intermediaries respect those markings, and whether the response varies on the attributes that actually change its meaning. A page that is harmless for one visitor can become a disclosure issue if the cache ignores cookies, headers, or authentication context.
For a practical methodology, use the Web Application Security Testing Guide as the broader testing framework and then focus specifically on cacheable responses, authenticated flows, and any endpoint that returns user-specific data. That is where cache bugs tend to become security bugs.
What to inspect in cache behaviour
Start by reviewing response headers and the conditions under which a response becomes cacheable. Confirm that sensitive pages are marked so they are not stored in shared caches, and that responses with personalised content are not treated as generic assets. Pay attention to whether the application uses cache-control directives consistently across HTML, JSON, and error responses.
Next, test whether cache variation is complete. If a response changes based on cookies, authentication state, locale, device type, or other request attributes, the cache key or vary logic must reflect that dependency. If it does not, one user’s content can be replayed to another user even though the application logic itself is correct.
You should also inspect purge and invalidation processes. A cache can be secure at first response and still become unsafe if stale authenticated content remains available after logout, role change, token rotation, or content update. Revalidation behaviour matters as much as initial storage rules.
How to test for exposure and replay
Use separate identities or sessions to request the same endpoint and compare the cached output. The strongest evidence comes from trying to fetch a personalised page from a second session after it has been populated by the first. If the second session receives data that should have been isolated, the cache boundary has failed.
Test both positive and negative cases. Check that public assets are cached as intended, then verify that login-protected pages, account summaries, API responses, reset flows, and pages containing tokens are not cacheable in a shared layer. Also test edge cases such as redirects, 4xx and 5xx responses, partial responses, and content negotiated by headers, because cache mistakes often hide there.
When the app sits behind multiple intermediaries, test the full path, not just the origin server. A response that is safe at the origin may still be cached by a CDN, reverse proxy, or browser under different rules. For that reason, cache testing is often a path analysis exercise as much as an application test.
Risk and Threat Considerations
Cache failures can disclose authenticated content, session-linked data, or tokens to other users, especially when shared infrastructure ignores variation rules or stores responses longer than intended. The risk grows when the cached response contains account data, privilege-sensitive content, or anything that can be reused outside the original session.
Failure mechanism: A shared cache stores a response that is meant to be private, then replays it based on an incomplete cache key, missing vary header, weak purge logic, or stale invalidation state. That can expose data across users, roles, or sessions even when the application’s authorization checks were correct at request time.
Impact: The result can be cross-user data disclosure, session leakage, privilege confusion, or persistence of content after logout or access revocation. In a multi-layer delivery chain, the same flaw may affect many users at once and can be difficult to detect after the fact.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V9 — Self-contained Tokens | Token-bearing responses need controls that prevent exposure through cache reuse. |
| V7 — Session Management | Cache replay across sessions can expose authenticated content to the wrong user. | |
| V16 — Security Logging and Error Handling | Cache anomalies and replay issues need observable evidence during testing and investigation. | |
| Recommendation — Verify token handling so responses do not expose reusable secrets through caching. Test session-bound pages to ensure cached responses cannot cross session boundaries. Log cache decisions and error paths so replay or stale-content issues can be detected. | ||
| CIS Controls v8 | CIS-3 — Data Protection | Cache testing is about preventing sensitive data from being stored or exposed in shared layers. |
| Recommendation — Classify sensitive responses and prevent them from being stored in shared caches. | ||
| NIST SP 800-53 Rev 5 | SC-28 — Protection of Information at Rest | Cached responses are stored information that must be protected from unintended disclosure. |
| Recommendation — Protect cached sensitive data so it cannot be disclosed through shared storage. | ||
Practitioner Guidance
What to verify: Confirm which response classes are intentionally cacheable and which are not, then test those decisions at each layer that can cache or transform content. The key question is whether the cache key fully reflects every request attribute that changes the meaning of the response.
Common mistake: Teams often test only the application server and assume the proxy, CDN, or browser will behave the same way. They also overlook logout, role switch, and token rotation paths, which are exactly where stale cached content tends to become visible.
Decision rule: If a response contains authenticated, personalised, or token-bearing data, treat shared caching as a risk until you have proved otherwise. If the content must remain cacheable for performance, narrow the cache scope and verify that the response varies correctly for every meaningful user context.
Practitioner takeaway: Web cache security is proven by isolation, not by intent, so the control is only real when your tests show that private responses cannot escape their original user context.
Related resources from NHI Mgmt Group
- Guide: Web Application Attacks Guide
- How should security teams test for parser differentials in web applications?
- How should security teams test authorisation in web applications?
- How should security teams test modern web applications continuously?
- What breaks when passive scanning is used as the only security test for web applications?