Re: [TLS] RFC 6066 - Max fragment length negotiation

Ilari Liusvaara <ilariliusvaara@welho.com> Fri, 17 March 2017 14:44 UTC

Return-Path: <ilariliusvaara@welho.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DF828128796 for <tls@ietfa.amsl.com>; Fri, 17 Mar 2017 07:44:59 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 COn8ts0M3psQ for <tls@ietfa.amsl.com>; Fri, 17 Mar 2017 07:44:57 -0700 (PDT)
Received: from welho-filter4.welho.com (welho-filter4.welho.com [83.102.41.26]) by ietfa.amsl.com (Postfix) with ESMTP id 923E3126C23 for <tls@ietf.org>; Fri, 17 Mar 2017 07:44:57 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by welho-filter4.welho.com (Postfix) with ESMTP id 5B3CD2783F; Fri, 17 Mar 2017 16:44:56 +0200 (EET)
X-Virus-Scanned: Debian amavisd-new at pp.htv.fi
Received: from welho-smtp2.welho.com ([IPv6:::ffff:83.102.41.85]) by localhost (welho-filter4.welho.com [::ffff:83.102.41.26]) (amavisd-new, port 10024) with ESMTP id rerGNYyjkRzM; Fri, 17 Mar 2017 16:44:55 +0200 (EET)
Received: from LK-Perkele-V2 (87-92-51-204.bb.dnainternet.fi [87.92.51.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by welho-smtp2.welho.com (Postfix) with ESMTPSA id 9C95721C; Fri, 17 Mar 2017 16:44:55 +0200 (EET)
Date: Fri, 17 Mar 2017 16:44:48 +0200
From: Ilari Liusvaara <ilariliusvaara@welho.com>
To: Thomas Pornin <pornin@bolet.org>
Cc: Peter Gutmann <pgut001@cs.auckland.ac.nz>, "tls@ietf.org" <tls@ietf.org>
Message-ID: <20170317144448.GB26550@LK-Perkele-V2.elisa-laajakaista.fi>
References: <CABkgnnVRZBwXHZ6w=gX9pykNpXp80OLP1pe-VMg-uO-C6O8yEQ@mail.gmail.com> <1489710142144.88978@cs.auckland.ac.nz> <CABkgnnXiB5ksGbbPqDP3D=FVdQu9ht0vD8-T-5HTaEKQQE4+9w@mail.gmail.com> <1489721710740.52293@cs.auckland.ac.nz> <CABkgnnWq_5e8TJgJV+okqi6vo-_5=811pOZRtUCp0TD07SmNoQ@mail.gmail.com> <CABkgnnW=Pz+6M8UYoB+MTY8rQp9vsHyh6aqiSb3EbTT_BdWokA@mail.gmail.com> <1489747107536.25854@cs.auckland.ac.nz> <CABkgnnUqHvc6zOL1SYP8FwBcF7SeMnnT-PJOwhMB1qqeDAcp9w@mail.gmail.com> <1489749662616.94542@cs.auckland.ac.nz> <20170317133344.GA20310@bolet.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
In-Reply-To: <20170317133344.GA20310@bolet.org>
User-Agent: Mutt/1.5.23 (2014-03-12)
Sender: ilariliusvaara@welho.com
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/Iw8eD2TuFnnRKDZT0oS9l61wqd8>
Subject: Re: [TLS] RFC 6066 - Max fragment length negotiation
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "This is the mailing list for the Transport Layer Security working group of the IETF." <tls.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/tls>, <mailto:tls-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/tls/>
List-Post: <mailto:tls@ietf.org>
List-Help: <mailto:tls-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/tls>, <mailto:tls-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 17 Mar 2017 14:45:00 -0000

On Fri, Mar 17, 2017 at 02:33:44PM +0100, Thomas Pornin wrote:
> On Fri, Mar 17, 2017 at 11:21:12AM +0000, Peter Gutmann wrote:
> > However, this then leads to a problem where it doesn't actually solve
> > the constrained-client/server issue, if a client asks for 2K max
> > record size and the server responds with a 4K hello then it's going to
> > break the client even if later application_data records are only 2K.
> > So it would need to apply to every record type, not just
> > application_data.

> Fragmentation of messages is another issue, which is correlated but
> still distinct. Note for instance that it is customary, in the case of
> TLS 1.0 with a CBC-based cipher suite, to fragment _all_ records
> (application data records, at least) as part of a protection against
> BEAST-like attacks. Also, having very small buffers does not necessarily
> prevent processing larger handshake messages, or even larger unencrypted
> records. Here I may point at my own SSL implementation (www.bearssl.org)
> that can do both: it supports unencrypted records that are larger than
> its input buffer, and it supports huge handshake messages. It can
> actually perform rudimentary X.509 path validation even with
> multi-megabyte certificates, while keeping to a few kilobytes of RAM and
> no dynamic allocation.
>
> Now that does not mean that a "don't fragment" flag has no value.
> Indeed, streamed processing of messages is not easy to implement (I
> know, since I did it), and having some guarantees on non-fragmentations
> may help some implementations that are very constrained in ROM size and
> must stick to the simplest possible code. But it still is a distinct
> thing. Moreover, maximum handshake message length needs not be the same
> as the maximum record length. For instance, OpenSSL tends to enforce a
> maximum 64 kB size on handshake messages. Maybe we need a "maximum
> handshake message length" extension.

The TLS implementation I did has 128kB limit. Also, unfragmented
handshake messages are subject to zerocopy processing. No
streaming processing.

The mere thought of someone implementing streaming processing in
C scares me. I think BearSSL autogenerates that code.

Also, in TLS 1.3, certificate messages are considerably more
complicated. I don't think streaming processing of recommended-to-
support stuff is even possible.

My own implementation won't implement all of that, but the parts
it implements (still took a few security issues because of the
complexity beyond what TLS 1.2 REQUIRED) still require considerable
back and forth. Most of the memory is borrowed from the message, but
still not streamable.

> In order to "fix" RFC 6066, the following would be needed, in my opinion:
> 
>   - Allow the server to send the extension even if the client did not
>     send it.

TLS architecture does not allow this. Sending any extension in server
hello that wasn't in client hello causes loads of implementations to
just blow up (my implementation is certainly one of those). In fact,
clients are REQUIRED to.

 
>   - Allow the server to mandate fragment lengths smaller than the
>     value sent by the client (a client not sending the extension would
>     be assumed to have implicitly sent an extension with a 16384-byte
>     max fragment length).

I think allowing server to give lower limit for client records was
one of the key improvments over max_record_length.

I also think with the proposed extension, client could send 4096 and
server could send 16384. Meaning server->client only supports records
up to 4096, but client->server supports records of any size.

>   - Preferably, change the encoding to allow for _two_ lengths, for
>     both directions, negociated separately.

You mean maximum handshake message size and maximum record size?



-Ilari