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

"Blumenthal, Uri - 0553 - MITLL" <uri@ll.mit.edu> Wed, 01 September 2021 20:34 UTC

Return-Path: <prvs=58784c5895=uri@ll.mit.edu>
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 4D0D43A193E for <tls@ietfa.amsl.com>; Wed, 1 Sep 2021 13:34:19 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.895
X-Spam-Level:
X-Spam-Status: No, score=-0.895 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, MAY_BE_FORGED=1, MIME_QP_LONG_LINE=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=no autolearn_force=no
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 BpXi2uwnVxDW for <tls@ietfa.amsl.com>; Wed, 1 Sep 2021 13:34:13 -0700 (PDT)
Received: from MX3.LL.MIT.EDU (mx3.ll.mit.edu [129.55.12.52]) (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 CE9AF3A194C for <tls@ietf.org>; Wed, 1 Sep 2021 13:34:12 -0700 (PDT)
Received: from LLE2K16-HYBRD01.mitll.ad.local (lle2k16-hybrid01.llan.ll.mit.edu [172.25.5.112] (may be forged)) by MX3.LL.MIT.EDU (8.16.1.2/8.16.1.2) with ESMTPS id 181KY8HW374467 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 1 Sep 2021 16:34:08 -0400
ARC-Seal: i=1; a=rsa-sha256; s=arcselector5401; d=microsoft.com; cv=none; b=A5nqfWXmXT6ICUFJOAHXOvuoa/Yjm/rISK6KHSHVk7bMb1jvYQfkaLjDBHbxk1Kko4zJX6VB8BeOH/iPcXsCpMpeb5Wet5Qo2JqIZTFxBWpA4c70+xLyg6hpLi6G0Ur9oX55vdlrsuvMPx+VaghGktJ5/XZVZaZIQRJTgTlrcKUpjraJB4UuA2eLroO1HuKvIVLNSf7zo4O916pkNo/kh/ufx1ejArKfY0X33NJu7yquZyg+ALrjwYGD5PabyDelme0icO/OIKgymGzjOpIii5C+M8tUHuIuE6GFjzv9HDW+4g85bvG4ITj/NO6AzvRnmGUqgg5+z1C+W3xDDFpfqA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector5401; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iE/AZFxRYxPL5B4qq/g2yQ/LvsH2tPSlguewbFAThP8=; b=w5h2NDww8ZHqiGjK6Ug1lsL06aSxZN3tXsGCq0/uG5F/z5y8VtkBHEiRBQ66MjvfwpPBG13D6mmr0BOpAyR/4UXa4kLP2ruko9LnTyrSJAh6p+yzdPwlsnUdEaEUST9P2uCKpCHBT1TryE1SjN7vBAAXosqBzchwIGmK/LXZT3odx/il/0ceZ0S3FePrCTZzJLqCxIHSifhtd7sH6Vhz5+5j2MGQRQDAsB1hPmB8wwwFMe4YYGAQtfTC82S5GlnQREtHWOM/LBm/knCHcJJrDzr3SzGua3oVkLjBaxcf4QJCBn7q0T0cR4lJ5BT7WeobnYBV81uuyfNVyX41hIHp/Q==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ll.mit.edu; dmarc=pass action=none header.from=ll.mit.edu; dkim=pass header.d=ll.mit.edu; arc=none
From: "Blumenthal, Uri - 0553 - MITLL" <uri@ll.mit.edu>
To: Nimrod Aviram <nimrod.aviram@gmail.com>
CC: Eylon Yogev <eylony@gmail.com>, Ilan Komargodski <ilankom10@gmail.com>, Benjamin Dowling <b.dowling@sheffield.ac.uk>, Eyal Ronen <er@eyalro.net>, "<tls@ietf.org>" <tls@ietf.org>
Thread-Topic: [TLS] Combining Secrets in Hybrid Key Exchange in TLS 1.3
Thread-Index: AQHXn2u58T1RcdAnu0mYBk5+iaOTdquPX4SA
Date: Wed, 01 Sep 2021 20:34:06 +0000
Message-ID: <27861041-A7D9-401F-8790-4BD76ED3CB9D@ll.mit.edu>
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:
user-agent: Microsoft-MacOutlook/16.52.21080801
authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=ll.mit.edu;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: c463f443-5dac-4abd-8677-08d96d87d82d
x-ms-traffictypediagnostic: BN1P110MB020:
x-microsoft-antispam-prvs: <BN1P110MB020DB465DCD6A7D7AF75FF190CD9@BN1P110MB020.NAMP110.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers: OLM:10000;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: AQYtrjViE9J6Oa0joQ68p5QqUdgW5U8KfmvaxhohHPEbwJ5nOsft4OF08IpmUjZkmoOkToQzjVytp6LLHiXGILLAhEx5wUu536NlyBDO7hrel1Z6NldsfZgDxUMap6nO1mti4yES2OPOZ8KEfQtTwKbgRGcVZRf7ZXfKzDKSkFK+X2tE5lXR6gMI0cjsBHAxkbiX2eAnTF3I4vM3f3p+I03UNmYIsBvE59UHFgXfIQsDO7JYMJJAHF8iaSw1jxvAM7vfuBO4JDHDyVS1Ohm6IR1+8uOXU5+riyRk4Fo8+fPJTPp1CsPdrOGuvlDyHWxrnIYmpUMNw6g/vDfacoNLz29G0knZVdtqSuoDfZq3aEimkYb6t440ylWiA4h0VGWBMUl//QYzjDyjqqKjKOQIWyvOANslsjB8k9HyEzAWHvPr9Oh1WyqbBHxC1zBNmc1RkpHr7qLPixLww1NlkRw5B9/50v0jzivX8gvJUhnRtE/lkHXKwbb9GfVaMkbWwyqLXAdqiARW3OCuCL0a8JKGK+/d4IY0jJQuAYNcVL4GRUbJjKcs29NdlyOAkapUmdtCVykKiiiTUUal8m5qnB9forPNFEPqcTnznjllhUvYzUsbRTanv5JWTMD9stvPUkhJzMXgNi//33KL2Zcn3ccLAkxzJjhklFsY54AeqPkWqrVC4qJLBFLa6Y0kJq5h6sBPpgt5mljiVafozZ7i2iLMxkXMX1QWe/DKdBWTX+i7SCEUmsiRAp4kGQ3L/AIOolBY
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN1P110MB0706.NAMP110.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(376002)(136003)(396003)(39850400004)(366004)(346002)(26005)(75432002)(6512007)(54906003)(66556008)(4326008)(86362001)(38070700005)(83380400001)(76116006)(66446008)(33656002)(166002)(64756008)(186003)(5660300002)(66476007)(6916009)(66946007)(6486002)(122000001)(66616009)(6506007)(2906002)(38100700002)(53546011)(2616005)(8676002)(99936003)(478600001)(316002)(71200400001)(8936002)(45980500001); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: jjc+bNxqjU9Hrz24Db1rUuKoOE9vqNRBIxC3s2jYD9xsNd4SAPbVs/j4eDU2cDTDx4mXJwjosI+Wk2VMS0O7zhE+fTcV2PRBO4SVGUUKCniYCmCdpSRocU61a1KVsyiGGxSZwaHsYtZBpStafcjdyE+GbYUIBZrLiWNNBkW+26rphMRrx1S3zm6M4PdFmXxlqN+8UvUDsDvOZ9Rg9rrMKxYFPhmcTVi0TaZ9VlSkcyyu9xkiIdkCZTWAhuriV+tfg+b2BNcD3gfxJHtM5ZWbqAOclDgpljbY2SAFByNBgxwxX5qAJT+NZdHHN/TTREuD3NWDzANRB2zhT/9kaQdW2GC6rKph7ZveyGRzg8FYH9cA2+ofFJ2UQvVM7PuumM5Ecc/f0HAXzSrr7nafHXQrNk+3oVxzs3DhMl0nrFgbq0sxS/p6FqTjGzeHKNLbnAcEjwTtqsRkhEpJNf9iByWCwsV85nfjovQq09ZsBa2cYxp9lGQ5yZvXUni6CTAJ6QF0lSY2jERuhtxB552pZEKcOfO2aVIJjXEIxHIof0WGKOsUTb2NrVKXiiH3YlJ7FrK6y621Wq2YJgMZIeptoswNq8erXkALofqQa6bt5njuSY2v4MW63VJvvBj9F0zAOJzGYV4nruGpTLcXVcWDqDLMHf7kO2jwVg4t3MDXw8gPBtbpWfgzbi/dG3Js/oX3dlwBX1Ra6wXHWiNCfznMGbEQ7A==
x-ms-exchange-transport-forked: True
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg="sha256"; boundary="B_3713358845_288842836"
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: BN1P110MB0706.NAMP110.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id: c463f443-5dac-4abd-8677-08d96d87d82d
X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Sep 2021 20:34:06.3441 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 83d1efe3-698e-4819-911b-0a8fbe79d01c
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1P110MB020
X-Proofpoint-ORIG-GUID: gsDy2fDv9JqY_vRubBd_JkmXaUoJWhH0
X-Proofpoint-GUID: gsDy2fDv9JqY_vRubBd_JkmXaUoJWhH0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-09-01_05:2021-09-01, 2021-09-01 signatures=0
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2108310000 definitions=main-2109010118
Archived-At: <https://mailarchive.ietf.org/arch/msg/tls/SQoR6tlVN37PFIz5Kwt5pfQf0BY>
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: Wed, 01 Sep 2021 20:34:20 -0000

How does the described AOAP attack apply to TLS KDF?

 

--

Regards,

Uri

 

There are two ways to design a system. One is to make is so simple there are obviously no deficiencies.

The other is to make it so complex there are no obvious deficiencies.

                                                                                                                                     -  C. A. R. Hoare

 

 

From: TLS <tls-bounces@ietf.org> on behalf of Nimrod Aviram <nimrod.aviram@gmail.com>
Date: Wednesday, September 1, 2021 at 15:58
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 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.