Re: [TLS] Application layer interactions and API guidance

Eric Rescorla <ekr@rtfm.com> Sat, 08 October 2016 16:23 UTC

Return-Path: <ekr@rtfm.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 B9ADB1295CA for <tls@ietfa.amsl.com>; Sat, 8 Oct 2016 09:23:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=rtfm-com.20150623.gappssmtp.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 z9Tqg0Kaxuc0 for <tls@ietfa.amsl.com>; Sat, 8 Oct 2016 09:23:23 -0700 (PDT)
Received: from mail-yb0-x230.google.com (mail-yb0-x230.google.com [IPv6:2607:f8b0:4002:c09::230]) (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 2CC5112957E for <tls@ietf.org>; Sat, 8 Oct 2016 09:23:22 -0700 (PDT)
Received: by mail-yb0-x230.google.com with SMTP id e2so25472183ybi.1 for <tls@ietf.org>; Sat, 08 Oct 2016 09:23:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rtfm-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=u9X3KmNH4OgF1R/c8NxFmbXIa4Vd35+D6w483hzAvDE=; b=plUYYBfRniWlRJEIR3vc9U91ZLVMOykpTII73LcbSUGRA7pVk6+FO8zuOLMmHIVz76 B5o4cQ6liL1wRZPNS3uZ1WBE3/suoA7nvr/ysIrMtoBhelH3KGcv4f/u7jkkOVaXTLwc luPjzYYEeaT4/Btw6sacBC8vXHazV2QP0589NM7LkGcDPpuLoiFsgU6Ws19F3ipSILKx ZsVSXUFi2MTeLDGAIN3WkD2RuRj6yPMQumCiZYGBLX7XUlxZW8N7qVcp07yZpogzEkN4 1XQ4hZZ68vKsiGyLFqvxBWXnZ8VtC9Gtg5wKat8hlmQ5ckrB9nv9M4YmbNG5eesQ5gC9 chHg==
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:from:date :message-id:subject:to:cc; bh=u9X3KmNH4OgF1R/c8NxFmbXIa4Vd35+D6w483hzAvDE=; b=jVkrGFdwfavbM/9+x7DRHzNpxkyC+M/UUXSZcc2lNltizGJkY6C9mLZpawy8G0R7d4 ivE/NF7l+pPg6ZPHrePU4wgpw7PfyWSEJPPVLC4lQOTMIsXSmabJ9AgI3sW8/ZZkQ90+ Djt+zZMInxnFRgv7yocwaJCpfZrKmQAkkgh7519TW8DiGBvJ03lfG2bBCmA27h4XLXGy ByO24MLlZbofI3cSygj5+kqFrkoSx9GjJj+Xbtg3t4wcmD5GUCIBAvYtEb3LZLH56yRR SExu1k39Mu4sHxS4kqnF2QdwOJJTJHIiRjVcEpLOKuLnevyZ8v5FupMOn0pi3lnOUvrp sKbA==
X-Gm-Message-State: AA6/9RnDIQxqkRfVfWI4n+c3FJp+B8u6esQNCDQrzFxECd9Sm+PnoeoAdV5Ez4XS9y7nVG1aP8oo0wa2f8JxOw==
X-Received: by 10.37.171.234 with SMTP id v97mr20244241ybi.161.1475943801392; Sat, 08 Oct 2016 09:23:21 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.129.75.212 with HTTP; Sat, 8 Oct 2016 09:22:40 -0700 (PDT)
In-Reply-To: <CACsn0cnMEVbqtG+FeP84KtmE0=5SkHqGVQ3esqZeqGf9-r6U_w@mail.gmail.com>
References: <CACsn0c=B0dVGaXKawW5DJCUfJfqFFHkk_cZCzjzKs53n4UKLpg@mail.gmail.com> <20160924054730.GB7594@LK-Perkele-V2.elisa-laajakaista.fi> <CACsn0cnpEq_00R37WZOm39dg9dXKSkpNjGt3FWg0uLgTEkwtRw@mail.gmail.com> <20161007220028.GA10288@LK-Perkele-V2.elisa-laajakaista.fi> <CABcZeBNU0HVqkZm6zb63xZzf4+ZQjXb8CacuYH77Fe_=dfFPhw@mail.gmail.com> <CACsn0cnMEVbqtG+FeP84KtmE0=5SkHqGVQ3esqZeqGf9-r6U_w@mail.gmail.com>
From: Eric Rescorla <ekr@rtfm.com>
Date: Sat, 8 Oct 2016 09:22:40 -0700
Message-ID: <CABcZeBMgfqytHTptFt9bAtUktpLVRjgRPfBF52d+UYaariGiDA@mail.gmail.com>
To: Watson Ladd <watsonbladd@gmail.com>
Content-Type: multipart/alternative; boundary=94eb2c0ce1f8fdcaca053e5cf118
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/WZixpG0qI48RavG-eyTh4QnWyBg>
Cc: "tls@ietf.org" <tls@ietf.org>
Subject: Re: [TLS] Application layer interactions and API guidance
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.17
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: Sat, 08 Oct 2016 16:23:26 -0000

On Sat, Oct 8, 2016 at 7:25 AM, Watson Ladd <watsonbladd@gmail.com>; wrote:

> On Fri, Oct 7, 2016 at 3:04 PM, Eric Rescorla <ekr@rtfm.com>; wrote:
> >
> >
> > On Fri, Oct 7, 2016 at 3:00 PM, Ilari Liusvaara <
> ilariliusvaara@welho.com>;
> > wrote:
> >>
> >> On Fri, Oct 07, 2016 at 01:41:14PM -0700, Watson Ladd wrote:
> >> > On Fri, Sep 23, 2016 at 10:47 PM, Ilari Liusvaara
> >> > <ilariliusvaara@welho.com>; wrote:
> >> > >
> >> > > Also, it is very likely that 0-RTT would need its own read API,
> >> > > because
> >> > > it is pretty unlikely that existing API could be safely retrofitted
> >> > > or even purpose-built unified API be designed that isn't just asking
> >> > > for security problems via mixing 0-RTT and 1-RTT data.
> >> >
> >> > Yes. In particular I think the TLS state machine transitions need to
> >> > be ordered with respect to the arrival and sending of data. The
> >> > challenge for a multithreaded program (yes, some programs have
> >> > multiple threads sending and receiving at once) is making this make
> >> > sense, or even a single-threaded program where the TLS stack can
> >> > change state at times not visible to the sending thread. Maybe there
> >> > is some slop here, like 0-RTT can become 1-RTT on send, but this
> >> > raises all sorts of problems for receiving. I think we need to require
> >> > separation in the API.
> >>
> >> 0-RTT can't be allowed to become 1-RTT on send (unless it is auto-
> >> retransmit, which needs to be disableable, as sometimes that just plain
> >> won't work).
> >
> >
> > Can you explain why that is?
>
> Grammar problems.
>
> Let's say you have an context-free parseable protocol, and you want to
> insert the restriction that there is a 0-RTT set of allowed constructions
> and an 1-RTT allowed set that is bigger. The most obvious way to do this is
> to treat the transition as a token that comes between the top-level
> productions of each set of allowable things: so I send you a bunch of 0-RTT
> allowed bits, then switch, then a bunch of 1-RTT allowed bits.
>
> If the sending stack can insert that transition anywhere the grammar
> explodes.
>
In the APIs people have been designing, 0-RTT can become 1-RTT but not the
other way around.
Specifically:

- There is an option to allow 0-RTT writing
- With that option on, SSL_Write() succeeds in both 0-RTT and 1-RTT modes.
- There is a callback that tells you when you have gone from 0-RTT to 1-RTT.

-Ekr


One could try to handle this by some nasty "did we switch before now"
> construction to delay the transition. But you still need to switch how you
> are reading.
>


-Ekr


> >
> > -Ekr
> >
> >
> >
> >> This impiles that the application always needs to explicitly signal
> >> the end of 0-RTT data, even just to abort sending it.
> >>
> >> > > (This is the reason one needs to be especially careful when
> combining
> >> > > dynamic client certificates with HTTP/2... Basically, it can not be
> >> > > done safely without coordination on application layer).
> >> > >
> >> > > One likely wants application protocol to be able to specify part of
> >> > > or the entiere request context and to extract that part in the other
> >> > > end when requesting a certificate selection. This is to allow
> putting
> >> > > part of coordination data into the request itself. However, this is
> >> > > not
> >> > > sufficient for e.g. HTTP/2 signaling, so more needs to be exchanged
> at
> >> > > application layer.
> >> > >
> >> > > And then upon completion of the authentication (either successful or
> >> > > explicitly rejected), signal the application with the new
> certificate
> >> > > chain and the context the request had.
> >> >
> >> > This is going to require major changes to APIs and to the HTTP/2
> >> > layer. It also interacts with token binding, whee! My question then
> >> > becomes one of what we actually need: can we assume that leakage
> >> > between authentication contexts over a single session is safe because
> >> > all contexts represent the same principal, by restricting the usages,
> >> > or is this overly restrictive?
> >>
> >> Yes, it is going to reuqire such changes.
> >>
> >> And you absolutely can not assume that all contexts present the same
> >> principal.
> >>
> >> And as I said, in multiplexed protocol like HTTP/2, you need
> application-
> >> level coordination on top. TLS just can't do that.
> >>
> >> > When we have multiple requests and replies in flight and the
> >> > authentication state changes, things get nasty. If we think of TLS as
> >> > sending a stream of events including authentication changes to the
> >> > application, this fits the semantics of the TLS draft as I understand
> >> > them to be, but does not necessarily fit what application protocols
> >> > want. There might be a semantic mismatch here requiring reworking of
> >> > one or another part.
> >>
> >> Also, some applications presumably want the events done synchronously,
> >> so they don't move with data reads.
> >>
> >>
> >> Basically, post-handshake auth is heckuva nasty problem.
> >>
> >>
> >> -Ilari
> >>
> >> _______________________________________________
> >> TLS mailing list
> >> TLS@ietf.org
> >> https://www.ietf.org/mailman/listinfo/tls
> >
> >
>
> --
> "Man is born free, but everywhere he is in chains".
> --Rousseau.
>