Skip to contentSkip to conversation

libssh: Fix CVE-2025-8277

PATCH New Vijay Anusuri 1 participant 1 message Oct 30, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libssh: Fix CVE-2025-8277

Upstream-Commits:
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=87db2659ec608a977a63eea529f17b9168388d73
&
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=266174a6d36687b65cf90174f06af90b8b27c65f
&
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=8e4d67aa9eda455bfad9ac610e54b7a548d0aa08
& https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=1c763e29d138db87665e98983f468d2dd0f286c1

The changes made to the file src/ecdh_crypto.c are excluded, present in the commit 266174a6d36687b65cf90174f06af90b8b27c65.
The relevant changes in ecdh_crypto.c are located within the function static ssh_string ssh_ecdh_generate. This function, however, is not present in the libssh-0.10.6 version. It was introduced in libssh version 0.11 by the commit https://git.libssh.org/projects/libssh.git/commit/src/ecdh_crypto.c?h=stable-0.11&id=1eb3df5254a4348eae6edbc8a2bf08fef4015897.

Consequently, these changes cannot be directly applied to the libssh-0.10.6 version. This aligns with the approach taken by other distributions, as Suse also did not backport the ecdh_crypto.c file changes in their libssh-0.10.6-3.1.src.rpm package, which is available at https://cdimage.debian.org/mirror/opensuse.org/distribution/leap-micro/6.0/product/repo/openSUSE-Leap-Micro-6.0-x86_64-Media3/src/libssh-0.10.6-3.1.src.rpm.

---
 .../libssh/libssh/CVE-2025-8277-1.patch       | 40 ++++++++
 .../libssh/libssh/CVE-2025-8277-2.patch       | 94 +++++++++++++++++++
 .../libssh/libssh/CVE-2025-8277-3.patch       | 48 ++++++++++
 .../libssh/libssh/CVE-2025-8277-4.patch       | 48 ++++++++++
 .../recipes-support/libssh/libssh_0.10.6.bb   |  4 +
 5 files changed, 234 insertions(+)
 create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-1.patch
 create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch
 create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-3.patch
 create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-4.patch
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-1.patch new file +40 -0
new file mode 100644
index 0000000000..7155618271
@@ -0,0 +1,40 @@
+From 87db2659ec608a977a63eea529f17b9168388d73 Mon Sep 17 00:00:00 2001
+From: Jakub Jelen <[email protected]>
+Date: Tue, 5 Aug 2025 18:42:31 +0200
+Subject: CVE-2025-8277: packet: Adjust packet filter to work when DH-GEX is
+ guessed wrongly
+
+Signed-off-by: Jakub Jelen <[email protected]>
+Reviewed-by: Andreas Schneider <[email protected]>
+(cherry picked from commit 4310a696f2d632c6742678077d703d9b9ff3bc0e)
+
+Upstream-Status: Backport [https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=87db2659ec608a977a63eea529f17b9168388d73]
+CVE: CVE-2025-8277
+Signed-off-by: Vijay Anusuri <[email protected]>
+---
+ src/packet.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/packet.c b/src/packet.c
+index f15aa2ad..f54b3158 100644
+--- a/src/packet.c
++++ b/src/packet.c
+@@ -294,6 +294,7 @@ static enum ssh_packet_filter_result_e ssh_packet_incoming_filter(ssh_session se
+          *   or session_state == SSH_SESSION_STATE_INITIAL_KEX
+          * - dh_handshake_state == DH_STATE_INIT
+          *   or dh_handshake_state == DH_STATE_INIT_SENT (re-exchange)
++         *   or dh_handshake_state == DH_STATE_REQUEST_SENT (dh-gex)
+          *   or dh_handshake_state == DH_STATE_FINISHED (re-exchange)
+          *
+          * Transitions:
+@@ -313,6 +314,7 @@ static enum ssh_packet_filter_result_e ssh_packet_incoming_filter(ssh_session se
+ 
+         if ((session->dh_handshake_state != DH_STATE_INIT) &&
+             (session->dh_handshake_state != DH_STATE_INIT_SENT) &&
++            (session->dh_handshake_state != DH_STATE_REQUEST_SENT) &&
+             (session->dh_handshake_state != DH_STATE_FINISHED))
+         {
+             rc = SSH_PACKET_DENIED;
+-- 
+cgit v1.2.3
+
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +94 -0

94 lines not on this page · raw message

meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-3.patch new file +48 -0

48 lines not on this page · raw message

meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-4.patch new file +48 -0

48 lines not on this page · raw message

meta-oe/recipes-support/libssh/libssh_0.10.6.bb +4 -0
index 602e01fce6..de37719b09 100644
@@ -18,6 +18,10 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable
            file://CVE-2025-4878-0002.patch \
            file://CVE-2025-5987.patch \
            file://CVE-2025-8114.patch \
+           file://CVE-2025-8277-1.patch \
+           file://CVE-2025-8277-2.patch \
+           file://CVE-2025-8277-3.patch \
+           file://CVE-2025-8277-4.patch \
           "
 SRCREV = "10e09e273f69e149389b3e0e5d44b8c221c2e7f6"
 
Signature · 1 line
2.43.0