|
| 1 | +From 001a6b04cfea193c4e3073d002a5cb7058d01714 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Azure Linux Security Servicing Account |
| 3 | + |
| 4 | +Date: Tue, 15 Jul 2025 05:54:27 +0000 |
| 5 | +Subject: [PATCH] Fix CVE CVE-2025-6395 in gnutls |
| 6 | + |
| 7 | +Upstream Patch Reference: https://gitlab.com/gnutls/gnutls/-/commit/23135619773e6ec087ff2abc65405bd4d5676bad.patch |
| 8 | +--- |
| 9 | + lib/handshake.c | 25 ++++++++++++++++++++++--- |
| 10 | + lib/state.c | 4 +++- |
| 11 | + 2 files changed, 25 insertions(+), 4 deletions(-) |
| 12 | + |
| 13 | +diff --git a/lib/handshake.c b/lib/handshake.c |
| 14 | +index 722307b..489d021 100644 |
| 15 | +--- a/lib/handshake.c |
| 16 | ++++ b/lib/handshake.c |
| 17 | +@@ -589,9 +589,28 @@ static int set_auth_types(gnutls_session_t session) |
| 18 | + /* Under TLS1.3 this returns a KX which matches the negotiated |
| 19 | + * groups from the key shares; if we are resuming then the KX seen |
| 20 | + * here doesn't match the original session. */ |
| 21 | +- if (!session->internals.resumed) |
| 22 | +- kx = gnutls_kx_get(session); |
| 23 | +- else |
| 24 | ++ if (!session->internals.resumed) { |
| 25 | ++ const gnutls_group_entry_st *group = get_group(session); |
| 26 | ++ |
| 27 | ++ if (session->internals.hsk_flags & HSK_PSK_SELECTED) { |
| 28 | ++ if (group) { |
| 29 | ++ kx = group->pk == GNUTLS_PK_DH ? |
| 30 | ++ GNUTLS_KX_DHE_PSK : |
| 31 | ++ GNUTLS_KX_ECDHE_PSK; |
| 32 | ++ } else { |
| 33 | ++ kx = GNUTLS_KX_PSK; |
| 34 | ++ } |
| 35 | ++ } else if (group) { |
| 36 | ++ /* Not necessarily be RSA, but just to |
| 37 | ++ * make _gnutls_map_kx_get_cred below |
| 38 | ++ * work. |
| 39 | ++ */ |
| 40 | ++ kx = group->pk == GNUTLS_PK_DH ? |
| 41 | ++ GNUTLS_KX_DHE_RSA : |
| 42 | ++ GNUTLS_KX_ECDHE_RSA; |
| 43 | ++ } else |
| 44 | ++ kx = GNUTLS_KX_UNKNOWN; |
| 45 | ++ } else |
| 46 | + kx = GNUTLS_KX_UNKNOWN; |
| 47 | + } else { |
| 48 | + /* TLS1.2 or earlier, kx is associated with ciphersuite */ |
| 49 | +diff --git a/lib/state.c b/lib/state.c |
| 50 | +index ec514c0..10ec0ea 100644 |
| 51 | +--- a/lib/state.c |
| 52 | ++++ b/lib/state.c |
| 53 | +@@ -202,7 +202,8 @@ gnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session) |
| 54 | + const gnutls_group_entry_st *group = get_group(session); |
| 55 | + |
| 56 | + if (ver->tls13_sem) { |
| 57 | +- if (session->internals.hsk_flags & HSK_PSK_SELECTED) { |
| 58 | ++ if (gnutls_auth_client_get_type(session) == |
| 59 | ++ GNUTLS_CRD_PSK) { |
| 60 | + if (group) { |
| 61 | + if (group->pk == GNUTLS_PK_DH) |
| 62 | + return GNUTLS_KX_DHE_PSK; |
| 63 | +@@ -349,6 +350,7 @@ void reset_binders(gnutls_session_t session) |
| 64 | + _gnutls_free_temp_key_datum(&session->key.binders[0].psk); |
| 65 | + _gnutls_free_temp_key_datum(&session->key.binders[1].psk); |
| 66 | + memset(session->key.binders, 0, sizeof(session->key.binders)); |
| 67 | ++ session->internals.hsk_flags &= ~HSK_PSK_SELECTED; |
| 68 | + } |
| 69 | + |
| 70 | + /* Check whether certificate credentials of type @cert_type are set |
| 71 | +-- |
| 72 | +2.45.3 |
| 73 | + |
0 commit comments