AS216394 · WireShield

Attack Analysis

What is web cache deception? How the attack works and how to prevent it

Web cache deception tricks a cache into storing a private page as if it were public. Learn how the attack works, a real example and how to protect your site.

Web cache deception: the attacker gets the victim's private page stored in the cache and reads it

Web cache deception is an attack that tricks a cache into storing a user's private page as if it were public. The attacker prepares a special address for the victim to open while logged in; the cache takes the response for a static file and stores it, and the attacker then requests the same address and reads the victim's account details from the cache. The security research organisation PortSwigger describes it as a vulnerability that arises from differences in how the cache and the origin server handle requests, making the cache store sensitive, dynamic content. This guide explains what web cache deception is, how it works and how to prevent it.

What is web cache deception?

A cache is a layer that serves frequently requested files quickly without going back to the origin server. CDNs and web application firewalls (WAFs) often do this by looking at the file extension: addresses ending in .css, .js or .jpg count as "static files" and are stored.

The core of the attack is this: if a private page (for example your profile page) also opens when a made-up static extension is added to its address, the cache takes that response for a static file as well and stores it. What gets stored is the private page the victim saw with their own session.

How does a web cache deception attack work, step by step?

  1. Preparation: The attacker finds a private page that shows when logged in, for example /account/profile. They check that the server returns the same page even with a made-up path part added: /account/profile/theme.css.
  2. The trap: The attacker sends the address to the victim by e-mail, message or social media. The victim, logged in to the site, clicks it.
  3. Server response: The server ignores the extra path part and returns the victim's profile page.
  4. Wrong caching: Because the address ends in .css, the cache takes it for a static file and stores the response publicly.
  5. Harvest: The attacker requests the same address. The cache serves the victim's private page to the attacker: name, e-mail, phone, account details and sometimes session tokens.

The attacker does not need the victim's password or session; getting the victim to open the right address once is enough.

Why is it possible?

The attack works when three conditions come together:

  • Path interpretation difference: The origin server treats /account/profile/theme.css as /account/profile; the cache reads the address as a file.
  • Extension-based caching: The cache decides by the extension of the address, not by the content of the response.
  • Cache-Control headers ignored: Even when the origin server says no-store or private, a cache rule overrides it.

Web cache deception vs web cache poisoning

Web cache deceptionWeb cache poisoning
What the attacker doesGets the victim's private content stored in the cacheGets malicious content stored in the cache
Who is harmedThe victim whose content is cachedAll visitors who receive the cached content
What the attacker gainsReads the victim's private dataServes harmful content to visitors
Weakness behind itCache and server read the path differentlyManipulation of the cache key

A real example: PayPal and Black Hat 2017

The attack type was brought to public attention by the security researcher Omer Gil. Gil reported the issue to PayPal in February 2017 and, on July 26, 2017, presented it at Black Hat USA in a talk and white paper titled "Web Cache Deception Attack". The talk showed that the attack could let an unauthenticated attacker reach sensitive information of logged-in users. After the report, the affected services fixed the issue.

How do you test your own site?

Only on your own site and with permission, run this check:

  1. While logged in, add a made-up static extension to the address of a private page: /account/profile/test.css.
  2. If the page still opens with your private content, your server ignores the extra path part.
  3. Look at the response headers: X-Cache, Age or your CDN's own cache-status header. In the WireShield cache this is ws-cache-status.
  4. Open the same address from a browser that is not logged in. If your private content shows, the site is vulnerable.

How do you protect against web cache deception?

On the server:

  • Add Cache-Control: no-store and private to sensitive responses. Private pages must not be stored in any shared cache.
  • Return 404 for unknown paths. Made-up paths like /account/profile/theme.css should return an error, not the profile page.
  • Make path interpretation consistent. The cache and the server must read the same address the same way.

In the cache and CDN:

  • Make sure cache rules do not override the Cache-Control header.
  • Use a protection that compares the response content type with the extension of the address. PortSwigger cites Cloudflare's Cache Deception Armor as an example.

With WireShield: The Web Protection cache includes Cache Deception Armor, on by default. It applies to both the cloud and on-premise options and to every plan, and you can turn it off if you need to. The cache also only stores GET and HEAD requests, and it is not used when the origin server returns no-store or private, when the response sets a cookie (Set-Cookie) or when the request carries an Authorization header. All cache features are on the Web Protection page.

Frequently asked questions

Does a WAF stop web cache deception?

If caching and protection are done in the same layer, yes: when the cache is set up to store only responses that really are static, the attack does not work. So check whether your WAF's cache has a deception protection.

Are only logged-in users at risk?

Yes, the victim has to be logged in to the target site for the attack to work. But any site with logged-in visitors is at risk.

Am I safe if my site does not use a cache?

Even if your own server has no cache, there may be a CDN or WAF cache in front of it. Check the cache settings of your hosting provider, CDN and WAF.

What data can the attack expose?

Whatever is on the cached page: name, e-mail, phone, address, part of payment details, sometimes session or CSRF tokens.

Is Cache Deception Armor enough on its own?

It is an extra layer. Adding no-store/private to sensitive pages and returning 404 for unknown paths also fixes the source; use both together.

Sources

Next step

Let us review the cache and protection settings of your web application together. You can look at the Web Protection page or talk to the technical team.

All posts

Let’s review the right protection model for your network together.

Contact our team to talk through your technical needs.