Re: [TLS] TLSv1.3 Cookies

Matt Caswell <frodo@baggins.org> Wed, 13 September 2017 15:24 UTC

Return-Path: <frodo@baggins.org>
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 B42BF132332 for <tls@ietfa.amsl.com>; Wed, 13 Sep 2017 08:24:53 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.119
X-Spam-Level:
X-Spam-Status: No, score=-2.119 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, 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 OXFeNvdfgY_S for <tls@ietfa.amsl.com>; Wed, 13 Sep 2017 08:24:52 -0700 (PDT)
Received: from mx496502.smtp-engine.com (mx496502.smtp-engine.com [217.160.92.157]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 078AD127517 for <tls@ietf.org>; Wed, 13 Sep 2017 08:24:51 -0700 (PDT)
Received: from mail-io0-f178.google.com (mail-io0-f178.google.com [209.85.223.178]) by mx496502.smtp-engine.com (Postfix) with ESMTPSA id 0FCD0DA7 for <tls@ietf.org>; Wed, 13 Sep 2017 16:24:48 +0100 (BST)
Received: by mail-io0-f178.google.com with SMTP id n69so2830369ioi.5 for <tls@ietf.org>; Wed, 13 Sep 2017 08:24:48 -0700 (PDT)
X-Gm-Message-State: AHPjjUiistshRN5qiiHLPYFV4maDTWyKkhIYhCJ+n6HfZFKl6ltA8qbl t8CXQX1YWGs1bvCXEsXT9+9g9EVuj68d4W/Popg=
X-Google-Smtp-Source: AOwi7QCEmrBYPB7NL9DPfnHvJYGQgEdrZU0N94IRBOGbtYTEyln95fSAdBsnd7GU5Mh1Pg/oHZXT2/Z3b5fnlZ8aK/U=
X-Received: by 10.107.29.149 with SMTP id d143mr26805588iod.201.1505316278154; Wed, 13 Sep 2017 08:24:38 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.79.165.25 with HTTP; Wed, 13 Sep 2017 08:24:37 -0700 (PDT)
In-Reply-To: <20170913150929.nupe6fq5rqtroflp@LK-Perkele-VII>
References: <CAMoSCWYXWJMkFAdrcy033_bjMZjRUiU-V5f8MkoTXyvDfw+z6A@mail.gmail.com> <20170913150929.nupe6fq5rqtroflp@LK-Perkele-VII>
From: Matt Caswell <frodo@baggins.org>
Date: Wed, 13 Sep 2017 16:24:37 +0100
X-Gmail-Original-Message-ID: <CAMoSCWapcL_xPLvkm6ey+Go1U+4Z_y2bZbKqCRPSHntFj3G41w@mail.gmail.com>
Message-ID: <CAMoSCWapcL_xPLvkm6ey+Go1U+4Z_y2bZbKqCRPSHntFj3G41w@mail.gmail.com>
To: Ilari Liusvaara <ilariliusvaara@welho.com>
Cc: "tls@ietf.org" <tls@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/zCdjL4VBpuQ7W-X5XG8qcWaYebQ>
Subject: Re: [TLS] TLSv1.3 Cookies
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: Wed, 13 Sep 2017 15:24:54 -0000

On 13 September 2017 at 16:09, Ilari Liusvaara <ilariliusvaara@welho.com> wrote:
> On Wed, Sep 13, 2017 at 03:53:46PM +0100, Matt Caswell wrote:
>> I am looking at trying to implement the TLSv1.3 stateless cookie
>> mechanism (in order to be able to support QUIC stateless retries).
>>
>> I am not clear how cookies are supposed to interact with early_data.
>> Consider the scenario where a server is operating statelessly. Because
>> there is no state each ClientHello looks like the first one it ever
>> saw. The server only knows that a particular ClientHello is actually a
>> ClientHello2 following an HRR because of the state held in the cookie.
>
> Looking at the definitions of Cookie and EarlyData extensions, those
> two are mutually exclusive. That is, there can be three kinds of
> ClientHello messages:
>
> 1) Contains neither Cookie nor EarlyData.
> 2) Contains an EarlyData, but not Cookie.
> 3) Contains a Cookie, but not EarlyData.
>
> (This exclusivity arises because Cookie can only be present in a retry,
> but EarlyData is stripped out for retry).
>
>> What happens when a client attempts to send early data to such a
>> server? The server will process the ClientHello and determine that
>> there is no cookie, sends back an HRR and then forgets all of its
>> state and waits for the next ClientHello. However what it actually
>> gets next is early_data. It does not know that that early data
>> followed an earlier ClientHello (because it is stateless) so it does
>> not know to skip the records. It just looks like illegal records so,
>> presumably, it will respond with an alert.
>
> Yes, if one receives a ClientHello with both Cookie and EarlyData, one
> can reply with a fatal alert, because that is not supposed to happen.

That isn't quite the scenario I was talking about. Rather your case
(2) above in a server which is operating statelessly, i.e. the client
has attempted to send early_data but has not provided a valid cookie
yet. The early_data when it arrives will look like bad packets, even
though (from the client perspective) it was valid to send them.

It kind of suggests that stateless operation is incompatible with
early_data, i.e. a server should not advertise early_data support in
its tickets if it is going to operate statelessly (because stateless
operation implies an HRR which implies no early_data). There is still
an edge case where a server's configuration has changed (i.e. it used
to operate statefully but now operates statelessly) - in that case a
client might have a valid ticket advertising early_data support which
the server will choke on when it actually receives that early_data.

>
> There is worse edge case with client key share tho: If a ClientHello
> that contains a Cookie does not contain suitable key share, that is an
> irrecoverable error, and the only thing server can do is to send a
> fatal alert (and hope the client somehow retries the connection setup).

Well, yes - if it contains a cookie then there must have been an HRR -
so this is a legitimate fatal error.

Matt