libssh: Fix multiple CVEs
v2 cover libssh: Fix multiple CVEs
From: Hetvi Thakar <[email protected]>
Backport five upstream libssh security fixes to the 0.10.6 recipe on
scarthgap:
- CVE-2026-59843
- CVE-2026-59844
- CVE-2026-59846
- CVE-2026-59848
- CVE-2026-59850
Carry these as focused backports instead of upgrading libssh because newer releases include API and functional changes outside the security scope.
CVE-2026-15370 and CVE-2026-59849 affect libssh >= 0.11.0. CVE-2026-59842 and CVE-2026-59851 affect only libssh 0.12.0 and rely on code or features absent from 0.10.6. NVD correction requests have been submitted for these inaccurate affected-version entries; therefore, no CVE_STATUS entries are added.
The individual commits retain the upstream fix provenance and advisory references for each CVE.
Testing:
- Applied all five patches to libssh 0.10.6 in series order without conflicts or fuzz.
- Package build completed successfully.
- Ptest completed successfully.
Hetvi Thakar (5):
libssh: Fix CVE-2026-59843
libssh: Fix CVE-2026-59844
libssh: Fix CVE-2026-59846
libssh: Fix CVE-2026-59848
libssh: Fix CVE-2026-59850
.../libssh/libssh/CVE-2026-59843.patch | 84 +++ .../libssh/libssh/CVE-2026-59844.patch | 52 ++ .../libssh/libssh/CVE-2026-59846.patch | 87 +++ .../libssh/CVE-2026-59848-regression.patch | 45 ++ .../libssh/libssh/CVE-2026-59848.patch | 684 ++++++++++++++++++ .../libssh/libssh/CVE-2026-59850.patch | 40 + .../recipes-support/libssh/libssh_0.10.6.bb | 6 + 7 files changed, 998 insertions(+) create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59843.patch create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59844.patch create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59846.patch create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59848-regression.patch create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59848.patch create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59850.patch
Signature · 1 line
2.35.6
PATCH v2 1/5 libssh: Fix CVE-2026-59843
From: Hetvi Thakar <[email protected]>
The stable-0.11 commit shown in [1] is the upstream fix selected for this backport. The upstream advisory [2] documents CVE-2026-59843 and identifies libssh 0.11.5 as the fixed release for the 0.11 series.
[1] https://git.libssh.org/projects/libssh.git/commit/?id=687ef1c44b646b9db0b1c6e8f987edb7c9e4d919
[2] https://www.libssh.org/security/advisories/CVE-2026-59843.txt
--- .../libssh/libssh/CVE-2026-59843.patch | 84 +++++++++++++++++++ .../recipes-support/libssh/libssh_0.10.6.bb | 1 + 2 files changed, 85 insertions(+) create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59843.patch
meta-oe/recipes-support/libssh/libssh/CVE-2026-59843.patch new file +84 -0
@@ -0,0 +1,84 @@ +From d965eb941a9a83a0643570a93d8997b91e248fc1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= <[email protected]> +Date: Fri, 6 Mar 2026 13:58:30 +0100 +Subject: [PATCH] CVE-2026-59843 channels: Fail when receiving max packet size + 0 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Do this both for SSH2_MSG_CHANNEL_OPEN and for +SSH2_MSG_CHANNEL_OPEN_CONFIRMATION. Using the +max packet size 0 would lead to an infinite loop +in channel_write_common. + +Originally reported by Rinku Das on on 23th February. +Independently reported by Yi Lin on 26th February and +Haruto Kimura on 22nd March. + +We do not consider this as a security issue as connecting +to untrusted servers on the internet brings much worse +security consequences than hanging your clinet. + +Signed-off-by: Pavol Žáčik <[email protected]> +Reviewed-by: Jakub Jelen <[email protected]> + +CVE: CVE-2026-59843 +Upstream-Status: Backport [https://git.libssh.org/projects/libssh.git/commit/?id=687ef1c44b646b9db0b1c6e8f987edb7c9e4d919] + +(cherry picked from commit 44b186fa17aff497dae420c59c003222e438103c) +(cherry picked from commit 687ef1c44b646b9db0b1c6e8f987edb7c9e4d919) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + src/channels.c | 7 +++++++ + src/messages.c | 19 +++++++++++++++---- + 2 files changed, 22 insertions(+), 4 deletions(-) + +diff --git a/src/channels.c b/src/channels.c +index 8290dbd1..3afdcf11 100644 +--- a/src/channels.c ++++ b/src/channels.c +@@ -192,6 +192,13 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf){ + if (rc != SSH_OK) + goto error; + ++ if (channel->remote_maxpacket == 0) { ++ SSH_LOG(SSH_LOG_RARE, ++ "Invalid maximum packet size 0 in " ++ "SSH2_MSG_CHANNEL_OPEN_CONFIRMATION"); ++ goto error; ++ } ++ + SSH_LOG(SSH_LOG_PROTOCOL, + "Received a CHANNEL_OPEN_CONFIRMATION for channel %d:%d", + channel->local_channel, +diff --git a/src/messages.c b/src/messages.c +index 6dadabf0..e79ecec2 100644 +--- a/src/messages.c ++++ b/src/messages.c +@@ -1160,10 +1160,21 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open){ + SSH_LOG(SSH_LOG_PACKET, + "Clients wants to open a %s channel", type_c); + +- ssh_buffer_unpack(packet,"ddd", +- &msg->channel_request_open.sender, +- &msg->channel_request_open.window, +- &msg->channel_request_open.packet_size); ++ rc = ssh_buffer_unpack(packet, ++ "ddd", ++ &msg->channel_request_open.sender, ++ &msg->channel_request_open.window, ++ &msg->channel_request_open.packet_size); ++ if (rc != SSH_OK){ ++ goto error; ++ } ++ ++ if (msg->channel_request_open.packet_size == 0) { ++ ssh_set_error(session, ++ SSH_FATAL, ++ "Invalid maximum packet size 0 in SSH2_MSG_CHANNEL_OPEN"); ++ goto error; ++ } + + if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED){ + ssh_set_error(session,SSH_FATAL, "Invalid state when receiving channel open request (must be authenticated)");
meta-oe/recipes-support/libssh/libssh_0.10.6.bb +1 -0
@@ -32,6 +32,7 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable file://CVE-2026-0968-2.patch \ file://CVE-2026-0967.patch \ file://CVE-2026-0965.patch \ + file://CVE-2026-59843.patch \ " SRCREV = "10e09e273f69e149389b3e0e5d44b8c221c2e7f6"
Signature · 1 line
2.35.6
PATCH v2 2/5 libssh: Fix CVE-2026-59844
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
The stable-0.11 commit shown in [1] is the upstream fix selected for this backport. The upstream advisory [2] documents CVE-2026-59844 and identifies libssh 0.11.5 as the fixed release for the 0.11 series.
[1] https://git.libssh.org/projects/libssh.git/commit/?id=e31f06e5380be4e714d5ad6965981fbf30738da9
[2] https://www.libssh.org/security/advisories/CVE-2026-59844.txt
--- .../libssh/libssh/CVE-2026-59844.patch | 52 +++++++++++++++++++ .../recipes-support/libssh/libssh_0.10.6.bb | 1 + 2 files changed, 53 insertions(+) create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59844.patch
meta-oe/recipes-support/libssh/libssh/CVE-2026-59844.patch new file +52 -0
@@ -0,0 +1,52 @@ +From ef7cd6d4aef6d18ca8bf15cb0398b630284f46f4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= <[email protected]> +Date: Fri, 6 Mar 2026 18:05:29 +0100 +Subject: [PATCH] CVE-2026-59844 sftpserver: cap accepted values of len in + SSH_FXP_READ +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The client-provided length is directly used in +a malloc in process_read(), so not restricting it +leads to allocations bounded only by UINT32_MAX. + +The new cap is the same as the one currently used +by OpenSSH. + +Signed-off-by: Pavol Žáčik <[email protected]> +Reviewed-by: Jakub Jelen <[email protected]> + +CVE: CVE-2026-59844 +Upstream-Status: Backport [https://git.libssh.org/projects/libssh.git/commit/?id=e31f06e5380be4e714d5ad6965981fbf30738da9] + +Backport Changes: +- Replace the upstream goto error path with equivalent direct message cleanup + and return because libssh 0.10.6 does not have the refactored + sftp_make_client_message() error label. + +(cherry picked from commit 6dba2e06f0713c04ad5eca7d4315d0104be7e627) +(cherry picked from commit e31f06e5380be4e714d5ad6965981fbf30738da9) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + src/sftpserver.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/sftpserver.c b/src/sftpserver.c +index 528ef6f9..77290068 100644 +--- a/src/sftpserver.c ++++ b/src/sftpserver.c +@@ -105,6 +105,13 @@ sftp_client_message sftp_get_client_message(sftp_session sftp) { + sftp_client_message_free(msg); + return NULL; + } ++ if (msg->len > MAX_PACKET_LEN - 1024) { ++ ssh_set_error(sftp->session, SSH_FATAL, ++ "Too large SSH_FXP_READ length: %" PRIu32, ++ msg->len); ++ sftp_client_message_free(msg); ++ return NULL; ++ } + break; + case SSH_FXP_WRITE: + rc = ssh_buffer_unpack(payload,
meta-oe/recipes-support/libssh/libssh_0.10.6.bb +1 -0
@@ -33,6 +33,7 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable file://CVE-2026-0967.patch \ file://CVE-2026-0965.patch \ file://CVE-2026-59843.patch \ + file://CVE-2026-59844.patch \ " SRCREV = "10e09e273f69e149389b3e0e5d44b8c221c2e7f6"
Signature · 1 line
2.35.6
PATCH v2 3/5 libssh: Fix CVE-2026-59846
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
libssh 0.10.6 predates the username-validation helper used by the stable-0.11 fix, so the upstream commit in [1] cannot be applied as-is. Adapt the same dangerous-character check directly at the ProxyCommand %r expansion sink and add focused regression coverage.
The upstream advisory [2] identifies libssh 0.11.5 and 0.12.1 as the fixed releases.
[1] https://gitlab.com/libssh/libssh-mirror/-/commit/56ce3c193eb06af5bf3b07ec0b4c7308b5c72130
[2] https://www.libssh.org/security/advisories/CVE-2026-59846.txt
---
Changes in v2
- rebase the patch on the current scarthgap branch
--- .../libssh/libssh/CVE-2026-59846.patch | 87 +++++++++++++++++++ .../recipes-support/libssh/libssh_0.10.6.bb | 1 + 2 files changed, 88 insertions(+) create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59846.patch
meta-oe/recipes-support/libssh/libssh/CVE-2026-59846.patch new file +87 -0
@@ -0,0 +1,87 @@ +From 19fe4c9fc7b3bd3553250bf9ddea03ed1dcf044f Mon Sep 17 00:00:00 2001 +From: Jakub Jelen <[email protected]> +Date: Thu, 2 Apr 2026 15:39:25 +0200 +Subject: [PATCH] CVE-2026-59846 Block shell metacharacters from usernames +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When an attacker could sneak the dollar sign or backslash into the username +expanded for example in proxy command, it can result in printing environment +variables that might contain secrets. + +This is a fixup of CVE-2023-6004 which fixed this for hostnames, but these +two metacharacters were left out from the username filter. + +This keeps the list in one place to simplify maintenance. + +Signed-off-by: Jakub Jelen <[email protected]> +Reviewed-by: Pavol Žáčik <[email protected]> +(cherry picked from commit 6309df220e3431deb41946f892f4bb5af8b59dba) + +CVE: CVE-2026-59846 +Upstream-Status: Backport [https://git.libssh.org/projects/libssh.git/commit/?id=56ce3c193eb06af5bf3b07ec0b4c7308b5c72130] + +Backport Changes: +- libssh 0.10.6 predates ssh_check_username_syntax() and the centralized + SSH_DANGEROUS_SHELL_CHARS definition, so enforce the same character list + directly at the %r expansion sink in ssh_path_expand_escape(). +- Add focused regression coverage to the existing path-expansion unit test + for dollar-sign, backslash, and command-separator usernames. + +(cherry picked from commit 56ce3c193eb06af5bf3b07ec0b4c7308b5c72130) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + src/misc.c | 9 +++++++++ + tests/unittests/torture_misc.c | 18 ++++++++++++++++++ + 2 files changed, 27 insertions(+) + +diff --git a/src/misc.c b/src/misc.c +index e78c92ba..15b427d7 100644 +--- a/src/misc.c ++++ b/src/misc.c +@@ -1262,6 +1262,15 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) + break; + case 'r': + if (session->opts.username) { ++ if (strpbrk(session->opts.username, ++ "'`\";&<>|(){}$\\,") != NULL) { ++ ssh_set_error(session, ++ SSH_FATAL, ++ "Invalid shell metacharacter in username"); ++ free(buf); ++ free(r); ++ return NULL; ++ } + x = strdup(session->opts.username); + } else { + ssh_set_error(session, SSH_FATAL, +diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c +index 82d6cf16..66d392ed 100644 +--- a/tests/unittests/torture_misc.c ++++ b/tests/unittests/torture_misc.c +@@ -194,6 +194,24 @@ static void torture_path_expand_escape(void **state) { + assert_non_null(e); + assert_string_equal(e, "guru/meditation/222/by/root"); + ssh_string_free_char(e); ++ ++ free(session->opts.username); ++ session->opts.username = strdup("root$HOME"); ++ assert_non_null(session->opts.username); ++ e = ssh_path_expand_escape(session, s); ++ assert_null(e); ++ ++ free(session->opts.username); ++ session->opts.username = strdup("root\\user"); ++ assert_non_null(session->opts.username); ++ e = ssh_path_expand_escape(session, s); ++ assert_null(e); ++ ++ free(session->opts.username); ++ session->opts.username = strdup("root;id"); ++ assert_non_null(session->opts.username); ++ e = ssh_path_expand_escape(session, s); ++ assert_null(e); + } + + static void torture_path_expand_known_hosts(void **state) {
meta-oe/recipes-support/libssh/libssh_0.10.6.bb +1 -0
@@ -34,6 +34,7 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable file://CVE-2026-0965.patch \ file://CVE-2026-59843.patch \ file://CVE-2026-59844.patch \ + file://CVE-2026-59846.patch \ " SRCREV = "10e09e273f69e149389b3e0e5d44b8c221c2e7f6"
Signature · 1 line
2.35.6
PATCH v2 4/5 libssh: Fix CVE-2026-59848
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
The stable-0.11 commit shown in [1] is the primary upstream fix selected for this backport. Commit [2] corrects the request-queue pointer state introduced by [1], so it is carried immediately afterward as a regression fix. The upstream advisory [3] documents CVE-2026-59848 and identifies libssh 0.11.5 as the fixed release for the 0.11 series.
[1] https://git.libssh.org/projects/libssh.git/commit/?id=a30a51003205744c10ba4439306f555206ae8497
[2] https://git.libssh.org/projects/libssh.git/commit/?id=5309aefd99e1775db40bf20869f1fb1cc6c787be
[3] https://www.libssh.org/security/advisories/CVE-2026-59848.txt
---
Changes in v2
- rebase the patch on the current scarthgap branch
--- .../libssh/CVE-2026-59848-regression.patch | 45 ++ .../libssh/libssh/CVE-2026-59848.patch | 684 ++++++++++++++++++ .../recipes-support/libssh/libssh_0.10.6.bb | 2 + 3 files changed, 731 insertions(+) create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59848-regression.patch create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59848.patch
meta-oe/recipes-support/libssh/libssh/CVE-2026-59848-regression.patch new file +45 -0
@@ -0,0 +1,45 @@ +From dddd93ac995ac382e4ec9496509f24003bd72c30 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Pavol=20=C5=BD=C3=A1=C4=8Dik?= <[email protected]> +Date: Wed, 3 Jun 2026 12:56:09 +0200 +Subject: [PATCH] CVE-2026-59848 sftp: Initialize sftp_request_queue ptr in + sftp_free +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Pavol Žáčik <[email protected]> +Reviewed-by: Jakub Jelen <[email protected]> + +CVE: CVE-2026-59848 +Upstream-Status: Backport [https://git.libssh.org/projects/libssh.git/commit/?id=5309aefd99e1775db40bf20869f1fb1cc6c787be] + +Backport Changes: +- Adjusted hunk context for the consolidated libssh 0.10.6 SFTP + implementation; the pointer initialization is unchanged from upstream. +- Omitted the upstream tests/client/torture_sftp_request_id.c follow-up hunk + because CVE-2026-59848.patch introduces the backported regression test + directly with sftp_read_and_dispatch(); there is no intermediate + sftp_recv_response_msg() version to update. + +(cherry picked from commit 00876f7658fd265682708572122502188fa22076) +(cherry picked from commit 5309aefd99e1775db40bf20869f1fb1cc6c787be) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + src/sftp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sftp.c b/src/sftp.c +index e6755e2b..ff6e5200 100644 +--- a/src/sftp.c ++++ b/src/sftp.c +@@ -371,7 +371,7 @@ void sftp_server_free(sftp_session sftp) + + void sftp_free(sftp_session sftp) + { +- sftp_request_queue ptr; ++ sftp_request_queue ptr = NULL; + struct ssh_iterator *id_it = NULL; + + if (sftp == NULL) { +-- +2.35.6
meta-oe/recipes-support/libssh/libssh/CVE-2026-59848.patch new file +684 -0
684 lines not on this page · raw message
meta-oe/recipes-support/libssh/libssh_0.10.6.bb +2 -0
@@ -35,6 +35,8 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable file://CVE-2026-59843.patch \ file://CVE-2026-59844.patch \ file://CVE-2026-59846.patch \ + file://CVE-2026-59848.patch \ + file://CVE-2026-59848-regression.patch \ " SRCREV = "10e09e273f69e149389b3e0e5d44b8c221c2e7f6"
Signature · 1 line
2.35.6
PATCH v2 5/5 libssh: Fix CVE-2026-59850
In reply to Hetvi Thakar -X (hthakar - E INFOCHIPS PRIVATE LIMITED at Cisco)From: Hetvi Thakar <[email protected]>
The stable-0.11 commit shown in [1] is the upstream fix selected for this backport. The upstream advisory [2] documents CVE-2026-59850 and identifies libssh 0.11.5 as the fixed release for the 0.11 series.
[1] https://git.libssh.org/projects/libssh.git/commit/?id=6edfb52b3b364577d2db0334c0514a977efceed2
[2] https://www.libssh.org/security/advisories/CVE-2026-59850.txt
--- .../libssh/libssh/CVE-2026-59850.patch | 40 +++++++++++++++++++ .../recipes-support/libssh/libssh_0.10.6.bb | 1 + 2 files changed, 41 insertions(+) create mode 100644 meta-oe/recipes-support/libssh/libssh/CVE-2026-59850.patch
meta-oe/recipes-support/libssh/libssh/CVE-2026-59850.patch new file +40 -0
@@ -0,0 +1,40 @@ +From a207ee3b4244c0e5da902245f8b81f3617b416f3 Mon Sep 17 00:00:00 2001 +From: Jakub Jelen <[email protected]> +Date: Wed, 1 Jul 2026 16:43:08 +0200 +Subject: [PATCH] CVE-2026-59850 channels: Avoid processing DATA packets on + closed channels +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Jakub Jelen <[email protected]> +Reviewed-by: Pavol Žáčik <[email protected]> + +CVE: CVE-2026-59850 +Upstream-Status: Backport [https://git.libssh.org/projects/libssh.git/commit/?id=6edfb52b3b364577d2db0334c0514a977efceed2] + +(cherry picked from commit a8a3fa352bb5213e08a35e4494c6e44360e2e38a) +(cherry picked from commit 6edfb52b3b364577d2db0334c0514a977efceed2) +Signed-off-by: Hetvi Thakar <[email protected]> +--- + src/channels.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/channels.c b/src/channels.c +index 3afdcf11..1543c792 100644 +--- a/src/channels.c ++++ b/src/channels.c +@@ -575,6 +575,13 @@ SSH_PACKET_CALLBACK(channel_rcv_data){ + channel->local_window, + channel->remote_window); + ++ if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) { ++ SSH_LOG(SSH_LOG_WARNING, "Received data on (remotely) closed channel"); ++ ssh_set_error(session, SSH_FATAL, "Received data on (remotely) closed channel"); ++ SSH_STRING_FREE(str); ++ return SSH_PACKET_USED; ++ } ++ + /* What shall we do in this case? Let's accept it anyway */ + if (len > channel->local_window) { + SSH_LOG(SSH_LOG_RARE,
meta-oe/recipes-support/libssh/libssh_0.10.6.bb +1 -0
@@ -37,6 +37,7 @@ SRC_URI = "git://git.libssh.org/projects/libssh.git;protocol=https;branch=stable file://CVE-2026-59846.patch \ file://CVE-2026-59848.patch \ file://CVE-2026-59848-regression.patch \ + file://CVE-2026-59850.patch \ " SRCREV = "10e09e273f69e149389b3e0e5d44b8c221c2e7f6"
Signature · 1 line
2.35.6