Re: [TLS] Combining Secrets in Hybrid Key Exchange in TLS 1.3

Dan Brown <danibrown@blackberry.com> Thu, 02 September 2021 20:29 UTC

Return-Path: <danibrown@blackberry.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 7156F3A0B29 for <tls@ietfa.amsl.com>; Thu, 2 Sep 2021 13:29:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.548
X-Spam-Level:
X-Spam-Status: No, score=-2.548 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.452, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=blackberry.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 Uj9pGV-5icUF for <tls@ietfa.amsl.com>; Thu, 2 Sep 2021 13:29:03 -0700 (PDT)
Received: from smtp-pc11.blackberry.com (smtp-pc11.blackberry.com [74.82.81.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 708043A0B21 for <tls@ietf.org>; Thu, 2 Sep 2021 13:29:03 -0700 (PDT)
Received: from pps.filterd (mhs401cnc.rim.net [127.0.0.1]) by mhs401cnc.rim.net (8.16.0.43/8.16.0.43) with SMTP id 182KIBaN133263; Thu, 2 Sep 2021 16:28:58 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackberry.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : mime-version; s=corp19; bh=YrbC3TXV2y7+RTVTqo5COcEaCsfxlfVLgG9oGYwcPMg=; b=rDiVlygwTqRNl8AaDNF8hTGw1xoHNnxsXgBNOWPZLjOKDtaMnRznNbHNxW7it/CRJAR+ bHk9Jm1IyvXzFPqAYIQpkux0xLMiXAwZNSUju+TEgKp/3n/07ZfX4NGOoCznHUaBWTdV vMXdGa9n9Glq/BqR9jonvSvM2ppFtdEstVyRV+1rXQg8/Y1vdx/9R6mpo2mXNX0Wpm2y q/CztXLPNIeKvBBh5k6GjcM4l628nuIiyUYsii6rJ02eZS4TYPtT/rtTjJtmbzhv3rEU +FIJmYSv7W6IyFqd1Qje0qhoCh6X6pYI4AYNXn/loHKKg3mEINY0BEBxtYBjh9WXYXBX mg==
Received: from xch212cnc.rim.net (xch212cnc.rim.net [10.3.27.117]) by mhs401cnc.rim.net with ESMTP id 3atdxtjvq5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 02 Sep 2021 16:28:58 -0400
Received: from XCH210YKF.rim.net (10.12.114.210) by XCH212CNC.rim.net (10.3.27.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Thu, 2 Sep 2021 16:28:57 -0400
Received: from XCH210YKF.rim.net ([fe80::ac8d:3541:704c:478a]) by XCH210YKF.rim.net ([fe80::ac8d:3541:704c:478a%5]) with mapi id 15.01.2176.014; Thu, 2 Sep 2021 16:28:57 -0400
From: Dan Brown <danibrown@blackberry.com>
To: Nimrod Aviram <nimrod.aviram@gmail.com>, "<tls@ietf.org>" <tls@ietf.org>
CC: Eylon Yogev <eylony@gmail.com>, Ilan Komargodski <ilankom10@gmail.com>, Benjamin Dowling <b.dowling@sheffield.ac.uk>, Eyal Ronen <er@eyalro.net>
Thread-Topic: [TLS] Combining Secrets in Hybrid Key Exchange in TLS 1.3
Thread-Index: AQHXn2ubZ31FVVTO8Ee0+dtVkmw3jauRMbnA
Date: Thu, 02 Sep 2021 20:28:57 +0000
Message-ID: <c01769da180b4e0aa5c6a9b2ad24fb51@blackberry.com>
References: <CABiKAoTOVqDucNuyJeH6VzJQdygpT7yAiA-V=+jLBCpfw+Ru4w@mail.gmail.com>
In-Reply-To: <CABiKAoTOVqDucNuyJeH6VzJQdygpT7yAiA-V=+jLBCpfw+Ru4w@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
x-originating-ip: [100.64.197.166]
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="2.16.840.1.101.3.4.2.1"; boundary="----=_NextPart_000_0155_01D7A017.A193F800"
MIME-Version: 1.0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-09-02_04:2021-09-02, 2021-09-02 signatures=0
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/IbqfTiz7dhzYzDp1h-ZgfOMW3LI>
Subject: Re: [TLS] Combining Secrets in Hybrid Key Exchange in TLS 1.3
X-BeenThere: tls@ietf.org
X-Mailman-Version: 2.1.29
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: Thu, 02 Sep 2021 20:29:10 -0000

Dear Nimrod and team:

How does your concern compare to Campagna and Petcher’s report

https://eprint.iacr.org/2020/1364

which has security proofs for concatenation-based KDF?

(Maybe a detailed discussion is better suited to CFRG?)

Best regards,

​​​​​Dan

 

From: TLS <tls-bounces@ietf.org> On Behalf Of Nimrod Aviram
Sent: Wednesday, September 1, 2021 3:57 PM
To: <tls@ietf.org> <tls@ietf.org>
Cc: Eylon Yogev <eylony@gmail.com>; Ilan Komargodski <ilankom10@gmail.com>; Benjamin Dowling <b.dowling@sheffield.ac.uk>; Eyal Ronen <er@eyalro.net>
Subject: [TLS] Combining Secrets in Hybrid Key Exchange in TLS 1.3

 

(This note is also available on Github <https://urldefense.com/v3/__https:/github.com/nimia/kdf_public*readme__;Iw!!COg3wY07Hnb7!5OmIbV58bG3VGtwYOI1gL73xJz_hfm6BqfyKoWRKT25K7-yOj4ziPAfkU9BCeC0$>  for ease of reading.)

 

This note identifies a possible security problem in the "Hybrid key exchange in
TLS 1.3" document, stemming from how cryptographic secrets are combined. In
short: constructions that concatenate secrets are vulnerable when the underlying
hash function is not collision-resistant. We are unaware of a full attack
that leverages the underlying problem. However, we view this as an opportunity
to defend-in-depth against such issues, while the document is not yet finalized.
We propose a new construction that seems robust to this potential issue, and we
are in the process of writing a technical report that includes a full security
proof.

# Concatenating Secrets May Be Dangerous

The APOP attack (see appendix for a brief description) demonstrates that
concatenating secrets to potentially attacker-controlled input might be
dangerous. Currently, the "Hybrid key exchange in TLS 1.3" document uses secret
concatenation as the preferred way to combine secrets. (This was an
understandable design choice given how little this issue has been studied.)

We recommend a defense-in-depth approach against this potential issue. We should
not concede to an attacker even the ability to cause a collision in an internal
state of the key schedule. Moreover, this part of TLS is likely particularly
amenable to ossification: Whatever we standardize will likely persist for 5-10
years. (We do note that TLS mixes in the client and server nonces, so additional
offensive techniques would be required to exploit this for a full attack.)

We note that concatenation is also used in the "TLS 1.3 Extended Key Schedule"
document.

# Our proposed construction

We have identified an alternative construction that we believe could provide
defense-in-depth against this issue. We are in the process of writing a
technical report that includes a full security proof.
The required assumptions on the hash function appear to be much milder than
collision resistance; instead, we likely only need multi-preimage-resistance:
Essentially, requiring only that computing preimages for multiple images is
hard.

The construction is: 
combined_key = H(HMAC(key=H1(k1), data=2||F(k2)) xor HMAC(key=H2(k2), data=1||F(k1))) 
where || denotes concatenation, H denotes the underlying hash function, and: 
H1(k) = H('derive1' || k) 
H2(k) = H('derive2' || k) 
F is defined as follows:
Let m denote the input to F. We split m into blocks, according to the block size
of H: 
m = m1||m2||...||mn 
Let j~=3 denote an “expanding factor” (the value chosen for j in practice
depends on how strong an assumption we want to rely on; we expect 3 to be enough).
Then 
F(m) = H(0||m1)||H(1||m1)||...||H(j-1||m1)||H(0||m2)||H(1||m2)||...||H(j-1||m2)||H(0||mn)||H(1||mn)||...||H(j-1||mn)

This construction is cheap to calculate and would be used only in the key
schedule, which is not a bottleneck for TLS performance.

# Adding another layer to the TLS key schedule may also be problematic

Another strategy for mixing secrets is to add the second secret to another layer
of the TLS key schedule. This strategy is already used to mix a PSK and an ECDHE
secret in TLS 1.3, as well as in AuthKEM, and it was also considered for the
Hybrid key exchange document. This strategy is vulnerable as well to collisions
in the underlying hash function, and we propose using one secure construction
for mixing secrets.

Consider a standard PSK+ECDHE TLS 1.3 handshake. Then 
handshake_secret = HKDF_Extract(IKM=ECDHE_secret, salt=Derive_Secret(early_secret)) 
early_secret = HKDF_Extract(IKM=PSK, salt=000) 
HKDF_Extract(IKM, salt) = HMAC(k=salt, data=IKM)

Therefore, early_secret = HMAC(k=000, data=PSK). 
Assume a non-collision-resistant hash function. Then an attacker that can
establish multiple PSKs of their choice with another party can cause two
sessions with two different PSKs to share the same early_secret. If the other
party reuses ECDH(E) values, the attacker can also cause the handshake_secret to
be identical.

Furthermore, 
Client_Handshake_Traffic_Secret = 
  HMAC(k=Handshake_Secret, data=Label||H(ClientHello...ServerHello)) 
If the attacker is the server, and the hash function allows for chosen-prefix
collisions, the attacker can choose two ServerHello messages such that for two
different ClientHello messages, H(ClientHello...ServerHello) is identical.
This leads to identical values for an actual key output of the key schedule,
Client-Handshake-Traffic-Secret (if the client reuses an ECDH(E) value, or in a
hypothetical PQ TLS, which uses a KEM and the server chooses the encapsulated
key).

We note that the full version of the HKDF paper explicitly disclaims security in
the presence of attacker-controlled entropy. Also, note that by definition, a
KEM allows one party to control the secret.

# Appendix: The APOP Attack

APOP is an old challenge-response protocol used in email, relevant here because
it demonstrates the attack well. Broadly, in APOP the challenger sends a
challenge, and the responder needs to respond with:
MD5(challenge || password)
where || denotes concatenation.

The attacker wants to e.g. test whether the password starts with 'a'. They
pick an MD5 collision x, y such that MD5(x) = MD5(y) and both x and y end with
'a'. They wait for the client to connect in two different sessions, and send
x[:-1] and y[:-1] as the challenges, where [:-1] denotes removing the last byte
from a string. If the password starts with 'a', and the MD5 blocks align, then
the response will be the same for both challenges. The attacker can therefore
test a single guess for the starting byte with two sessions, and learn that byte
after at most 512 sessions. See [1], [2].

best wishes,
Nimrod Aviram, Benjamin Dowling, Ilan Komargodski, Kenny Paterson, Eyal Ronen, Eylon Yogev

References: 
[1] Practical key-recovery attack against APOP, an MD5-based challenge-response authentication. Leurent, Gaetan.

[2] Practical Password Recovery on an MD5 Challenge and Response.
Sasaki, Yu and Yamamoto, Go and Aoki, Kazumaro.

 

----------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.