Re: [TLS] Clarification on interleaving app data and handshake records

"Short, Todd" <tshort@akamai.com> Fri, 16 October 2015 19:11 UTC

Return-Path: <tshort@akamai.com>
X-Original-To: tls@ietfa.amsl.com
Delivered-To: tls@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 85D3B1ACE8B for <tls@ietfa.amsl.com>; Fri, 16 Oct 2015 12:11:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.71
X-Spam-Level:
X-Spam-Status: No, score=-2.71 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=ham
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 5BiFM9jke9FO for <tls@ietfa.amsl.com>; Fri, 16 Oct 2015 12:11:06 -0700 (PDT)
Received: from prod-mail-xrelay06.akamai.com (prod-mail-xrelay06.akamai.com [96.6.114.98]) by ietfa.amsl.com (Postfix) with ESMTP id 9486B1ACE9E for <tls@ietf.org>; Fri, 16 Oct 2015 12:11:06 -0700 (PDT)
Received: from prod-mail-xrelay06.akamai.com (localhost.localdomain [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id 13E4A496C2A; Fri, 16 Oct 2015 19:11:06 +0000 (GMT)
Received: from prod-mail-relay08.akamai.com (prod-mail-relay08.akamai.com [172.27.22.71]) by prod-mail-xrelay06.akamai.com (Postfix) with ESMTP id DE7E9496C15; Fri, 16 Oct 2015 19:11:05 +0000 (GMT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; s=a1; t=1445022665; bh=vsTibMsg7hRAVCMYI2/vjW9GBM5ZhFs2B2McAluxzsQ=; l=11740; h=From:To:CC:Date:References:In-Reply-To:From; b=XTf/DCFZ7lVvF3AeP8RfFsOcNpFkocNDcDch7/roFJNBBkgis6f0qL3eOsXSJGw4s 77bTr6sibhDJgnQqNrUmIKoUfIfLET4TtnHcvXq9k7wudu5fMK3mjMomn5GN8TBK1t zCRdA1ObTCAxVuXv4LtoyFE5UXjQuKNKotoMAh8w=
Received: from email.msg.corp.akamai.com (ustx2ex-cas2.msg.corp.akamai.com [172.27.25.31]) by prod-mail-relay08.akamai.com (Postfix) with ESMTP id D93049808B; Fri, 16 Oct 2015 19:11:05 +0000 (GMT)
Received: from USTX2EX-DAG1MB5.msg.corp.akamai.com (172.27.27.105) by ustx2ex-dag1mb4.msg.corp.akamai.com (172.27.27.104) with Microsoft SMTP Server (TLS) id 15.0.1076.9; Fri, 16 Oct 2015 14:11:05 -0500
Received: from USTX2EX-DAG1MB5.msg.corp.akamai.com ([172.27.27.105]) by ustx2ex-dag1mb5.msg.corp.akamai.com ([172.27.27.105]) with mapi id 15.00.1076.000; Fri, 16 Oct 2015 14:11:05 -0500
From: "Short, Todd" <tshort@akamai.com>
To: Matt Caswell <frodo@baggins.org>
Thread-Topic: [TLS] Clarification on interleaving app data and handshake records
Thread-Index: AQHRCEZnMGJCacmCHEiMi6ZvuMhhCg==
Date: Fri, 16 Oct 2015 19:11:04 +0000
Message-ID: <578EBE44-433F-4008-A856-4A53F39D0554@akamai.com>
References: <560BB34F.4070201@openssl.org> <560BB416.10602@baggins.org> <561CCB0D.6020506@baggins.org>
In-Reply-To: <561CCB0D.6020506@baggins.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-transport-fromentityheader: Hosted
x-originating-ip: [172.19.45.92]
Content-Type: multipart/alternative; boundary="_000_578EBE44433F4008A8564A53F39D0554akamaicom_"
MIME-Version: 1.0
Archived-At: <http://mailarchive.ietf.org/arch/msg/tls/l2zUXOGXRsUC6nRlct4IoKzWM7Y>
Cc: "tls@ietf.org" <tls@ietf.org>
Subject: Re: [TLS] Clarification on interleaving app data and handshake records
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.15
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, 16 Oct 2015 19:11:09 -0000

Hi Matt:

I agree with your interpretation, in that there should be no records of any type between the CSS and the Handshake/Finished message, even during re-handshake. The full handshake (and subsequent key material) cannot be validated until the Handshake/Finished messages has been received and processed.

Any AppData received between a CSS and Handshake/Finished is potentially malicious data trying to sneak in before the Handshake is verified; forwarding this data to an upper layer would be potentially harmful. A MITM would hope that the data would be processed by an application before the TLS layer receives and verifies the Handshake/Finished message.

--
-Todd Short
// tshort@akamai.com<mailto:tshort@akamai.com>
// "One if by land, two if by sea, three if by the Internet."

On Oct 13, 2015, at 5:12 AM, Matt Caswell <frodo@baggins.org<mailto:frodo@baggins.org>> wrote:

Hello,

Does anyone have any views on the below?

Thanks

Matt

On 30/09/15 11:06, Matt Caswell wrote:
Hi all

I have a question on how to interpret RFC 5246 with regards to the
interleaving of app data and handshake records.

RFC 5246 (and RFC 4346 before it) contains these words:

  Note: Data of different TLS Record layer content types MAY be
  interleaved.  Application data is generally of lower precedence for
  transmission than other content types.  However, records MUST be
  delivered to the network in the same order as they are protected by
  the record layer.  Recipients MUST receive and process interleaved
  application layer traffic during handshakes subsequent to the first
  one on a connection.

This wording seems to place no limits whatsoever on when it is valid to
receive app data in the handshake. By the wording in the RFC it would be
valid for app data to be received *after* the ChangeCipherSpec has been
received but *before* the Finished has been processed.

There is also this wording:

  Note: If a rehandshake occurs while data is flowing on a connection,
  the communicating parties may continue to send data using the old
  CipherSpec.  However, once the ChangeCipherSpec has been sent, the
  new CipherSpec MUST be used.  The first side to send the
  ChangeCipherSpec does not know that the other side has finished
  computing the new keying material (e.g., if it has to perform a
  time-consuming public key operation).  Thus, a small window of time,
  during which the recipient must buffer the data, MAY exist.  In
  practice, with modern machines this interval is likely to be fairly
  short.

I think this means that as soon as the first party sends a CCS, they
must not send any app data until they have received a CCS back - they
must buffer it until the CCS is seen - but on reading it again I'm not
sure! If that were the case then the second party should never expect to
see app data between CCS and Finished. It doesn't tell you anything
about what the first party can expect though, i.e. is the second party
allowed to send app data between the CCS and Finished?

Finally there is also this:

  A Finished message is always sent immediately after a change
  cipher spec message to verify that the key exchange and
  authentication processes were successful.

I suppose this trumps everything else, although as this section is
specifically talking about handshakes you could interpret "immediately"
as applying to the handshake sequence only without saying anything about
interleaved app data records.

I believe the intention is that app data should not be sent between the
CCS and Finished but the RFC wording is not exactly crystal clear. This
is the interpretation I have taken whilst fixing this OpenSSL bug:

https://rt.openssl.org/Ticket/Display.html?id=3712&user=guest&pass=guest

Can some confirm my interpretation is correct?

Thanks

Matt



_______________________________________________
TLS mailing list
TLS@ietf.org<mailto:TLS@ietf.org>
https://www.ietf.org/mailman/listinfo/tls