Caching 412 responses

Colleagues,

RFC2616 and the HTTPbis drafts allow an intermediary to cache a 412 response to a request with an If-Match header, if the response contains appropriate Cache-Control headers.

My understanding of the specifications is that the intermediary is then within its right to serve the cached 412 response in response to subsequent GET requests that do not contain an If-Match header (see bottom of this mail for an example set of requests/responses that illustrate what I'm trying to describe).

This seems problematic because if an attacker knows an origin returns cacheable 412 responses, the attacker could fill the cache with 412 responses for a set of URLs (from that origin) by making spurious If-Match requests it knows will return 412 responses, and those 412 responses would subsequently be served up to other clients instead of the 'real' response the origin would have given if the 412 was not cacheable or if the attacker had not poisoned the intermediary's cache with 412s.

I was wondering whether this is a gap in the spec and cacheable 412 responses should have an explicit (or implicit?) Vary: If-Match semantic associated with them?

Or, whether it is purposely the way it is and is a case of providing the rope and letting people hang themselves if they so choose (Origin servers can always add the Vary: header if they care about cache poisoning, intermediaries can always not cache 412 responses, etc.).

An example (with only the relevant Headers included for compactness) of what I am talking about would be:

First request:
GET /foo HTTP/1.1
Host: example.com
If-Match: "thisisnotanetag"

HTTP/1.1 412 Precondition Failed
Cache-Control: max-age=900
...rest of response...


Subsequent request:
GET /foo HTTP/1.1
Host: example.com

HTTP/1.1 412 Precondition Failed
Age: 10
Cache-Control: max-age=900
...rest of response...

Thanks
Ben

Received on Saturday, 16 February 2013 10:57:33 UTC