Fix timing side-channel in TLS RSA key exchange
Resolves: #2162601 Signed-off-by: Daiki Ueno <dueno@redhat.com>
This commit is contained in:
parent
bb8f9067ee
commit
f764d48554
114
gnutls-3.7.8-rsa-kx-timing.patch
Normal file
114
gnutls-3.7.8-rsa-kx-timing.patch
Normal file
@ -0,0 +1,114 @@
|
||||
From c149dd0767f32789e391280cb1eb06b7eb7c6bce Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Sosedkin <asosedkin@redhat.com>
|
||||
Date: Tue, 9 Aug 2022 16:05:53 +0200
|
||||
Subject: [PATCH 1/2] auth/rsa: side-step potential side-channel
|
||||
|
||||
Remove branching that depends on secret data.
|
||||
|
||||
Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
|
||||
Signed-off-by: Hubert Kario <hkario@redhat.com>
|
||||
Tested-by: Hubert Kario <hkario@redhat.com>
|
||||
---
|
||||
lib/auth/rsa.c | 10 ----------
|
||||
1 file changed, 10 deletions(-)
|
||||
|
||||
diff --git a/lib/auth/rsa.c b/lib/auth/rsa.c
|
||||
index 8108ee841d..6b158bacb2 100644
|
||||
--- a/lib/auth/rsa.c
|
||||
+++ b/lib/auth/rsa.c
|
||||
@@ -155,7 +155,6 @@ static int
|
||||
proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
||||
size_t _data_size)
|
||||
{
|
||||
- const char attack_error[] = "auth_rsa: Possible PKCS #1 attack\n";
|
||||
gnutls_datum_t ciphertext;
|
||||
int ret, dsize;
|
||||
ssize_t data_size = _data_size;
|
||||
@@ -235,15 +234,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
||||
ok &= CONSTCHECK_NOT_EQUAL(check_ver_min, 0) &
|
||||
CONSTCHECK_EQUAL(session->key.key.data[1], ver_min);
|
||||
|
||||
- if (ok) {
|
||||
- /* call logging function unconditionally so all branches are
|
||||
- * indistinguishable for timing and cache access when debug
|
||||
- * logging is disabled */
|
||||
- _gnutls_no_log("%s", attack_error);
|
||||
- } else {
|
||||
- _gnutls_debug_log("%s", attack_error);
|
||||
- }
|
||||
-
|
||||
/* This is here to avoid the version check attack
|
||||
* discussed above.
|
||||
*/
|
||||
--
|
||||
2.39.1
|
||||
|
||||
|
||||
From 7c963102ec2119eecc1789b993aabe5edfd75f3b Mon Sep 17 00:00:00 2001
|
||||
From: Hubert Kario <hkario@redhat.com>
|
||||
Date: Wed, 8 Feb 2023 14:32:09 +0100
|
||||
Subject: [PATCH 2/2] rsa: remove dead code
|
||||
|
||||
since the `ok` variable isn't used any more, we can remove all code
|
||||
used to calculate it
|
||||
|
||||
Signed-off-by: Hubert Kario <hkario@redhat.com>
|
||||
---
|
||||
lib/auth/rsa.c | 20 +++-----------------
|
||||
1 file changed, 3 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/lib/auth/rsa.c b/lib/auth/rsa.c
|
||||
index 6b158bacb2..858701fe6e 100644
|
||||
--- a/lib/auth/rsa.c
|
||||
+++ b/lib/auth/rsa.c
|
||||
@@ -159,8 +159,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
||||
int ret, dsize;
|
||||
ssize_t data_size = _data_size;
|
||||
volatile uint8_t ver_maj, ver_min;
|
||||
- volatile uint8_t check_ver_min;
|
||||
- volatile uint32_t ok;
|
||||
|
||||
#ifdef ENABLE_SSL3
|
||||
if (get_num_version(session) == GNUTLS_SSL3) {
|
||||
@@ -186,7 +184,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
||||
|
||||
ver_maj = _gnutls_get_adv_version_major(session);
|
||||
ver_min = _gnutls_get_adv_version_minor(session);
|
||||
- check_ver_min = (session->internals.allow_wrong_pms == 0);
|
||||
|
||||
session->key.key.data = gnutls_malloc(GNUTLS_MASTER_SIZE);
|
||||
if (session->key.key.data == NULL) {
|
||||
@@ -205,10 +202,9 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
- ret =
|
||||
- gnutls_privkey_decrypt_data2(session->internals.selected_key,
|
||||
- 0, &ciphertext, session->key.key.data,
|
||||
- session->key.key.size);
|
||||
+ gnutls_privkey_decrypt_data2(session->internals.selected_key,
|
||||
+ 0, &ciphertext, session->key.key.data,
|
||||
+ session->key.key.size);
|
||||
/* After this point, any conditional on failure that cause differences
|
||||
* in execution may create a timing or cache access pattern side
|
||||
* channel that can be used as an oracle, so treat very carefully */
|
||||
@@ -224,16 +220,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
||||
* Vlastimil Klima, Ondej Pokorny and Tomas Rosa.
|
||||
*/
|
||||
|
||||
- /* ok is 0 in case of error and 1 in case of success. */
|
||||
-
|
||||
- /* if ret < 0 */
|
||||
- ok = CONSTCHECK_EQUAL(ret, 0);
|
||||
- /* session->key.key.data[0] must equal ver_maj */
|
||||
- ok &= CONSTCHECK_EQUAL(session->key.key.data[0], ver_maj);
|
||||
- /* if check_ver_min then session->key.key.data[1] must equal ver_min */
|
||||
- ok &= CONSTCHECK_NOT_EQUAL(check_ver_min, 0) &
|
||||
- CONSTCHECK_EQUAL(session->key.key.data[1], ver_min);
|
||||
-
|
||||
/* This is here to avoid the version check attack
|
||||
* discussed above.
|
||||
*/
|
||||
--
|
||||
2.39.1
|
||||
|
@ -13,7 +13,7 @@ print(string.sub(hash, 0, 16))
|
||||
}
|
||||
|
||||
Version: 3.7.6
|
||||
Release: 16%{?dist}
|
||||
Release: 17%{?dist}
|
||||
# not upstreamed
|
||||
Patch: gnutls-3.6.7-no-now-guile.patch
|
||||
Patch: gnutls-3.2.7-rpath.patch
|
||||
@ -38,6 +38,7 @@ Patch: gnutls-3.7.6-fips-service-indicator-test-functions.patch
|
||||
Patch: gnutls-3.7.6-fips-ccm-taglen.patch
|
||||
Patch: gnutls-3.7.6-fips-rsa-pss-saltlen.patch
|
||||
Patch: gnutls-3.7.8-revert-hmac-name.patch
|
||||
Patch: gnutls-3.7.8-rsa-kx-timing.patch
|
||||
|
||||
# not upstreamed
|
||||
Patch: gnutls-3.7.3-disable-config-reload.patch
|
||||
@ -405,6 +406,9 @@ make check %{?_smp_mflags} GNUTLS_SYSTEM_PRIORITY_FILE=/dev/null
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Feb 10 2023 Daiki Ueno <dueno@redhat.com> - 3.7.6-17
|
||||
- Fix timing side-channel in TLS RSA key exchange (#2162601)
|
||||
|
||||
* Fri Feb 10 2023 Daiki Ueno <dueno@redhat.com> - 3.7.6-16
|
||||
- fips: extend PCT to DH key generation (#2168143)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user