October 4, 2026
Web Cache Poisoning: Understanding, Detecting, and Exploiting Cache Vulnerabilities
Introduction

By Mazen Elsayed
5 min read
Introduction
Web applications rely heavily on caching to improve performance and reduce the load on backend servers. By storing responses and serving them to subsequent users, caches can significantly speed up the delivery of web content.
However, caching can also introduce security vulnerabilities when the cache and the backend application do not process requests in the same way.
One of these vulnerabilities is Web Cache Poisoning, where an attacker manipulates a response and causes the cache to store it. If successful, the poisoned response can then be served to other users who request the same resource.
In this article, we will explore how Web Cache Poisoning works, how to identify vulnerable behavior, and how these vulnerabilities can be exploited and prevented.
What is Web Cache Poisoning?
Web Cache Poisoning occurs when an attacker is able to influence a response that is stored by a web cache. Normally, a cache stores a response to a request and later reuses that response for other requests considered equivalent.
The problem appears when the cache decides that two requests are equivalent based on only part of the request, while the application processes additional parts of it. If an attacker can modify one of these ignored inputs and influence the generated response, the cache may store that manipulated response.
Once the malicious response is cached, other users requesting the same resource may receive it. This makes the vulnerability particularly interesting because the attacker is not necessarily targeting a single request or user โ the poisoned response can potentially affect everyone who receives the cached content.
How Web Caching Works
To understand Web Cache Poisoning, we first need to understand how a web cache decides whether it can reuse a stored response.
When a user sends a request, the cache checks whether it already has a response for that request. If a matching cached response exists, the cache can return it directly without contacting the backend server. Otherwise, the request is forwarded to the application, and the resulting response may be stored in the cache.
The important concept here is the cache key. The cache key is the information used by the cache to determine whether two requests should receive the same cached response. Depending on the cache configuration, this may include the HTTP method, hostname, URL path, and query parameters.
The security problem begins when the application uses information that is not included in the cache key to generate its response. These inputs are commonly referred to as unkeyed inputs.
If an attacker can control an unkeyed input and use it to influence the response, they may be able to create a response that the cache considers valid for other users as well.
Understanding Cache Keys and Unkeyed Inputs
The cache key is one of the most important concepts in Web Cache Poisoning. It determines which parts of a request the cache uses to identify a stored response.
For example, a cache might use the following components:
GET /products?id=10
Host: example.comGET /products?id=10
Host: example.comIf the cache key is based on the host, path, and query string, changing the value of an unrelated HTTP header may not create a new cache entry. However, the backend application may still process that header and use it when generating the response.
This creates a difference between what the cache considers important and what the application considers important.
An input that affects the application's response but is ignored by the cache when creating the cache key is called an unkeyed input.
These inputs are especially interesting during security testing because an attacker may be able to manipulate them, influence the response, and then cause the resulting response to be cached.
The key question when testing for Web Cache Poisoning is therefore:
Can I control an input that changes the response without changing the cache key?
Detecting Web Cache Poisoning
The first step when testing for Web Cache Poisoning is to determine whether the response is actually being cached.
A useful indicator is the presence of cache-related headers such as X-Cache, Age, Cache-Control, or headers provided by a CDN. Sending the same request multiple times can also help determine whether the response is being served from the cache.
Once caching is confirmed, the next step is to look for inputs that influence the response but may not be included in the cache key. HTTP headers are particularly interesting because some applications use them to construct URLs, generate links, determine the host, or change other parts of the response.
For example, if changing a specific header modifies the response while the cache continues to treat the request as the same cache entry, this may indicate a potential poisoning condition.
However, simply finding an unkeyed input is not enough. You also need to verify that the modified response can actually be stored and subsequently delivered to other requests. This distinction is important because not every unusual response behavior leads to a practical cache poisoning vulnerability.
Exploiting Web Cache Poisoning
After identifying an unkeyed input that can influence the response, the next step is to determine whether it can be used to poison the cache.
The basic idea is straightforward: an attacker sends a request containing a malicious value in the unkeyed input. If the application reflects or otherwise uses that value in its response, and the response is considered cacheable, the cache may store the manipulated response.
For example, imagine an application uses a request header to generate an absolute URL inside its response:
GET / HTTP/1.1
Host: example.com
X-Forwarded-Host: attacker.exampleGET / HTTP/1.1
Host: example.com
X-Forwarded-Host: attacker.exampleIf the application uses the X-Forwarded-Host value when generating the response, while the cache does not include this header in its cache key, the resulting response could potentially be stored under the normal cache entry.
The important part of the test is verifying the complete flow:
Attacker-controlled input โ Modified response โ Cached response โ Response served to another request
A successful attack therefore depends on both the application's behavior and the cache's behavior. If either side prevents the manipulated response from being stored or reused, the poisoning attempt will fail.
Impact of Web Cache Poisoning
The impact of Web Cache Poisoning depends on what the attacker can influence in the cached response.
In some cases, the vulnerability may have a relatively limited impact, such as modifying links or loading resources from an attacker-controlled domain. In more serious scenarios, cache poisoning can be chained with other vulnerabilities, such as Cross-Site Scripting (XSS), to execute malicious JavaScript in the browsers of other users.
Another important factor is the scope of the cache. If a poisoned response is stored in a shared cache, the attack may affect multiple users rather than only the attacker. This can turn a seemingly small input manipulation into a vulnerability with significant impact.
Therefore, when assessing Web Cache Poisoning, it is important to consider not only whether the cache can be poisoned, but also who can receive the poisoned response and what that response can do.
Prevention and Mitigation
Preventing Web Cache Poisoning requires keeping the caching behavior consistent with the way the application processes requests.
One important step is to make sure that any input capable of changing a response is properly considered when constructing the cache key. Applications should also avoid trusting user-controlled headers when generating security-sensitive or cacheable content.
Caching should be configured carefully, especially for responses that contain user-specific or dynamic information. Responses that should not be shared between users should generally not be stored in a shared cache.
Finally, developers and security teams should test the interaction between the application and the caching layer rather than analyzing them independently. A secure application can still become vulnerable if a reverse proxy, CDN, or other caching component interprets requests differently from the backend.
By controlling which responses are cached, correctly defining cache keys, and avoiding unsafe trust in user-controlled inputs, the risk of Web Cache Poisoning can be significantly reduced.
Conclusion
Web Cache Poisoning is a good example of how security issues can arise from the interaction between different components of a web application.
The key to understanding this vulnerability is recognizing the difference between what the application uses to generate a response and what the cache uses to identify that response. When an attacker can control an input that affects the response but is ignored by the cache key, a poisoning condition may become possible.
For security testers, understanding cache behavior, identifying unkeyed inputs, and verifying whether manipulated responses can be stored and served to other users are the most important steps when testing for this vulnerability.
For developers, correctly defining cache keys, handling user-controlled inputs safely, and carefully configuring shared caching can help prevent these attacks.