libssh: Fix CVE-2025-8277
PATCH 1/1 libssh: Fix CVE-2025-8277
From: Vijay Anusuri <[email protected]>
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
--- .../libssh/libssh/CVE-2025-8277-1.patch | 40 +++++++++ .../libssh/libssh/CVE-2025-8277-2.patch | 89 +++++++++++++++++++ .../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, 229 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
@@ -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 +89 -0
89 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
@@ -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.25.1
Quoted 17 lines · Vijay Anusuri via lists.openembedded.org
+++
b/meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch(quoted diff) +1
-0@@ -0,0 +1,89 @@ +From 266174a6d36687b65cf90174f06af90b8b27c65f Mon Sep 17 00:00:002001
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +3
-0+From: Francesco Rollo <[email protected]> +Date: Thu, 24 Jul 2025 16:30:07 +0300 +Subject: [PATCH] CVE-2025-8277: Fix memory leak of unused ephemeralkey pair
+ after client's wrong KEX guessmeta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +6
-0+ +Signed-off-by: Francesco Rollo <[email protected]> +Reviewed-by: Andreas Schneider <[email protected]> +(cherry picked from commit ccff22d3787c1355b3f0dcd09fe54d90acc55bf1) + +Upstream-Status: Backport[https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=
266174a6d36687b65cf90174f06af90b8b27c65f]
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch line 18
Quoted 7 lines
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +7
-0+CVE: CVE-2025-8277 +Signed-off-by: Vijay Anusuri <[email protected]> +--- + src/dh_crypto.c | 5 +++++ + src/dh_key.c | 5 +++++ + src/ecdh_gcrypt.c | 6 ++++++ + src/ecdh_mbedcrypto.c | 6 ++++++
This does not look like a simple backport of
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=266174a6d36687b65cf90174f06af90b8b27c65f
Was the change in ecdh_crypto.c not required?
Hi Anuj,
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`
.
Thanks & Regards,
Vijay
Quoted 33 lines · Anuj
Quoted 17 lines · Vijay Anusuri via lists.openembedded.org
+++
b/meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch(quoted diff) +1
-0@@ -0,0 +1,89 @@ +From 266174a6d36687b65cf90174f06af90b8b27c65f Mon Sep 17 00:00:002001
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +3
-0+From: Francesco Rollo <[email protected]> +Date: Thu, 24 Jul 2025 16:30:07 +0300 +Subject: [PATCH] CVE-2025-8277: Fix memory leak of unused ephemeralkey pair
+ after client's wrong KEX guessmeta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +6
-0+ +Signed-off-by: Francesco Rollo <[email protected]> +Reviewed-by: Andreas Schneider <[email protected]> +(cherry picked from commit ccff22d3787c1355b3f0dcd09fe54d90acc55bf1) + +Upstream-Status: Backport[https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=
266174a6d36687b65cf90174f06af90b8b27c65f]meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch line 18
Quoted 7 lines
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +7
-0+CVE: CVE-2025-8277 +Signed-off-by: Vijay Anusuri <[email protected]> +--- + src/dh_crypto.c | 5 +++++ + src/dh_key.c | 5 +++++ + src/ecdh_gcrypt.c | 6 ++++++ + src/ecdh_mbedcrypto.c | 6 ++++++This does not look like a simple backport of
Was the change in
ecdh_crypto.cnot required?
Quoted 9 lines · Vijay Anusuri
Hi Anuj,
The relevant changes in
ecdh_crypto.care located within the functionstatic ssh_string ssh_ecdh_generate. This function, however, is not present in thelibssh-0.10.6version. It was introduced inlibsshversion 0.11 by the commithttps://git.libssh.org/projects/libssh.git/commit/src/ecdh_crypto.c? h=stable-0.11&id=1eb3df5254a4348eae6edbc8a2bf08fef4015897.
Quoted 8 lines
Consequently, these changes cannot be directly applied to the
libssh-0.10.6version. This aligns with the approach taken by other distributions, as Suse also did not backport theecdh_crypto.cfile changes in theirlibssh-0.10.6-3.1.src.rpmpackage, which is available athttps://cdimage.debian.org/mirror/opensuse.org/distribution/leap-mic ro/6.0/product/repo/openSUSE-Leap-Micro-6.0-x86_64-Media3/src/libssh- 0.10.6-3.1.src.rpm.
Thank you for the details. These should be present in the commit message saying what was changed while cherry-picking.
Can you please send a v2?
Quoted 42 lines
Thanks & Regards,
VijayQuoted 36 lines · Anuj
Quoted 22 lines · Vijay Anusuri via lists.openembedded.org
+++
b/meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch(quoted diff) +1
-0@@ -0,0 +1,89 @@ +From 266174a6d36687b65cf90174f06af90b8b27c65f Mon Sep 1700:00:00
2001meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +3
-0+From: Francesco Rollo <[email protected]> +Date: Thu, 24 Jul 2025 16:30:07 +0300 +Subject: [PATCH] CVE-2025-8277: Fix memory leak of unusedephemeral
key pair
+ after client's wrong KEX guessmeta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +4
-0+ +Signed-off-by: Francesco Rollo <[email protected]> +Reviewed-by: Andreas Schneider <[email protected]> +(cherry picked from commit
ccff22d3787c1355b3f0dcd09fe54d90acc55bf1)(quoted diff) +2
-0+ +Upstream-Status: Backport[
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&i
d=266174a6d36687b65cf90174f06af90b8b27c65f]meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch line 18
Quoted 7 lines
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +7
-0+CVE: CVE-2025-8277 +Signed-off-by: Vijay Anusuri <[email protected]> +--- + src/dh_crypto.c | 5 +++++ + src/dh_key.c | 5 +++++ + src/ecdh_gcrypt.c | 6 ++++++ + src/ecdh_mbedcrypto.c | 6 ++++++This does not look like a simple backport of
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&id=266174a6d36687b65cf90174f06af90b8b27c65fWas the change in
ecdh_crypto.cnot required?
Hi Anuj,
I have sent a V2 patch
https://lists.openembedded.org/g/openembedded-devel/message/121197
Thanks & Regards,
Vijay
Quoted 68 lines · Anuj
Quoted 9 lines · Vijay Anusuri
Hi Anuj,
The relevant changes in
ecdh_crypto.care located within the functionstatic ssh_string ssh_ecdh_generate. This function, however, is not present in thelibssh-0.10.6version. It was introduced inlibsshversion 0.11 by the commithttps://git.libssh.org/projects/libssh.git/commit/src/ecdh_crypto.c? h=stable-0.11&id=1eb3df5254a4348eae6edbc8a2bf08fef4015897.Quoted 8 lines
Consequently, these changes cannot be directly applied to the
libssh-0.10.6version. This aligns with the approach taken by other distributions, as Suse also did not backport theecdh_crypto.cfile changes in theirlibssh-0.10.6-3.1.src.rpmpackage, which is available athttps://cdimage.debian.org/mirror/opensuse.org/distribution/leap-mic ro/6.0/product/repo/openSUSE-Leap-Micro-6.0-x86_64-Media3/src/libssh- 0.10.6-3.1.src.rpm.Thank you for the details. These should be present in the commit message saying what was changed while cherry-picking.
Can you please send a v2?
Quoted 40 lines
Thanks & Regards,
VijayQuoted 34 lines · Anuj
Quoted 22 lines · Vijay Anusuri via lists.openembedded.org
+++
b/meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch(quoted diff) +1
-0@@ -0,0 +1,89 @@ +From 266174a6d36687b65cf90174f06af90b8b27c65f Mon Sep 1700:00:00
2001meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +3
-0+From: Francesco Rollo <[email protected]> +Date: Thu, 24 Jul 2025 16:30:07 +0300 +Subject: [PATCH] CVE-2025-8277: Fix memory leak of unusedephemeral
key pair
+ after client's wrong KEX guessmeta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +4
-0+ +Signed-off-by: Francesco Rollo <[email protected]> +Reviewed-by: Andreas Schneider <[email protected]> +(cherry picked from commit
ccff22d3787c1355b3f0dcd09fe54d90acc55bf1)(quoted diff) +2
-0+ +Upstream-Status: Backport[
https://git.libssh.org/projects/libssh.git/commit/?h=stable-0.11&i
d=266174a6d36687b65cf90174f06af90b8b27c65f]meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch line 18
Quoted 7 lines
meta-oe/recipes-support/libssh/libssh/CVE-2025-8277-2.patch new file +7
-0+CVE: CVE-2025-8277 +Signed-off-by: Vijay Anusuri <[email protected]> +--- + src/dh_crypto.c | 5 +++++ + src/dh_key.c | 5 +++++ + src/ecdh_gcrypt.c | 6 ++++++ + src/ecdh_mbedcrypto.c | 6 ++++++This does not look like a simple backport of
Quoted 2 lines
Quoted 2 lines
Was the change in
ecdh_crypto.cnot required?