package/libssh2: fix five security vulnerabilities
v2 cover package/libssh2: fix five security vulnerabilities
From: Stefan Müller <[email protected]>
This series backports upstream fixes for five security vulnerabilities in libssh2.
Changes v1 -> v2:
- Resend using a different SMTP provider because O365/Exchange converted the original patch emails to HTML.
- No code changes.
Stefan Müller (5):
package/libssh2: fix CVE-2025-15661
package/libssh2: fix CVE-2026-66032
package/libssh2: fix CVE-2026-66033
package/libssh2: fix CVE-2026-66034
package/libssh2: fix CVE-2026-66035
...-sftp-symlink-fix-out-of-bounds-read.patch | 116 ++++++++++++++++++ ...ibssh2-priv-backport-LIBSSH2_UNCONST.patch | 29 +++++ ...-symlink-fix-SSH_FXP_STATUS-response.patch | 46 +++++++ ...-prevent-dangling-pointer-after-free.patch | 28 +++++ ...08-openssl-fix-AES-GCM-bounds-checks.patch | 44 +++++++ ...009-publickey-fix-potential-OOB-read.patch | 35 ++++++ ...tential-heap-overflow-on-ETM-decrypt.patch | 41 +++++++ package/libssh2/libssh2.mk | 17 +++ 8 files changed, 356 insertions(+) create mode 100644 package/libssh2/0004-sftp-symlink-fix-out-of-bounds-read.patch create mode 100644 package/libssh2/0005-libssh2-priv-backport-LIBSSH2_UNCONST.patch create mode 100644 package/libssh2/0006-sftp-symlink-fix-SSH_FXP_STATUS-response.patch create mode 100644 package/libssh2/0007-sftp-prevent-dangling-pointer-after-free.patch create mode 100644 package/libssh2/0008-openssl-fix-AES-GCM-bounds-checks.patch create mode 100644 package/libssh2/0009-publickey-fix-potential-OOB-read.patch create mode 100644 package/libssh2/0010-transport-fix-potential-heap-overflow-on-ETM-decrypt.patch
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/5 package/libssh2: fix CVE-2025-15661
From: Stefan Müller <[email protected]>
Backport the SFTP symlink bounds checking fix for CVE-2025-15661.
The initial fix requires the LIBSSH2_UNCONST compatibility backport on libssh2 1.11.1. Also include the upstream follow-up fixing SSH_FXP_STATUS handling introduced by the initial security fix.
The patches are based on the upstream fixes and Debian's libssh2 1.11.1 backports.
---
Backport to: 2025.02.x
--- ...-sftp-symlink-fix-out-of-bounds-read.patch | 116 ++++++++++++++++++ ...ibssh2-priv-backport-LIBSSH2_UNCONST.patch | 29 +++++ ...-symlink-fix-SSH_FXP_STATUS-response.patch | 46 +++++++ package/libssh2/libssh2.mk | 5 + 4 files changed, 196 insertions(+) create mode 100644 package/libssh2/0004-sftp-symlink-fix-out-of-bounds-read.patch create mode 100644 package/libssh2/0005-libssh2-priv-backport-LIBSSH2_UNCONST.patch create mode 100644 package/libssh2/0006-sftp-symlink-fix-SSH_FXP_STATUS-response.patch
package/libssh2/0004-sftp-symlink-fix-out-of-bounds-read.patch new file +116 -0
@@ -0,0 +1,116 @@ +From 2dae3024897e1898d389835151f4e9606227721d Mon Sep 17 00:00:00 2001 +From: Will Cosgrove <[email protected]> +Date: Fri, 10 Oct 2025 08:26:20 -0700 +Subject: [PATCH] Update sftp_symlink to avoid out of bounds read on malformed + packet #1705 (#1717) + + +CVE: CVE-2025-15661 +Upstream: https://github.com/libssh2/libssh2/commit/2dae3024897e1898d389835151f4e9606227721d +Signed-off-by: Stefan Müller <[email protected]> +--- +--- libssh2-1.11.1.orig/src/sftp.c ++++ libssh2-1.11.1/src/sftp.c +@@ -3795,15 +3795,19 @@ static int sftp_symlink(LIBSSH2_SFTP *sf + { + LIBSSH2_CHANNEL *channel = sftp->channel; + LIBSSH2_SESSION *session = channel->session; +- size_t data_len = 0, link_len; ++ size_t data_len = 0, lk_len; + /* 13 = packet_len(4) + packet_type(1) + request_id(4) + path_len(4) */ + ssize_t packet_len = + path_len + 13 + + ((link_type == LIBSSH2_SFTP_SYMLINK) ? (4 + target_len) : 0); + unsigned char *s, *data = NULL; ++ struct string_buf buf; + static const unsigned char link_responses[2] = + { SSH_FXP_NAME, SSH_FXP_STATUS }; + int retcode; ++ unsigned char packet_type; ++ uint32_t tmp_u32; ++ unsigned char *lk_target; + + if(sftp->symlink_state == libssh2_NB_state_idle) { + sftp->last_errno = LIBSSH2_FX_OK; +@@ -3891,8 +3895,25 @@ static int sftp_symlink(LIBSSH2_SFTP *sf + + sftp->symlink_state = libssh2_NB_state_idle; + +- if(data[0] == SSH_FXP_STATUS) { +- retcode = _libssh2_ntohu32(data + 5); ++ buf.data = (unsigned char *)LIBSSH2_UNCONST(data); ++ buf.dataptr = buf.data; ++ buf.len = data_len; ++ ++ if(_libssh2_get_byte(&buf, &packet_type)) { ++ LIBSSH2_FREE(session, data); ++ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, ++ "SFTP Protocol Error (type)"); ++ } ++ ++ if(packet_type == SSH_FXP_STATUS) { ++ if(_libssh2_get_u32(&buf, &tmp_u32)) { ++ LIBSSH2_FREE(session, data); ++ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, ++ "SFTP Protocol Error (code)"); ++ } ++ ++ retcode = (int)tmp_u32; ++ + LIBSSH2_FREE(session, data); + if(retcode == LIBSSH2_FX_OK) + return LIBSSH2_ERROR_NONE; +@@ -3903,30 +3924,37 @@ static int sftp_symlink(LIBSSH2_SFTP *sf + } + } + +- if(_libssh2_ntohu32(data + 5) < 1) { ++ /* advance past id */ ++ if(_libssh2_get_u32(&buf, &tmp_u32)) { + LIBSSH2_FREE(session, data); + return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, +- "Invalid READLINK/REALPATH response, " +- "no name entries"); ++ "SFTP Protocol Error (id)"); + } + +- if(data_len < 13) { +- if(data_len > 0) { +- LIBSSH2_FREE(session, data); +- } ++ /* look for at least one link */ ++ if(_libssh2_get_u32(&buf, &tmp_u32) || tmp_u32 < 1) { ++ LIBSSH2_FREE(session, data); + return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, +- "SFTP stat packet too short"); ++ "Invalid READLINK/REALPATH response, " ++ "no name entries"); + } + +- /* this reads a u32 and stores it into a signed 32bit value */ +- link_len = _libssh2_ntohu32(data + 9); +- if(link_len < target_len) { +- memcpy(target, data + 13, link_len); +- target[link_len] = 0; +- retcode = (int)link_len; ++ if(_libssh2_get_string(&buf, &lk_target, &lk_len) == LIBSSH2_ERROR_NONE) { ++ if(lk_len < target_len) { ++ memcpy(target, lk_target, lk_len); ++ target[lk_len] = '\0'; ++ retcode = (int)lk_len; ++ } ++ else { ++ retcode = LIBSSH2_ERROR_BUFFER_TOO_SMALL; ++ } + } +- else +- retcode = LIBSSH2_ERROR_BUFFER_TOO_SMALL; ++ else { ++ LIBSSH2_FREE(session, data); ++ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, ++ "SFTP Protocol Error (filename)"); ++ } ++ + LIBSSH2_FREE(session, data); + + return retcode;
package/libssh2/0005-libssh2-priv-backport-LIBSSH2_UNCONST.patch new file +29 -0
@@ -0,0 +1,29 @@ +Needed by the fix for CVE-2025-15661 + +Cherrypicked from +commit 606c102e52f8447de2b745dd6c5ddf418defc519 +Author: Viktor Szakats <[email protected]> +Date: Thu Jan 30 21:18:23 2025 +0100 + + +CVE: CVE-2025-15661 +Upstream: https://github.com/libssh2/libssh2/commit/606c102e52f8447de2b745dd6c5ddf418defc519 +Signed-off-by: Stefan Müller <[email protected]> +--- +--- libssh2-1.11.1.orig/src/libssh2_priv.h ++++ libssh2-1.11.1/src/libssh2_priv.h +@@ -117,6 +117,14 @@ + #define UINT32_MAX 0xffffffffU + #endif + ++#ifdef _WIN64 ++#define LIBSSH2_UNCONST(p) ((void *)(libssh2_uint64_t)(const void *)(p)) ++#elif defined(_MSC_VER) ++#define LIBSSH2_UNCONST(p) ((void *)(unsigned int)(const void *)(p)) ++#else ++#define LIBSSH2_UNCONST(p) ((void *)(uintptr_t)(const void *)(p)) ++#endif ++ + #if (defined(__GNUC__) || defined(__clang__)) && \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(LIBSSH2_NO_FMT_CHECKS)
package/libssh2/0006-sftp-symlink-fix-SSH_FXP_STATUS-response.patch new file +46 -0
46 lines not on this page · raw message
package/libssh2/libssh2.mk +5 -0
@@ -22,6 +22,11 @@ LIBSSH2_IGNORE_CVES += CVE-2026-55199 # 0003-transport-c-Additional-boundary-checks-for-packet-length.patch LIBSSH2_IGNORE_CVES += CVE-2026-55200 +# 0004-sftp-symlink-fix-out-of-bounds-read.patch +# 0005-libssh2-priv-backport-LIBSSH2_UNCONST.patch +# 0006-sftp-symlink-fix-SSH_FXP_STATUS-response.patch +LIBSSH2_IGNORE_CVES += CVE-2025-15661 + ifeq ($(BR2_PACKAGE_LIBSSH2_MBEDTLS),y) LIBSSH2_DEPENDENCIES += mbedtls LIBSSH2_CONF_OPTS += --with-libmbedcrypto-prefix=$(STAGING_DIR)/usr \
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/5] package/libssh2: fix CVE-2025-15661
Quoted 4 lines · Stefan Mueller via buildroot
From: Stefan Müller <[email protected]>
Backport the SFTP symlink bounds checking fix for CVE-2025-15661.
Quoted 8 lines
The initial fix requires the
LIBSSH2_UNCONSTcompatibility backport on libssh2 1.11.1. Also include the upstream follow-up fixingSSH_FXP_STATUShandling introduced by the initial security fix.The patches are based on the upstream fixes and Debian's libssh2 1.11.1 backports.
Signed-off-by Stefan Müller <[email protected]>
Series applied to master, thanks.
I also added links to the Debian patches, for better transparency and traceability.
Best regards,
Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 2/5 package/libssh2: fix CVE-2026-66032
In reply to Stefan Mueller via buildrootFrom: Stefan Müller <[email protected]>
Backport the fix for CVE-2026-66032.
A SFTP error path can leave a dangling pointer after freeing the response buffer, which may result in a double free on subsequent error handling.
Use Debian's libssh2 1.11.1 backport of the upstream fix.
---
Backport to: 2025.02.x
--- ...-prevent-dangling-pointer-after-free.patch | 28 +++++++++++++++++++ package/libssh2/libssh2.mk | 3 ++ 2 files changed, 31 insertions(+) create mode 100644 package/libssh2/0007-sftp-prevent-dangling-pointer-after-free.patch
package/libssh2/0007-sftp-prevent-dangling-pointer-after-free.patch new file +28 -0
@@ -0,0 +1,28 @@ +From 5e4776146552d898b9c0e1b313cd093fa8dc92d0 Mon Sep 17 00:00:00 2001 +From: Will Cosgrove <[email protected]> +Date: Thu, 2 Jul 2026 11:00:23 -0700 +Subject: [PATCH] Prevent dangling pointer by nullifying data (#2180) + +Set data to NULL after freeing it to avoid dangling pointer. fixes +GHSA-px3w-7g75-hg7w. + +Credit: VladimirEliTokarev +Forwarded: not-needed + +CVE: CVE-2026-66032 +Upstream: https://github.com/libssh2/libssh2/commit/5e4776146552d898b9c0e1b313cd093fa8dc92d0 +Signed-off-by: Stefan Müller <[email protected]> +--- + src/sftp.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/src/sftp.c ++++ b/src/sftp.c +@@ -1279,6 +1279,7 @@ + "got HANDLE FXOK")); + + LIBSSH2_FREE(session, data); ++ data = NULL; + + /* silly situation, but check for a HANDLE */ + rc = sftp_packet_require(sftp, SSH_FXP_HANDLE,
package/libssh2/libssh2.mk +3 -0
@@ -27,6 +27,9 @@ LIBSSH2_IGNORE_CVES += CVE-2026-55200 # 0006-sftp-symlink-fix-SSH_FXP_STATUS-response.patch LIBSSH2_IGNORE_CVES += CVE-2025-15661 +# 0007-sftp-prevent-dangling-pointer-after-free.patch +LIBSSH2_IGNORE_CVES += CVE-2026-66032 + ifeq ($(BR2_PACKAGE_LIBSSH2_MBEDTLS),y) LIBSSH2_DEPENDENCIES += mbedtls LIBSSH2_CONF_OPTS += --with-libmbedcrypto-prefix=$(STAGING_DIR)/usr \
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 3/5 package/libssh2: fix CVE-2026-66033
In reply to Stefan Mueller via buildrootFrom: Stefan Müller <[email protected]>
Backport the fix for CVE-2026-66033.
The OpenSSL AES-GCM cipher path lacks runtime bounds checks around the input block size. A malformed packet can therefore lead to an out-of-bounds read or write.
Use Debian's libssh2 1.11.1 backport of the upstream fix.
---
Backport to: 2025.02.x
--- ...08-openssl-fix-AES-GCM-bounds-checks.patch | 44 +++++++++++++++++++ package/libssh2/libssh2.mk | 3 ++ 2 files changed, 47 insertions(+) create mode 100644 package/libssh2/0008-openssl-fix-AES-GCM-bounds-checks.patch
package/libssh2/0008-openssl-fix-AES-GCM-bounds-checks.patch new file +44 -0
@@ -0,0 +1,44 @@ +From a2ed82d40964bbc0d64cd717aa0a5a892117d2e6 Mon Sep 17 00:00:00 2001 +From: Viktor Szakats <[email protected]> +Date: Thu, 23 Jul 2026 10:32:04 +0200 +Subject: [PATCH] openssl: fix potential OOB read/write with AES-GCM in + `ssh2_cipher_crypt()` + +By applying two bounds checks to non-debug builds. + +Reported-by: Vladimir Eli Tokarev +Fixes GHSA-c4f7-cvfc-33j7 +Follow-up to 3c953c05d67eb1ebcfd3316f279f12c4b1d600b4 #797 + +Closes #2401 +Forwarded: not-needed + +CVE: CVE-2026-66033 +Upstream: https://github.com/libssh2/libssh2/commit/a2ed82d40964bbc0d64cd717aa0a5a892117d2e6 +Signed-off-by: Stefan Müller <[email protected]> +--- + src/openssl.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +--- a/src/openssl.c ++++ b/src/openssl.c +@@ -1042,13 +1042,15 @@ + const int aadlen = (is_aesgcm && IS_FIRST(firstlast)) ? 4 : 0; + /* size of AT, if present */ + const int authenticationtag = IS_LAST(firstlast) ? authlen : 0; +- /* length to encrypt */ +- const int cryptlen = (unsigned int)blocksize - aadlen - authenticationtag; ++ unsigned int cryptlen; /* length to encrypt */ + + (void)algo; + +- assert(blocksize <= sizeof(buf)); +- assert(cryptlen >= 0); ++ if(blocksize > sizeof(buf) || ++ blocksize < (size_t)(aadlen + authenticationtag)) ++ return 1; ++ ++ cryptlen = (unsigned int)blocksize - aadlen - authenticationtag; + + #if LIBSSH2_AES_GCM + /* First block */
package/libssh2/libssh2.mk +3 -0
@@ -30,6 +30,9 @@ LIBSSH2_IGNORE_CVES += CVE-2025-15661 # 0007-sftp-prevent-dangling-pointer-after-free.patch LIBSSH2_IGNORE_CVES += CVE-2026-66032 +# 0008-openssl-fix-AES-GCM-bounds-checks.patch +LIBSSH2_IGNORE_CVES += CVE-2026-66033 + ifeq ($(BR2_PACKAGE_LIBSSH2_MBEDTLS),y) LIBSSH2_DEPENDENCIES += mbedtls LIBSSH2_CONF_OPTS += --with-libmbedcrypto-prefix=$(STAGING_DIR)/usr \
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 4/5 package/libssh2: fix CVE-2026-66034
In reply to Stefan Mueller via buildrootFrom: Stefan Müller <[email protected]>
Backport the fix for CVE-2026-66034.
The publickey subsystem does not sufficiently validate the length of a server-controlled comment field. A malformed response can therefore cause an out-of-bounds read.
Use Debian's libssh2 1.11.1 backport of the upstream fix.
---
Backport to: 2025.02.x
--- ...009-publickey-fix-potential-OOB-read.patch | 35 +++++++++++++++++++ package/libssh2/libssh2.mk | 3 ++ 2 files changed, 38 insertions(+) create mode 100644 package/libssh2/0009-publickey-fix-potential-OOB-read.patch
package/libssh2/0009-publickey-fix-potential-OOB-read.patch new file +35 -0
@@ -0,0 +1,35 @@ +From a13bb6c773f0d55ad1628cede57e99803cd898d9 Mon Sep 17 00:00:00 2001 +From: Viktor Szakats <[email protected]> +Date: Sat, 4 Jul 2026 11:19:49 +0200 +Subject: [PATCH] publickey: fix potential OOB read in + `libssh2_publickey_list_fetch()` + +Reported-by: Vladimir Eli Tokarev +Fixes GHSA-w6g9-cpfp-22gc + +Closes #2202 +Forwarded: not-needed + +CVE: CVE-2026-66034 +Upstream: https://github.com/libssh2/libssh2/commit/a13bb6c773f0d55ad1628cede57e99803cd898d9 +Signed-off-by: Stefan Müller <[email protected]> +--- + src/publickey.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/src/publickey.c ++++ b/src/publickey.c +@@ -988,6 +988,13 @@ + } + + if(comment_len) { ++ if(pkey->listFetch_s + comment_len > ++ pkey->listFetch_data + pkey->listFetch_data_len) { ++ _libssh2_error(session, LIBSSH2_ERROR_BUFFER_TOO_SMALL, ++ "ListFetch data too short"); ++ goto err_exit; ++ } ++ + list[keys].num_attrs = 1; + list[keys].attrs = + LIBSSH2_ALLOC(session,
package/libssh2/libssh2.mk +3 -0
@@ -33,6 +33,9 @@ LIBSSH2_IGNORE_CVES += CVE-2026-66032 # 0008-openssl-fix-AES-GCM-bounds-checks.patch LIBSSH2_IGNORE_CVES += CVE-2026-66033 +# 0009-publickey-fix-potential-OOB-read.patch +LIBSSH2_IGNORE_CVES += CVE-2026-66034 + ifeq ($(BR2_PACKAGE_LIBSSH2_MBEDTLS),y) LIBSSH2_DEPENDENCIES += mbedtls LIBSSH2_CONF_OPTS += --with-libmbedcrypto-prefix=$(STAGING_DIR)/usr \
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 5/5 package/libssh2: fix CVE-2026-66035
In reply to Stefan Mueller via buildrootFrom: Stefan Müller <[email protected]>
Backport the fix for CVE-2026-66035.
The ETM decrypt path does not validate the received packet length before calculating the decrypt buffer size. A malformed packet can therefore lead to a heap overflow.
Use Debian's libssh2 1.11.1 backport of the upstream fix.
---
Backport to: 2025.02.x
--- ...tential-heap-overflow-on-ETM-decrypt.patch | 41 +++++++++++++++++++ package/libssh2/libssh2.mk | 3 ++ 2 files changed, 44 insertions(+) create mode 100644 package/libssh2/0010-transport-fix-potential-heap-overflow-on-ETM-decrypt.patch
package/libssh2/0010-transport-fix-potential-heap-overflow-on-ETM-decrypt.patch new file +41 -0
@@ -0,0 +1,41 @@ +From 42e33d81577ed4b95d4b4f6f845e5ee8efe5eeb4 Mon Sep 17 00:00:00 2001 +From: Viktor Szakats <[email protected]> +Date: Fri, 3 Jul 2026 18:22:55 +0200 +Subject: [PATCH] transport: fix potential heap overflow on ETM decrypt + +Reported-by: Vladimir Eli Tokarev +Fixes GHSA-6c79-444r-wx26 + +Closes #2198 +Forwarded: not-needed + +CVE: CVE-2026-66035 +Upstream: https://github.com/libssh2/libssh2/commit/42e33d81577ed4b95d4b4f6f845e5ee8efe5eeb4 +Signed-off-by: Stefan Müller <[email protected]> +--- + src/transport.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +--- a/src/transport.c ++++ b/src/transport.c +@@ -242,6 +242,12 @@ + unsigned char *decrypt_buffer; + int blocksize = session->remote.crypt->blocksize; + ++ if(p->total_num < mac_len + 4 + (size_t)blocksize) { ++ LIBSSH2_FREE(session, p->payload); ++ return LIBSSH2_ERROR_DECRYPT; ++ } ++ decrypt_size = (ssize_t)(p->total_num - mac_len - 4); ++ + rc = decrypt(session, p->payload + 4, + first_block, blocksize, FIRST_BLOCK); + if(rc) { +@@ -249,7 +255,6 @@ + } + + /* we need buffer for decrypt */ +- decrypt_size = p->total_num - mac_len - 4; + decrypt_buffer = LIBSSH2_ALLOC(session, decrypt_size); + if(!decrypt_buffer) { + return LIBSSH2_ERROR_ALLOC;
package/libssh2/libssh2.mk +3 -0
@@ -36,6 +36,9 @@ LIBSSH2_IGNORE_CVES += CVE-2026-66033 # 0009-publickey-fix-potential-OOB-read.patch LIBSSH2_IGNORE_CVES += CVE-2026-66034 +# 0010-transport-fix-potential-heap-overflow-on-ETM-decrypt.patch +LIBSSH2_IGNORE_CVES += CVE-2026-66035 + ifeq ($(BR2_PACKAGE_LIBSSH2_MBEDTLS),y) LIBSSH2_DEPENDENCIES += mbedtls LIBSSH2_CONF_OPTS += --with-libmbedcrypto-prefix=$(STAGING_DIR)/usr \
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot