Re: [websec] Minor feedback on draft-ietf-websec-mime-sniff-03

Adam Barth <ietf@adambarth.com> Sun, 15 January 2012 19:53 UTC

Return-Path: <ietf@adambarth.com>
X-Original-To: websec@ietfa.amsl.com
Delivered-To: websec@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5A99921F847C for <websec@ietfa.amsl.com>; Sun, 15 Jan 2012 11:53:13 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.747
X-Spam-Level:
X-Spam-Status: No, score=-2.747 tagged_above=-999 required=5 tests=[AWL=0.230, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, RCVD_IN_DNSWL_LOW=-1]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zv47eFwAe62j for <websec@ietfa.amsl.com>; Sun, 15 Jan 2012 11:53:12 -0800 (PST)
Received: from mail-iy0-f172.google.com (mail-iy0-f172.google.com [209.85.210.172]) by ietfa.amsl.com (Postfix) with ESMTP id 954C721F8475 for <websec@ietf.org>; Sun, 15 Jan 2012 11:53:12 -0800 (PST)
Received: by iaae16 with SMTP id e16so8038163iaa.31 for <websec@ietf.org>; Sun, 15 Jan 2012 11:53:11 -0800 (PST)
Received: by 10.43.53.1 with SMTP id vo1mr9909679icb.2.1326657191130; Sun, 15 Jan 2012 11:53:11 -0800 (PST)
Received: from mail-iy0-f172.google.com (mail-iy0-f172.google.com [209.85.210.172]) by mx.google.com with ESMTPS id xu6sm28800309igb.7.2012.01.15.11.53.09 (version=SSLv3 cipher=OTHER); Sun, 15 Jan 2012 11:53:09 -0800 (PST)
Received: by iaae16 with SMTP id e16so8038139iaa.31 for <websec@ietf.org>; Sun, 15 Jan 2012 11:53:09 -0800 (PST)
Received: by 10.50.214.38 with SMTP id nx6mr7259333igc.19.1326657189101; Sun, 15 Jan 2012 11:53:09 -0800 (PST)
MIME-Version: 1.0
Received: by 10.231.62.139 with HTTP; Sun, 15 Jan 2012 11:52:38 -0800 (PST)
In-Reply-To: <20120115195120.GG32205@1wt.eu>
References: <20120115195120.GG32205@1wt.eu>
From: Adam Barth <ietf@adambarth.com>
Date: Sun, 15 Jan 2012 11:52:38 -0800
Message-ID: <CAJE5ia_gBJ=7DviO5hkmqnXHtC8ptHyKAMieBrFbVV-h9rQo9g@mail.gmail.com>
To: Willy Tarreau <w@1wt.eu>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Cc: websec@ietf.org, ian@hixie.ch
Subject: Re: [websec] Minor feedback on draft-ietf-websec-mime-sniff-03
X-BeenThere: websec@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: Web Application Security Minus Authentication and Transport <websec.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/websec>, <mailto:websec-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/websec>
List-Post: <mailto:websec@ietf.org>
List-Help: <mailto:websec-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/websec>, <mailto:websec-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 15 Jan 2012 19:53:13 -0000

The requirement in the spec is what we intend.  The rule applies only
to that exact octet sequence.

Adam


On Sun, Jan 15, 2012 at 11:51 AM, Willy Tarreau <w@1wt.eu> wrote:
> Hello Adam, Ian,
>
> Today I came across your draft "draft-ietf-websec-mime-sniff-03", and
> noticed the point below :
>
>   2.  If the octets were fetched via HTTP and there is an HTTP Content-
>       Type header field and the value of the last such header field has
>       octets that *exactly* match the octets contained in one of the
>       following lines:
>
>      +-------------------------------+--------------------------------+
>      | Bytes in Hexadecimal          | Textual Representation         |
>      +-------------------------------+--------------------------------+
>      | 74 65 78 74 2f 70 6c 61 69 6e | text/plain                     |
>      +-------------------------------+--------------------------------+
>      | 74 65 78 74 2f 70 6c 61 69 6e | text/plain; charset=ISO-8859-1 |
>      | 3b 20 63 68 61 72 73 65 74 3d |                                |
>      | 49 53 4f 2d 38 38 35 39 2d 31 |                                |
>     .../...
>
> I was having a doubt about spaces being optional around the semi-colon,
> so I just checked and indeed we have OWS before and after it :
>
>   http://www.ietf.org/id/draft-ietf-httpbis-p3-payload-18.txt
>
>   2.3.  Media Types
>
>   HTTP uses Internet Media Types [RFC2046] in the Content-Type
>   (Section 6.8) and Accept (Section 6.1) header fields in order to
>   provide open and extensible data typing and type negotiation.
>
>     media-type = type "/" subtype *( OWS ";" OWS parameter )
>     type       = token
>     subtype    = token
>
>   The type/subtype MAY be followed by parameters in the form of
>   attribute/value pairs.
>
>     parameter      = attribute "=" value
>     attribute      = token
>     value          = word
>
> Also, it is said here that quotes are allowed around the parameter
> value :
>
>   A parameter value that matches the token production can be
>   transmitted as either a token or within a quoted-string.  The quoted
>   and unquoted values are equivalent.
>
> So examples below are completely valid :
>
>   Content-type: text/plain;charset="ISO-8859-1"
>
>   Content-type: text/plain   ;  charset=ISO-8859-1
>
>   Content-type: text/plain ;
>         charset="ISO-8859-1"
>
> Thus the byte matching can only apply to the tokens and values. I think the
> safest thing to do would be to refer to the HTTP spec to define the header
> format then suggest byte matches for each fields, for instance :
>
>       If the octets were fetched via HTTP and there is an HTTP Content-
>       Type header field and the value of the last such header *exactly*
>       matches one of the media-types below, then the sniffed-type is
>       defined as the concatenation of the unquoted matching parts :
>
>       media-type = type "/" subtype *( OWS ";" OWS parameter )
>       sniffed-type = type "/" subtype 1*( "; " attribute "=" value )
>
>       All accepted media-types must *exactly* match :
>          - type    = "text" (hex 74 65 78 74)
>          - subtype = "plain" (hex 70 6c 61 69 6e)
>
>       If a parameter is present, its attribute must be "charset"
>       (hex 63 68 61 72 73 65 74) and the value must be one of :
>          - "ISO-8859-1" (hex 49 53 4f 2d 38 38 35 39 2d 31)
>          - "iso-8859-1" (hex 69 73 6f 2d 38 38 35 39 2d 31)
>          - "UTF-8"      (hex 55 54 46 2d 38)
>
> Please also note that HTTP indicates that some attributes accept a
> case-insensitive value. I have not yet found in the spec if "charset"
> accepts a case-insensitive value, but given that you identified two
> possible cases for "iso-8859-1", it is likely that "charset" falls into
> this case.
>
> Best regards,
> Willy
>