Re: Caching 412 responses

Mark Nottingham <> Fri, 17 May 2013 03:28 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 1BDF311E8112 for <>; Thu, 16 May 2013 20:28:02 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -8.613
X-Spam-Status: No, score=-8.613 tagged_above=-999 required=5 tests=[AWL=1.986, BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id s3IkIKxY9j+n for <>; Thu, 16 May 2013 20:27:56 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 2C70D11E80E4 for <>; Thu, 16 May 2013 20:27:55 -0700 (PDT)
Received: from lists by with local (Exim 4.72) (envelope-from <>) id 1UdBKF-000545-LC for; Fri, 17 May 2013 03:27:23 +0000
Resent-Date: Fri, 17 May 2013 03:27:23 +0000
Resent-Message-Id: <>
Received: from ([]) by with esmtp (Exim 4.72) (envelope-from <>) id 1UdBK4-00053M-EY for; Fri, 17 May 2013 03:27:12 +0000
Received: from ([]) by with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from <>) id 1UdBK2-0002E0-Lv for; Fri, 17 May 2013 03:27:12 +0000
Received: from [] (unknown []) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPSA id BD40B22E1F3; Thu, 16 May 2013 23:26:48 -0400 (EDT)
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\))
From: Mark Nottingham <>
In-Reply-To: <>
Date: Fri, 17 May 2013 13:26:43 +1000
Cc: HTTP Working Group <>
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <>
To: Ben Niven-Jenkins <>
X-Mailer: Apple Mail (2.1503)
Received-SPF: pass client-ip=;;
X-W3C-Hub-Spam-Status: No, score=-3.4
X-W3C-Hub-Spam-Report: AWL=-3.371, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001
X-W3C-Scan-Sig: 1UdBK2-0002E0-Lv de0e7be7cec30ae4e033b69eccd11db4
Subject: Re: Caching 412 responses
Archived-At: <>
X-Mailing-List: <> archive/latest/18019
Precedence: list
List-Id: <>
List-Help: <>
List-Post: <>
List-Unsubscribe: <>

Hi Ben,

In the current model, the server *has* to make a 412 explicitly cacheable (e.g, with CC: max-age, as you do below) or otherwise usable (e.g., with CC: public) for an intermediary to store it, so I don't see how this is exploitable; the server shouldn't make those responses cacheable (and indeed, AFAICT none do).

The same could be said about 413 (Request Entity Too Large), 415 (Unsupported Media Type), 416 (Requested Range Not Satisfiable), 428 (Precondition Required), and probably a few more. If someone wants to make these responses cacheable, they need to do the work to make them properly cacheable (by including Vary).

Make sense?


On 16/02/2013, at 9:57 PM, Ben Niven-Jenkins <> wrote:

> 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:
> If-Match: "thisisnotanetag"
> HTTP/1.1 412 Precondition Failed
> Cache-Control: max-age=900
> of response...
> Subsequent request:
> GET /foo HTTP/1.1
> Host:
> HTTP/1.1 412 Precondition Failed
> Age: 10
> Cache-Control: max-age=900
> of response...
> Thanks
> Ben

Mark Nottingham