offsecnotes

Web cache

by frankheat

A web cache is an intermediary system between the origin server and the user. When a client requests a static resource, the cache checks if it has a copy. If not (a cache miss), the request is sent to the origin server, which processes and responds.

Cache keys

When the cache gets an HTTP request, it decides whether to serve a cached response or forward the request to the origin server by generating a “cache key”. Typically, this would contain the request line and Host header but can also include headers and content type.


Cache rules

Cache rules dictate what can be cached and for how long. They usually store static resources, which change infrequently and are used across multiple pages. Dynamic content isn’t cached, as it often contains sensitive information, ensuring users receive the most up-to-date data from the server.


Detecting cached responses

If you notice a big difference in response time for the same request, this may also indicate that the faster response is served from the cache.


Using a cache buster

A “cache buster” is a technique to ensure that users get the most recent version of a file (like CSS, JavaScript, or images) by bypassing the browser’s cache. This is done by appending a unique query string (e.g., ?v=1.1 or ?ts=1689876543 or whatever you want) to the file URL. The browser treats this as a different file and loads the latest version, preventing issues with outdated cached files.

When testing for discrepancies and crafting a web cache deception exploit, ensure each request has a unique cache key to avoid receiving cached responses, which could skew your results.

Since the cache key typically includes the URL path and query parameters, change the key by adding a different query string with each request. Automate this with the Param Miner extension by selecting Add dynamic cachebuster under the Param Miner > Settings menu in Burp. This will add a unique query string to every request, viewable in the Logger tab.