Web Proxy / Caching Fundamentals Series

🎭 Understanding Web Cache Deception and Web Cache Poisoning From a Top 1% Perspective — When the Cache Layer and the Origin Server Interpret the Same URL Differently

Introduction

This article is part of the Top 1% Series Complete Article Guide, and article 6.2 in the Web Proxy/Caching Series.

Prerequisite Knowledge

Getting the Big Picture

Web cache deception abuses a mismatch between how the cache layer and the origin server interpret the exact same URL. For a URL like /account.php/nonexistent.css, the origin server ignores the extra trailing path and returns the normal /account.php page, personal data and all — but the cache layer, looking only at the .css extension, decides “this is a static asset” and caches that same personal-data-filled response as-is. Web cache poisoning, on the other hand, abuses an input (a header or parameter) the response’s content actually varies on, that never got included in the cache key — letting an attacker send just one malicious request and have that malicious response keep getting served to every other visitor who requests that same URL afterward.

graph TB
    subgraph "Web Cache Deception"
    Victim["Victim requests /account.php/fake.css"]
    Origin1["Origin: ignores the tail, returns the personal-data page"]
    Cache1["Cache: sees the .css extension, wrongly decides it's static"]
    Victim --> Origin1 --> Cache1
    Cache1 --> Leak["Personal data served to the next visitor"]
    end
graph TB
    subgraph "Web Cache Poisoning"
    Attacker["Attacker sends a malicious X-Forwarded-Host value"]
    Origin2["Origin: reflects the header's value into the response"]
    Cache2["Cache: this header was never part of the cache key"]
    Attacker --> Origin2 --> Cache2
    Cache2 --> Poisoned["Malicious response served to every other visitor"]
    end

Deep Dive Into the Fundamentals

Web Cache Deception: a Static Extension Becomes the Sole Basis for a Caching Decision

Many cache layers decide whether to cache a response by looking only at the URL’s extension. But if the origin server’s own routing ignores extra trailing path information on a URL and still processes it as the original endpoint, the cache layer and the origin server stop agreeing on what that URL actually refers to. This exact interpretation mismatch is the fundamental root cause that makes web cache deception possible.

Web Cache Poisoning: “an Input Left Out of the Key” Becomes the Attack’s Entry Point

A cache key typically includes only the URL path and part of the query parameters — a header like X-Forwarded-Host, or certain query parameters like utm_content, commonly get left out of the key. But if the origin server actually reflects the value of one of these “inputs left out of the key” into the response content (a generated URL, a redirect target, and similar), an attacker can send just one malicious request with a malicious value for that input, bake that response into the cache, and have it served to every subsequent visitor.

A Broader Technique 2024 Research Revealed, Abusing Parser Interpretation Differences

Research published in 2024 systematically revealed that various HTTP servers and proxies interpret a cleverly crafted URL differently from each other — an issue rooted in RFC ambiguity — as a technique that achieves arbitrary cache poisoning and cache deception across numerous websites and CDN providers. Differences in how delimiter characters like ;, ?, and # get interpreted were pointed out as a similar class of abuse pattern.

What a Pro Sees Here (Top 1% Understanding)

“The Cache Layer” and “the Origin Server” Don’t Necessarily Interpret the Same URL the Same Way

Surprisingly many designers never even hold the premise that two different pieces of software — a cache and an origin — might interpret the same URL string under different rules at all. The habit of re-asking, every time you introduce a cache, “do the cache layer and the origin server genuinely interpret this URL the same way” is the perspective a top-1% engineer carries.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. A page containing personal data might be getting cached unintentionally: Send a request with a static-asset extension appended to the URL’s tail, and check whether the origin server still returns the same dynamic content.
  2. The value of a specific header is leaking into other visitors’ responses: Check whether that header actually affects the response content, despite never being included in the cache key.
  3. Unexpected caching behavior started after introducing a CDN: Check whether the cache layer and the origin server genuinely share the same rules for interpreting a URL’s path.

Summary

Takeaways to Apply Today

  1. When introducing a cache, check whether it’s making caching decisions based solely on the URL’s extension, against the origin server’s actual routing.
  2. Verify that every input affecting a response’s content is correctly reflected in either the cache key or the Vary header.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).