Re: [secdir] secdir review of draft-ietf-httpbis-p1-messaging-25

Ben Laurie <benl@google.com> Thu, 19 December 2013 12:21 UTC

Return-Path: <benl@google.com>
X-Original-To: secdir@ietfa.amsl.com
Delivered-To: secdir@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5E0751A1F1B for <secdir@ietfa.amsl.com>; Thu, 19 Dec 2013 04:21:01 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.917
X-Spam-Level:
X-Spam-Status: No, score=-1.917 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, RP_MATCHES_RCVD=-0.538, SPF_PASS=-0.001] autolearn=unavailable
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8160LVKXb4kW for <secdir@ietfa.amsl.com>; Thu, 19 Dec 2013 04:20:58 -0800 (PST)
Received: from mail-vc0-x22c.google.com (mail-vc0-x22c.google.com [IPv6:2607:f8b0:400c:c03::22c]) by ietfa.amsl.com (Postfix) with ESMTP id B04B91A1F54 for <secdir@ietf.org>; Thu, 19 Dec 2013 04:20:58 -0800 (PST)
Received: by mail-vc0-f172.google.com with SMTP id ij19so601723vcb.31 for <secdir@ietf.org>; Thu, 19 Dec 2013 04:20:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=husSEnS0ODRDmMt7u0QlZhvkLzczRyQx5M6UpCSHg/s=; b=VQdSSiujLMbP5wqarQZ5ng7pWttRoP6cDzxQBtTR+/tbXNvbyLRk99nd35sGYXgeoB YpevYKSuvFKEZ8Qd6GHjdG1NCs5cL+n7fUJfBPjk7JGc0Ni/ghcGa4J2CS/YqVTFuzif MwSRAGNe8V+udaXqLy3Y4OwO52bp2EP/ycz1lPd7UTGjFjR2QgSGzVsuvPvR6YK7bdbd M2bxHXb5UKhlngqW+AVIbg0taygjTd3w+IAW0gIA3KQAXENxXzX9l8KgAKIS+p2ekpwA DT76LiH/6Esuv0vz7ANoZR/fbf6/SbekLW5yqn020UAeTZpouOpwQoWaarQ8Kjt5zjad 5u9w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=husSEnS0ODRDmMt7u0QlZhvkLzczRyQx5M6UpCSHg/s=; b=Ee9X54aiRMKNSlcAwYLEE8f5lKssgVtbTc/JdqpTTsop5BsbeLv5NH07ZX+cn9X/By 9NKxAk1kmcd1i4KBjDyWud5a1IwpMI6aywFfTpLMMFzn0gqvO7DUpltTivQkfrUG8Zs+ QXqWHWY4MMMM0dc991u2h4W6XSBQCYsXvQ42iYxzpP/vuINiWY3QR96/ayHwmlyPWvOZ MNVBO95k7CuUfELhrOJiL0OWyc8WBprf+pZ/7bz9wVmE1KnQPZe9QX7vUNyaU2VkR/eD ZV1zbAjC8Pb4DnsZtpc7xlyeUTHZUqu/tPb11DGo5nzwg9XkmlMA8YiKHXUcw2+hW8PQ sP6g==
X-Gm-Message-State: ALoCoQkikWO+zKG/nE0zNj60pGQRErsauWfMhHXqBr3qzk3VFlUsR1xtw8RtasJPvqg6wOyuzyZA7XwgHvOnhK9yHgDLW6u/3wPI8PntF6TqrqozcBNe+CQU0APVKRu3CTeoxUNMxofkfGH78w7zeW1jJIemBUoNm/b5/S45iwADtmbILAAO88IgN7+f+roGm3N3WXyfofSo
MIME-Version: 1.0
X-Received: by 10.58.156.106 with SMTP id wd10mr674308veb.7.1387455656568; Thu, 19 Dec 2013 04:20:56 -0800 (PST)
Received: by 10.52.178.9 with HTTP; Thu, 19 Dec 2013 04:20:55 -0800 (PST)
In-Reply-To: <453C9132-9FFF-4DC0-8E9C-1CBA1D90F4B5@mnot.net>
References: <CABrd9SS-R7s4U7_tRGuV2mNgxKnW9mhk=AboNcUxFEAZSLPnbA@mail.gmail.com> <453C9132-9FFF-4DC0-8E9C-1CBA1D90F4B5@mnot.net>
Date: Thu, 19 Dec 2013 12:20:55 +0000
Message-ID: <CABrd9SQPMiVz8kJKao8pA1v0a36mCBorQGUYZBrGUDuOCB8fHQ@mail.gmail.com>
From: Ben Laurie <benl@google.com>
To: Mark Nottingham <mnot@mnot.net>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Cc: draft-ietf-httpbis-p1-messaging.all@tools.ietf.org, The IESG <iesg@ietf.org>, "secdir@ietf.org" <secdir@ietf.org>
Subject: Re: [secdir] secdir review of draft-ietf-httpbis-p1-messaging-25
X-BeenThere: secdir@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Security Area Directorate <secdir.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/secdir>, <mailto:secdir-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/secdir/>
List-Post: <mailto:secdir@ietf.org>
List-Help: <mailto:secdir-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/secdir>, <mailto:secdir-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 19 Dec 2013 12:21:01 -0000

On 19 December 2013 03:01, Mark Nottingham <mnot@mnot.net> wrote:
> Hi Ben,
>
> Thanks for the detailed review. A few preliminary comments below.
>
>
> On 19 Dec 2013, at 5:02 am, Ben Laurie <benl@google.com> wrote:
>
>> I have reviewed this document as part of the security directorate's
>> ongoing effort to review all IETF documents being processed by the
>> IESG.  These comments were written primarily for the benefit of the
>> security area directors.  Document editors and WG chairs should treat
>> these comments just like any other last call comments.
>>
>> Summary: HTTP/1.1 is complicated, with many pitfalls. The draft does
>> not give a great deal of assistance in dealing with them, and, indeed,
>> encourages s/w to trip over these pitfalls.
>>
>> 2.4 Caches
>>
>> As well as poisoning attacks, websites can leave themselves exposed by
>> failing to set appropriate caching values - for example, allowing
>> caches to cache pages containing pesonal information, which is later
>> served to the wrong person. The I-D should discuss this issue and give
>> concrete advice on how to avoid inappropriate caching, whilst still
>> permitting appropriate caching.
>>
>> Likewise, caches can be fooled into serving cached data inappropriaely
>> - for example, in response to a subtly different request.
>>
>> Part 6, which is devoted to caches, appears to give no advice
>> whatsoever, other than applications should "emit appropriate
>> Cache-Control response header fields".
>>
>> It also, strangely, blames cache poisoning on implementation flaws,
>> whilst exactly those types of flaws are encouraged in the next section of this
>> I-D: "Unless noted otherwise, a recipient MAY attempt to recover a
>> usable  protocol element from an invalid construct."
>
> Do you have a suggestion for text we should include (either here or in p6)?

I would say that recipients MUT NOT attempt recover a usable...

Also, for "appropriate Cache-Control response header fields", I'd
suggest including examples for likely scenarios (e.g. "can be freely
cached, must not be cached at all, ever, can be cached for anyone with
this particular cookie" [if that's even possible]).

>> 2.5.  Conformance and Error Handling
>>
>> Obviously very important for security. Is littered with vague
>> generalities like
>>
>> "A sender MUST NOT generate protocol elements that convey a meaning
>> that is known by that sender to be false."
>>
>> "Within a given message, a sender MUST NOT generate protocol elements
>> or syntax alternatives that are only allowed to be generated by
>> participants in other roles (i.e., a role that the sender does not
>> have for that message)."
>>
>> "When a received protocol element is parsed, the recipient MUST be
>>   able to parse any value of reasonable length that is applicable to
>>   the recipient's role and matches the grammar defined by the
>>   corresponding ABNF rules."
>>
>> without giving any concrete advice (other than, presumably, "read and
>> memorise the whole xxx pages of RFCs A, B, C ... Z"). Are there
>> matrices of what is allowed, for example? Where? How long is
>> "reasonable"? What do you do if the length is, in fact,
>> "unreasonable"?
>
> If we were designing HTTP from scratch, I would agree with you. However, we're not; it is arguably the most widely deployed and diversely implemented application protocols. There are few (if any) fields where a single recommendation about "reasonable" size (for example) would be appropriate, because HTTP is used for everything from Web browsers to embedded controllers. We can't make these things non-conformant retrospectively.

You could, perhaps, distinguish between what might be found in the
wild (that you want to make conformant, for some reason) and what you
advise for new implementations.

> We have, however, introduced recommendations (not requirements) around minimum field lengths, etc. in most places. If you find a particular one lacking, please do bring it to our attention.
>
>
>> As mentioned above, dangerous behaviour is encouraged on the part of
>> receivers - i.e. to attempt to make some sense of invalid constructs.
>>
>> Also, "A recipient MUST interpret a received protocol element
>> according to the semantics defined for it by this specification,
>> including extensions to this specification, unless the recipient has
>> determined (through experience or configuration) that the sender
>> incorrectly implements what is implied by those semantics." is a
>> licence for arbitraty behaviour.
>>
>> No mention at all of any of this in Security Considerations.
>>
>> 2.6. Protocol Versioning
>>
>> "A client MAY send a lower request version if it is known that the
>> server incorrectly implements the HTTP specification, but only after
>> the client has attempted at least one normal request and determined
>> from the response status code or header fields (e.g., Server) that the
>> server improperly handles higher request versions." - more
>> encouragement to ignore the spec, and doubtless introduce yet more
>> interesting security flaws.
>
> How is this "ignoring the spec"?

You allow clients to fall back to older specs (i.e. ignore this spec)
on essentially arbitrary grounds.

>> 3.  Message Format
>>
>> "A recipient that receives whitespace between the start-line and the
>> first header field MUST either reject the message as invalid or
>> consume each whitespace-preceded line without further processing of it
>> (i.e., ignore the entire line, along with any subsequent lines
>> preceded by whitespace, until a properly formed header field is
>> received or the header section is terminated)." - ditto.
>
> Can you please give us more substantive input? What is the *specific* flaw here?

The issue is encouraging interpreting content that may or may not be
HTTP as if it were (combined with other admonishments to guess at its
meaning as you go). This is how request splitting attacks work, for
example.

In other words, recipients should be strict in their interpretation
lest they are fooled into misinterpretation.

>> 3.1.1.  Request Line
>>
>> "Recipients of an invalid request-line SHOULD respond with either a
>> 400 (Bad Request) error or a 301 (Moved Permanently) redirect with the
>> request-target properly encoded." - ditto.
>
> And again...

See above. The response should be a 400, never a 301.

>> 3.2.2.  Field Order
>>
>> "A server MUST wait until the entire header section is received before
>> interpreting a request message, since later header fields might
>> include conditionals, authentication credentials, or deliberately
>> misleading duplicate header fields that would impact request
>> processing."
>>
>> Good advice, but sadly, no substance - it goes on to say:
>>
>> "A recipient MAY combine multiple header fields with the same field
>> name into one "field-name: field-value" pair, without changing the
>> semantics of the message, by appending each subsequent field value to
>> the combined field value in order, separated by a comma.  The order in
>> which header fields with the same field name are received is therefore
>> significant to the interpretation of the combined field value"
>>
>> Which gives no useful advice about "duplicate header fields that would
>> impact request processing", and worse, means that intermediates and
>> endpoints have essentially no chance of predicting the behaviour of
>> machines up/downstream from them.
>
> We've taken the approach of identifying security-sensitive headers and giving such advice in their specification, since this section is going to be read by implementers of the generic message parsers, not the folks who need to understand the security import of this design.

OK. It would probably be useful to have a list somewhere, rather than
obliging everyone, e.g. code auditors, to read all n documents.

>> 3.2.4.  Field Parsing
>>
>> "A server that receives an obs-fold in a request message that is not
>> within a message/http container MUST either reject the message by
>> sending a 400 (Bad Request), preferably with a representation
>> explaining that obsolete line folding is unacceptable, or replace each
>> received obs-fold with one or more SP octets prior to interpreting the
>> field value or forwarding the message downstream." - again,
>> encouraging dangerous behaviour.
>
> Please explain how it is dangerous.

Again, non-strict interpretation can lead (and historically has led)
to misinterpretation, which leads to exploitable bugs.

>> 3.3.2.  Content-Length
>>
>> Oddly, advice is given on what to when multiple identical content
>> lengths are received, but not when they're different...
>>
>> "If a message is received that has multiple Content-Length header
>> fields with field-values consisting of the same decimal value, or a
>> single Content-Length header field with a field value containing a
>> list of identical decimal values (e.g., "Content-Length: 42, 42"),
>> indicating that duplicate Content-Length header fields have been
>> generated or combined by an upstream message processor, then the
>> recipient MUST either reject the message as invalid or replace the
>> duplicated field-values with a single valid Content-Length field
>> containing that decimal value prior to determining the message body
>> length or forwarding the message."
>>
>> (though the next section does say what to do: for a change, reject
>> it).
>
> So, it is given. What's the issue - would you like this section rearranged? If so, please come out and say so; if not, please explain.

Yeah, it just seemed odd to deal with one case in one place and the
other in a completely different section. It also is a little odd to
collapse multiple content-lengths (which is incorrect according to the
spec) into a single one, just because they happen to match.

>> "Since there is no way to distinguish a successfully completed,
>> close-delimited message from a partially-received message interrupted
>> by network failure, a server SHOULD generate encoding or length-
>> delimited messages whenever possible.  The close-delimiting feature
>> exists primarily for backwards compatibility with HTTP/1.0."
>>
>> Surely closed connections _can_ be distinguished from interrupted
>> ones?
>
> Not if the client is behind a proxy, and not if the HTTP API doesn't expose this information. That said, "no way" is too strong here; should be at least qualified with a "sometimes."

Perhaps the proxy should indicate if this has happened?