gnutls: Apply patch to fix CVE-2023-0361 (#5001)

* gnutls: apply patch to fix CVE-2023-0361

* fix the patch manually
This commit is contained in:
Nan Liu 2023-03-07 09:40:36 -08:00 committed by GitHub
parent 13f1c019a5
commit cf13330b87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 1 deletions

View File

@ -0,0 +1,88 @@
From b65f51cbd579de7f347ed9de5f3a836c5bbc11be Mon Sep 17 00:00:00 2001
From: Nan Liu <liunan@microsoft.com>
Date: Mon, 6 Mar 2023 17:19:57 -0800
Subject: [PATCH] Address CVE-2023-0361
From 80a6ce8ddb02477cd724cd5b2944791aaddb702a 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/3] 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 | 30 +++---------------------------
1 file changed, 3 insertions(+), 27 deletions(-)
diff --git a/lib/auth/rsa.c b/lib/auth/rsa.c
index 8108ee8..858701f 100644
--- a/lib/auth/rsa.c
+++ b/lib/auth/rsa.c
@@ -155,13 +155,10 @@ 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;
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) {
@@ -187,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) {
@@ -206,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 */
@@ -225,25 +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);
-
- 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.25.1

View File

@ -1,13 +1,14 @@
Summary: The GnuTLS Transport Layer Security Library
Name: gnutls
Version: 3.7.7
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv3+ AND LGPLv2.1+
Vendor: Microsoft Corporation
Distribution: Mariner
Group: System Environment/Libraries
URL: https://www.gnutls.org
Source0: https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/%{name}-%{version}.tar.xz
Patch0: CVE-2023-0361.patch
BuildRequires: autogen-libopts-devel
BuildRequires: gc-devel
BuildRequires: guile-devel
@ -94,6 +95,9 @@ sed -i 's/TESTS += test-ciphers-openssl.sh//' tests/slow/Makefile.am
%{_mandir}/man3/*
%changelog
* Mon Mar 06 2023 Nan Liu <liunan@microsoft.com> - 3.7.7-2
- Add patch to fix CVE-2023-0361
* Tue Aug 09 2022 Andrew Phelps <anphel@microsoft.com> - 3.7.7-1
- Update to version 3.7.7 to resolve CVE CVE-2022-2509