Re: [TLS] close_notify and TLS 1.3

Eric Rescorla <ekr@rtfm.com> Mon, 13 November 2017 20:35 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 C0BAE129B1B for <tls@ietfa.amsl.com>; Mon, 13 Nov 2017 12:35:19 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.598
X-Spam-Level:
X-Spam-Status: No, score=-2.598 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_LOW=-0.7, URIBL_BLOCKED=0.001] 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 BO0vH8qOcPjC for <tls@ietfa.amsl.com>; Mon, 13 Nov 2017 12:35:17 -0800 (PST)
Received: from mail-yw0-x22e.google.com (mail-yw0-x22e.google.com [IPv6:2607:f8b0:4002:c05::22e]) (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 6D2951201F8 for <tls@ietf.org>; Mon, 13 Nov 2017 12:35:17 -0800 (PST)
Received: by mail-yw0-x22e.google.com with SMTP id k3so14537828ywk.8 for <tls@ietf.org>; Mon, 13 Nov 2017 12:35:17 -0800 (PST)
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=PnPyqpB3rAtBaWchMZ8s+jvh7OhwmUxKSzrBysGEqZk=; b=oTo7VEz83wFEjqOaIfSR9CfTZrfSX97PyTjCXKyYmNFc0CujKfQCwLkbvy9WN9N8QT owNsoEHfcMJHN2CunvjUUQlLQFxgwgytiVMXQxCn83C/KFRxpwFBBzGDxmfeHlu7Uf5j m8mbS0dGnpZMREQenj82OA3xJEdt7619qIjXjv5gIs598P2VWuv6lLxTvNXXwSixGINT VBSAcHaIObYnvFAoXTGqCM3znmaXHAlERnPj5/SRGb0h2/TXxWhC6SQwakcJYbfB4GiH 1RCVqaWpuUfI8aWpmEcXUIsvznrasPh/TzrNw6Y5t9+ZglbbiH1KdVjJkrulLXScMlhE eU0g==
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=PnPyqpB3rAtBaWchMZ8s+jvh7OhwmUxKSzrBysGEqZk=; b=fra+TtXFqVm30lE7nLqvYJRZpUCJ62+G0ZyL9FtIWguw3IlO1WOQoT6d8wM0UDiE+3 vZ8jVa0DPah3a04BkCqlg062/4BT4GDEEuqdyUrmJs0T08JGDOPCzxbraz8jPON1gOCM fa8Yh+XaPdL7Cy16Na3mOeLFeazw4T50cHyttLAruFPgY8TA5nSSWOINs1b0FwqzHUWV 92u6oyuMTIMQqRWaOEPjLOiezMRULNkk0shR05qck/NoGhtmnuQFUAYWRTFXU1n5EXC9 45m7+VoTRrZmIZ5h80yrtQaiCUUAnAdZvPr2G2gD1d4BAA78CYwo+qRUc5NwkcTS7ken +/+w==
X-Gm-Message-State: AJaThX4VCTrbayRfddDTNvnOUmffAE9gP5dKOnTZXxiIee5N+dhCDdPq 6zjyNa44IGYp+piV/Dz90tAUTzVvcHL5rfhavZrydSwB
X-Google-Smtp-Source: AGs4zMavrenAw9K0nKFDUF5xPb/uyEviqumkqKUB+5kyJUautblPmEF2+RjalQg7/NOSfJ+WsuKOVt7tPIOFpFSM0VE=
X-Received: by 10.129.172.25 with SMTP id k25mr5160295ywh.155.1510605316653; Mon, 13 Nov 2017 12:35:16 -0800 (PST)
MIME-Version: 1.0
Received: by 10.129.61.12 with HTTP; Mon, 13 Nov 2017 12:34:36 -0800 (PST)
In-Reply-To: <1553712.MIZnC4Bnhv@pintsize.usersys.redhat.com>
References: <A6C599ED-3F3D-462F-9B39-1FEF6A0B549B@apple.com> <3025542.QI1GADQRnG@pintsize.usersys.redhat.com> <CABcZeBPczGOafQk-hokrxALWUwWAaegDoK_Ed+wcvxx9Jor5vw@mail.gmail.com> <1553712.MIZnC4Bnhv@pintsize.usersys.redhat.com>
From: Eric Rescorla <ekr@rtfm.com>
Date: Mon, 13 Nov 2017 20:34:36 +0000
Message-ID: <CABcZeBOWrE8b2a4vMo0U_rPGAO3E0VXZ_w8LkDcZ74Dz8kHZTQ@mail.gmail.com>
To: Hubert Kario <hkario@redhat.com>
Cc: "tls@ietf.org" <tls@ietf.org>
Content-Type: multipart/alternative; boundary="94eb2c1badfc4b8b67055de335a3"
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/LJLaAKe8cqiSQBegl4fvPKUEWME>
Subject: Re: [TLS] close_notify and TLS 1.3
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: Mon, 13 Nov 2017 20:35:20 -0000

On Mon, Nov 13, 2017 at 2:38 PM, Hubert Kario <hkario@redhat.com> wrote:

> On Monday, 13 November 2017 13:25:07 CET Eric Rescorla wrote:
> > On Mon, Nov 13, 2017 at 11:37 AM, Hubert Kario <hkario@redhat.com>
> wrote:
> > > On Saturday, 11 November 2017 10:21:11 CET David Schinazi wrote:
> > > > Hello all,
> > > >
> > > > Currently TLS 1.3 specifies close_notify in the same way that TLS 1.2
> > >
> > > did.
> > >
> > > > I believe that has issues and this might be the right time to fix
> them.
> > > > The purpose of close_notify is to protect against data truncation
> > >
> > > attacks,
> > >
> > > > each side is required to send close_notify before closing the write
> side
> > >
> > > of
> > >
> > > > the transport connection so the other side knows that the data was
> not
> > > > truncated. As such, close_notify only needs half-close semantics to
> > >
> > > prevent
> > >
> > > > truncation.
> > > >
> > > > However, the specification contains the following text:
> > > > << Each party MUST send a “close_notify” alert before closing the
> write
> > >
> > > side
> > >
> > > > of the connection, unless some other fatal alert has been
> transmitted.
> > >
> > > The
> > >
> > > > other party MUST respond with a “close_notify” alert of its own and
> > > > close
> > > > down the connection immediately, discarding any pending writes. >>
> > > >
> > > > This means that an application-layer client can't send a query then
> > > > close
> > > > their write transport when they know that they're done, because the
> > >
> > > server
> > >
> > > > would terminate the TLS session before sending the reply. On top of
> > > > this,
> > > > when the server receives the close_notify, it may have already sent
> part
> > >
> > > of
> > >
> > > > the reply (or wrote it to the socket send buffer) so the responding
> > > > close_notify would in effect be inflicting a truncation attack on the
> > > > client.
> > > >
> > > > This doesn't make much difference for HTTP because clients already
> > > > don't close their write transport after sending a reply, however
> having
> > >
> > > the
> > >
> > > > option do do this could allow innovation in new protocols that can
> > > > define
> > > > the semantics of when they use close_notify. An example is DNS PUSH:
> > > > https://tools.ietf.org/html/draft-ietf-dnssd-push
> > > > <https://tools.ietf.org/html/draft-ietf-dnssd-push>
> > > >
> > > > A proposal to solve this problem would be to give close_notify
> > > > half-close
> > > > semantics: we keep the requirements that a close_notify be sent
> before
> > > > closing the transport, and that any data received after a
> close_notify
> > > > is
> > > > ignored, but we simply remove the requirement to immediately reply
> > > > with a close_notify. This has the advantage that current
> implementations
> > > > are already compliant but future ones can leverage this improvement.
> > > >
> > > > What do you think? Is this worth discussing on Thursday?
> > >
> > > what about alerts?
> > >
> > >
> > > if you half-closed the connection for write and then received
> key-update,
> >
> > I assume you mean with update_requested set. in any case, you do nothing:
> >
> > If the request_update field is set to "update_requested" then the
> receiver
> > MUST
> > send a KeyUpdate of its own with request_update set to
> > "update_not_requested" prior
> > to sending its next application data record.
>
> how "MUST send a KeyUpdate of its own" is "you do nothing"?
>

You need to read to the end of the sentence
"prior to sending its next application data record". As no such record is
sent, you don't need to do anything.


> > or
> > > message with an invalid tag, how are you supposed to react to it?
> >
> > I think it would be fine to either silently tear down the connection or
> to
> > send an alert.
>
> sending alerts after close_notify goes against the semantics of TCP half-
> close. If the intention is to support TCP half-close-like mechanism in
> TLS, we
> need to document when and where that abstraction is broken. In particular -
> that sending close_notify shouldn't be followed by closing the write side
> of
> the connection (be it TCP or Unix socket). Only that application_data
> packets
> are disallowed after close_notify.
>

As David says, this problem already exists.

-Ekr

--
> Regards,
> Hubert Kario
> Senior Quality Engineer, QE BaseOS Security team
> Web: www.cz.redhat.com
> Red Hat Czech s.r.o., Purkyňova 115, 612 00  Brno, Czech Republic
>