`Vary` cache-key conflation of absent and empty request fields
Django's cache middleware generates the same cache key when a request header nominated by Vary is absent and when it is present with an empty value. An attacker could cause a response intended for one request state to be served to the other, potentially disclosing private data.
- Triaged in 12 days
- Fixed in 38 days
- Disclosed after 38 days
UpdateCacheMiddleware / CacheMiddleware generates the same page-cache key when a request header nominated by Vary is absent and when it is present with an empty field value. This can cause a response selected for one request to be returned for the other.
RFC 9111 §4.1 says that an absent nominated request field can match only another request in which that field is also absent. HTTP field-value grammar permits an empty field value.
steps to reproduce
Use the included local-only PoC:
PYTHONPATH=/path/to/django-6.1.1 python poc_django_vary_missing_empty.py
It sets up a view where presence of X-Scope selects a PRIVATE response and the response declares Vary: X-Scope.
GET /accountwithX-Scope:storesPRIVATE.GET /accountwith noX-Scopefield returnsPRIVATEfrom cache.- The view invocation counter is
1, proving the second response was a cache hit.
Observed output:
first=PRIVATE second=PRIVATE view_calls=1
VULNERABLE: missing and empty varied headers were treated as one cache key
I also verified Django’s ASGI request adapter preserves the present-but-empty field as META["HTTP_X_SCOPE"] == ""; the collapse happens in the cache-key generator.
Impact
An application that correctly uses Vary to separate representations based on a header’s presence can have a representation cached for a request with an empty header served to a request without that header, or vice versa. If either representation contains data intended only for the other request state, this is private-response disclosure through Django’s origin cache.
The attacker capability is only to send an empty request header and to cause/request cache population; no secret-key knowledge, raw SQL, or special deployment component is needed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the cache-key generator treats an absent header and an empty header value as equivalent, ignoring the distinction required by RFC 9111.
Impact
A representation cached for a request with an empty header could be served to a request without that header, or vice versa, potentially disclosing private data.
What the attacker needed
Django application using Vary and cache middleware; attacker can send requests with empty headers
How it was found
- Send a request with the header present but empty, causing a private response to be cached.
- Send a request without the header, which returns the cached private response.
- Observe that the view was called only once, confirming a cache hit.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a website caches pages, it uses a key to decide which stored copy to return. This report shows that two different requests (one with a header missing, one with the header present but empty) get the same key, so the wrong cached page can be shown. That could leak private information if the page was meant only for one of those requests.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.