From a2905fda96b9b87c0e2d6536842515c71de281b7 Mon Sep 17 00:00:00 2001 From: zhangbinqin Date: Mon, 15 Sep 2025 09:32:39 +0000 Subject: [PATCH] fix CVE-2025-8114 --- ...nter-dereference-after-allocate-fail.patch | 46 +++++++++++++++++++ libssh.spec | 9 +++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 backport-CVE-2025-8114-NULL-pointer-dereference-after-allocate-fail.patch diff --git a/backport-CVE-2025-8114-NULL-pointer-dereference-after-allocate-fail.patch b/backport-CVE-2025-8114-NULL-pointer-dereference-after-allocate-fail.patch new file mode 100644 index 0000000..4402585 --- /dev/null +++ b/backport-CVE-2025-8114-NULL-pointer-dereference-after-allocate-fail.patch @@ -0,0 +1,46 @@ +From 53ac23ded4cb2c5463f6c4cd1525331bd578812d Mon Sep 17 00:00:00 2001 +From: Andreas Schneider +Date: Wed, 6 Aug 2025 15:17:59 +0200 +Subject: CVE-2025-8114: Fix NULL pointer dereference after allocation failure + +Signed-off-by: Andreas Schneider +Reviewed-by: Jakub Jelen + +Conflict: NA +Reference:https://git.libssh.org/projects/libssh.git/patch/?id=53ac23ded4cb2c5463f6c4cd1525331bd578812d +--- + src/kex.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/kex.c b/src/kex.c +index b8958b5..a834568 100644 +--- a/src/kex.c ++++ b/src/kex.c +@@ -1332,6 +1332,8 @@ int ssh_make_sessionid(ssh_session session) + ssh_log_hexdump("hash buffer", ssh_buffer_get(buf), ssh_buffer_get_len(buf)); + #endif + ++ /* Set rc for the following switch statement in case we goto error. */ ++ rc = SSH_ERROR; + switch (session->next_crypto->kex_type) { + case SSH_KEX_DH_GROUP1_SHA1: + case SSH_KEX_DH_GROUP14_SHA1: +@@ -1391,6 +1393,7 @@ int ssh_make_sessionid(ssh_session session) + session->next_crypto->secret_hash); + break; + } ++ + /* During the first kex, secret hash and session ID are equal. However, after + * a key re-exchange, a new secret hash is calculated. This hash will not replace + * but complement existing session id. +@@ -1399,6 +1402,7 @@ int ssh_make_sessionid(ssh_session session) + session->next_crypto->session_id = malloc(session->next_crypto->digest_len); + if (session->next_crypto->session_id == NULL) { + ssh_set_error_oom(session); ++ rc = SSH_ERROR; + goto error; + } + memcpy(session->next_crypto->session_id, session->next_crypto->secret_hash, +-- +2.33.0 + diff --git a/libssh.spec b/libssh.spec index da00922..cd4a5e1 100644 --- a/libssh.spec +++ b/libssh.spec @@ -1,6 +1,6 @@ Name: libssh Version: 0.9.6 -Release: 11 +Release: 12 Summary: A library implementing the SSH protocol License: LGPLv2+ URL: http://www.libssh.org @@ -65,6 +65,7 @@ Patch52: backport-CVE-2025-4878-fix-uninitialized-variable-part1.patch Patch53: backport-CVE-2025-4878-fix-uninitialized-variable-part2.patch Patch54: backport-CVE-2025-5372-pre-Reformat-ssh_kdf.patch Patch55: backport-CVE-2025-5372-Simplify-error-checking-in-ssh_kdf.patch +Patch56: backport-CVE-2025-8114-NULL-pointer-dereference-after-allocate-fail.patch BuildRequires: cmake gcc-c++ gnupg2 openssl-devel pkgconfig zlib-devel BuildRequires: krb5-devel libcmocka-devel openssh-clients openssh-server @@ -150,6 +151,12 @@ popd %doc ChangeLog README %changelog +* Mon Sep 15 2025 zhangbinqin - 0.9.6-12 +- Type:CVE +- Id:CVE-2025-8114 +- SUG:NA +- DESC:fix CVE-2025-8114 + * Wed Aug 27 2025 gaihuiying - 0.9.6-11 - Type:CVE - CVE:CVE-2025-4877 CVE-2025-4878 CVE-2025-5372 -- Gitee