Re: [Unbearable] 0-RTT Token Binding: When to switch exporters?

Nick Harper <nharper@google.com> Mon, 20 March 2017 19:18 UTC

Return-Path: <nharper@google.com>
X-Original-To: unbearable@ietfa.amsl.com
Delivered-To: unbearable@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D7C62129506 for <unbearable@ietfa.amsl.com>; Mon, 20 Mar 2017 12:18:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.702
X-Spam-Level:
X-Spam-Status: No, score=-2.702 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=google.com
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 o7jJ7SdSmC1Y for <unbearable@ietfa.amsl.com>; Mon, 20 Mar 2017 12:18:26 -0700 (PDT)
Received: from mail-yw0-x233.google.com (mail-yw0-x233.google.com [IPv6:2607:f8b0:4002:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AB79C129468 for <unbearable@ietf.org>; Mon, 20 Mar 2017 12:18:26 -0700 (PDT)
Received: by mail-yw0-x233.google.com with SMTP id v198so96570888ywc.2 for <unbearable@ietf.org>; Mon, 20 Mar 2017 12:18:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=P+Xjj/r1f0ejyKXksEdx+9oQ9LwjrbCK/FIH3BsaRYo=; b=u3fqKIxYNgo6VQW2lvWixQWY0sNsMtWoLfWclf/gyGS1LXplwa9R6qBVGA10AqlhQ7 cT8CQL8NMzWHg7A/Pj54eTtLeCAT3ahsNnAY/eyrqCsfEw4Ki6YBCDv2KOx4UzLGKmQ4 s3iXFU47FtZTDB+OB6CgFI2VzeddQKdkGOhMp3G7UcKbv7KzMEqNZymSBq+lpjUQh7kf YhTxr08rZdYTH2OXcRQ/Yvc+6XTX8cgo7G9HoTrcWnFBvD1xJf6M0wIvKoV9qKwnzywh AmFSQNKhuATJTMVny1KJKLCxw64vC3FeHKcwyBGP8lJAZdB8vIfGHAMrv7lnZBmtGLzZ 0VRQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=P+Xjj/r1f0ejyKXksEdx+9oQ9LwjrbCK/FIH3BsaRYo=; b=pktRWLCEbt12xoHVr8WujcAr3XMUH9MqG0efWrJvnvfgI3EYMdZETxk9QZsWssXIB1 pKjZpZJY/yJ1lnM0RyYLMcxVA/t4zfScvm14Hqoa6PLbyiiv7oN/UehbKHiXZ3E1DTaR JLOMGnLaHHmArIrf9gu9X8nh5QokcY7Q4KFtE9kUXA+I5fa9FTMVsotU+sx8mvQ8m2id KXsDGfXnOpvjf4E5eN1XeM/Ync6g3BdugW0YYf3wjSzhMygeUJrO+BTuzbxNLz3eXVF+ gouRp5k5oyZT73wyFdROYof5lJyeJvaqxmNaQ+gzAXGnyMNuVfj16D2Sd6Bzg2R3sXBl LXBg==
X-Gm-Message-State: AFeK/H1h1Eyp3p4HIOex550Z+5krqcwrCS99cADvmm7sNByUohfpTgCJ6lFHlTOh+0Y3c4kMqk+bmlS3SOOUDW2V
X-Received: by 10.37.174.90 with SMTP id g26mr8997338ybe.102.1490037505602; Mon, 20 Mar 2017 12:18:25 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.129.65.5 with HTTP; Mon, 20 Mar 2017 12:18:05 -0700 (PDT)
In-Reply-To: <CABcZeBN2RhBsyj8_1F6bBnw9j10qdABwdZVdgwVcUr4Tf6sLtA@mail.gmail.com>
References: <CACdeXiK2Hs=Kz_5OFryWR+9_t6nDL_p7NKjw=CwRsua_E5S9Mw@mail.gmail.com> <DM2PR0301MB084793F58146F8574BF36EE18C780@DM2PR0301MB0847.namprd03.prod.outlook.com> <CACdeXiJGcsTxrSWmd5BZrfoWTHhFF3+RisQFD628iYNMzZakhQ@mail.gmail.com> <CACdeXiJFe7-jM9qEnNB+Wp3joGxF_X1z+-dPywb9SRZuSNmAzQ@mail.gmail.com> <DM2PR21MB0091E3F087E1AECA3A63A3788C560@DM2PR21MB0091.namprd21.prod.outlook.com> <CACdeXi+YjLaXtoX47LtVK4Ay2y-mCOOraV46gbbbuQPL40ngXg@mail.gmail.com> <DM2PR21MB00910C83983BEE885B0E04288C560@DM2PR21MB0091.namprd21.prod.outlook.com> <CACdeXiLON5OAjfFCNsenCeaGV3a_LDoi17VAk=fSzF0YA5=f7Q@mail.gmail.com> <CACdeXiLNCrPSz0_hZSpQ6tsoHB7ryJ2dCnHjUYwu5vu5fO4XBg@mail.gmail.com> <SN1PR21MB0096D7426A4E230E284F0D058C560@SN1PR21MB0096.namprd21.prod.outlook.com> <CACdeXiKuzNh0fP9b-jEF82m-6mX+i04To96GMa_tFNcuznGn+A@mail.gmail.com> <DM2PR21MB00914BA07BA984E931B88FEB8C290@DM2PR21MB0091.namprd21.prod.outlook.com> <CACdeXiKQjaoAArLBcjRj+kUJUqH+f1bA5yeCCiQ6GMXzWJURBw@mail.gmail.com> <CABkgnnV0+vumfkZAMRZ_8q5pTkwf_CqhZ+deeVWdbF9SFaHoJw@mail.gmail.com> <DM2PR21MB0091DE5B213D2363FAF353CF8C280@DM2PR21MB0091.namprd21.prod.outlook.com> <CACdeXiKweRaZEKi4kqmPfUc2JLyZLGbp8tFRpkTfmJisPCMWRg@mail.gmail.com> <CACdeXiL6riBRb1-UDhVK-R5CvopzisJnYTRjWsvpimWA2G3DhQ@mail.gmail.com> <CABcZeBN2RhBsyj8_1F6bBnw9j10qdABwdZVdgwVcUr4Tf6sLtA@mail.gmail.com>
From: Nick Harper <nharper@google.com>
Date: Mon, 20 Mar 2017 12:18:05 -0700
Message-ID: <CACdeXiLZQSMxSqTPSHVqUwZomUpaMadUNYEEzF2to9Rx6nLMWQ@mail.gmail.com>
To: Eric Rescorla <ekr@rtfm.com>
Cc: Andrei Popov <Andrei.Popov@microsoft.com>, IETF Tokbind WG <unbearable@ietf.org>, Martin Thomson <martin.thomson@gmail.com>
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/unbearable/44CLkg2PlVzG9-d7_4BGHCs8utE>
Subject: Re: [Unbearable] 0-RTT Token Binding: When to switch exporters?
X-BeenThere: unbearable@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: "\"This list is for discussion of proposals for doing better than bearer tokens \(e.g. HTTP cookies, OAuth tokens etc.\) for web applications. The specific goal is chartering a WG focused on preventing security token export and replay attacks.\"" <unbearable.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/unbearable>, <mailto:unbearable-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/unbearable/>
List-Post: <mailto:unbearable@ietf.org>
List-Help: <mailto:unbearable-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/unbearable>, <mailto:unbearable-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 20 Mar 2017 19:18:29 -0000

On Mon, Mar 20, 2017 at 9:56 AM, Eric Rescorla <ekr@rtfm.com> wrote:
> I'm not quite sure I understand the reasoning here, so let me try to walk
> through it.
>
> The HTTP stack tells the TLS stack to initiate a connection and starts
> streaming
> requests down to the TLS stack. At this point, it can only use the 0-RTT
> exporter,
> so it has to do that. At some point in this process, the client receives the
> 1-RTT
> Finished and can then switch to the 1-RTT exporter, but the serves has no
> way
> of knowing at which point that is.

As the client's HTTP stack is streaming requests down to the TLS stack
(expecting that they be sent as 0-RTT data), a few things could
happen:
- The TLS stack could have received the server's Finished, so the TLS
stack decides to finish the handshake and send all future data
streamed from the HTTP stack post-handshake. If the HTTP stack starts
preparing the request just before the TLS stack receives the server's
Finished, the HTTP stack will generate a Token-Binding header using
the 0-RTT exporter, and then stream it to the TLS stack which sends it
post-handshake. We could try to assume that the TLS stack will fail
any requests to stream data once the handshake is complete and require
the HTTP stack to call a different function to send non-0-RTT data.
However, this runs into another problem.
- The TLS stack can choose how to fragment messages. When the HTTP
stack streams a request (which contains a Token-Binding header) to be
sent over 0-RTT, the TLS stack could fragment the HTTP request in a
way that splits the Token-Binding header between TLS records, and puts
half of it in 0-RTT data and the other half in post-handshake
application data. (Or, if the "stream early data" function call
returns an error if the HTTP stack tries to send 0-RTT data after the
handshake is complete, the HTTP stack is now stuck with half of a
request sent and a field it needs to change but has already sent half
of.)
- This split of a Token-Binding header across 0-RTT and non-0-RTT data
could also be caused by the TLS stack hitting the max early data size
required by the server.
- In QUIC, even if the HTTP/QUIC/TLS stack provides some way to
guarantee that an HTTP request will end up entirely in 0-RTT data, a
packet containing part of the Token-Binding header could get lost
until after the TLS handshake is complete, at which point QUIC will
retransmit it under the new keys. Given this possibility of
retransmission, how is the server to know which exporter to enforce
use of?
>
> In the current rule, the client MUST switch when it sees app data from the
> server,

I assume you're referring to paragraph two of section 2.1.1 of
draft-ietf-tokbind-tls13-0rtt-01? Now that I re-read that, it does not
convey what I meant it to mean. I think what I meant to say is that
after a client receives an application-layer response from the server,
it must use the exporter_secret for all future token bindings in
application messages that are in response to the received
application-layer message from the server.

Essentially, the problem I'm trying to work around is that there is a
non-zero amount of time between the HTTP stack building a request
(specifically, the part of that where it builds the Token-Binding
header) and the HTTP stack sending that request to the TLS stack. (If
the HTTP stack is streaming the request to the TLS stack as the
request is being generated, this end time is when the last byte of the
HTTP request hits the TLS stack.) During this time, the TLS handshake
could have completed. If a client starts building an HTTP request
after it has seen application data from the server, then we can
guarantee that the client will be able to use the 1-RTT exporter.
However, the client could start building an HTTP request before it has
seen application data (and before the TLS stack has seen a Finished
message from the server), but send that after the client's TLS stack
sends its Finished message. This is the case that I want to allow.

> so if the server receives a HTTP request from the client that is
> semantically
> dependent on some HTTP response from the server, then it knows that the
> client should have switched at this point. However, ISTM that SFIN must
> have appeared prior to the any such application layer message, so requiring
> the client to switch on SFIN would make the switch happen slightly earlier
> and give the server the same guarantees. What's the argument for not
> requiring
> that instead, given that it's tied to the state of the TLS stack rather than
> the
> HTTP stack.
>
> -Ekr