Skip to content

Commit 4bda3f2

Browse files
committed
build(ssh): patch libssh2 against CVE-2026-55200
1 parent 6bc532e commit 4bda3f2

5 files changed

Lines changed: 71 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Cancel now stops a connection attempt right away instead of letting it run on in the background. A cancelled connection is also dropped from the last session, so restarting no longer reconnects to a host you gave up on, and it can no longer interrupt a later successful connection. (#1358)
1515
- Fixed a crash when clicking a column header on a table whose columns have comments. Sorting such a table quit the app immediately. (#1869)
1616

17+
### Security
18+
19+
- Patched CVE-2026-55200 in libssh2, a critical out-of-bounds write that let a malicious SSH server corrupt memory and run code before authentication finished. It affected every SSH tunnel and jump host.
20+
1721
## [0.57.0] - 2026-07-14
1822

1923
### Added

Libs/checksums.sha256

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ efba529b1ad767de988a58ca2c3fdcc26c38ce79df044a988f41fddbf9fde118 Libs/libpgport
4242
b86ecf68d2b0dd8aa7712d13607c9584df2297aca4cd651428e8ee974c6bdf80 Libs/libpq_universal.a
4343
1ce2b45af228915fad05e07f54e96621af7143e199e002e5100777261a7f4a13 Libs/libpq_x86_64.a
4444
b86ecf68d2b0dd8aa7712d13607c9584df2297aca4cd651428e8ee974c6bdf80 Libs/libpq.a
45-
166e0e23ce60fd2edcae38b6005de106394f7e2bc922a4944317d6aa576f284c Libs/libssh2_arm64.a
46-
445b51e6fdaa0a0eceb8090e6d552a551ec15d91e4370a4cc356c8f561e8b469 Libs/libssh2_universal.a
47-
76681299c4305273cea62e59cfa366ceb5cc320831b87fd6a06143d342f8b7db Libs/libssh2_x86_64.a
48-
445b51e6fdaa0a0eceb8090e6d552a551ec15d91e4370a4cc356c8f561e8b469 Libs/libssh2.a
45+
6d737d744b5a2494bca0eee9091166d7e15912a3eca5aa0f74644393cc2ce087 Libs/libssh2_arm64.a
46+
c6e3dbcb3d79d740a8bcab355ae10389a39d99e0c8594528202d0eb8c78a5e18 Libs/libssh2_universal.a
47+
bd4dab1e2b24fa695bad8c951d5a2c3271c4c4436f0651f276c09899126fe088 Libs/libssh2_x86_64.a
48+
c6e3dbcb3d79d740a8bcab355ae10389a39d99e0c8594528202d0eb8c78a5e18 Libs/libssh2.a
4949
b3861975896ebf35255d8c3efccdc59ad39874c9b70fdd710ebd15f0a58c4e10 Libs/libssl_arm64.a
5050
3ca208dedf57dbae4f5cb0a22bfbedeba80dc6740d626484d9d815811d64a2aa Libs/libssl_universal.a
5151
34de647ccd0951095f987591562a5236348bac2d4b3e217877559a7b170cf4e4 Libs/libssl_x86_64.a

scripts/build-libssh2.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ build_openssl() {
111111
echo "✅ OpenSSL $arch: $(ls -lh "$prefix/lib/libssl.a" | awk '{print $5}') (libssl) $(ls -lh "$prefix/lib/libcrypto.a" | awk '{print $5}') (libcrypto)"
112112
}
113113

114+
# libssh2 1.11.1 is the newest release and is still vulnerable to CVE-2026-55200 (CVSS 9.2):
115+
# ssh2_transport_read() enforces no upper bound on packet_length, so a malicious server can
116+
# overflow the heap before authentication. Upstream fixed it in 97acf3df with no release cut
117+
# since, so the fix rides as a patch on top of the pinned release tarball. Drop the patch once
118+
# a release contains it.
119+
apply_patches() {
120+
local source_dir=$1
121+
local patch_dir="$SCRIPT_DIR/patches"
122+
123+
[ -d "$patch_dir" ] || return 0
124+
125+
for patch in "$patch_dir"/*.patch; do
126+
[ -e "$patch" ] || continue
127+
echo "🩹 Applying $(basename "$patch")"
128+
patch -p1 -d "$source_dir" -i "$patch"
129+
done
130+
}
131+
114132
build_libssh2() {
115133
local arch=$1
116134
local openssl_prefix="$BUILD_DIR/install-openssl-$arch"
@@ -124,6 +142,8 @@ build_libssh2() {
124142
mkdir -p "$BUILD_DIR/libssh2-$LIBSSH2_VERSION-$arch"
125143
tar xzf "$BUILD_DIR/libssh2-$LIBSSH2_VERSION.tar.gz" -C "$BUILD_DIR/libssh2-$LIBSSH2_VERSION-$arch" --strip-components=1
126144

145+
apply_patches "$BUILD_DIR/libssh2-$LIBSSH2_VERSION-$arch"
146+
127147
local build_dir="$BUILD_DIR/libssh2-$LIBSSH2_VERSION-$arch/cmake-build"
128148
mkdir -p "$build_dir"
129149
cd "$build_dir"

scripts/ios/build-libssh2-ios.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ curl -fSL "https://github.com/libssh2/libssh2/releases/download/libssh2-$LIBSSH2
6868
echo "$LIBSSH2_SHA256 $BUILD_DIR/libssh2.tar.gz" | shasum -a 256 -c - > /dev/null
6969
tar xzf "$BUILD_DIR/libssh2.tar.gz" -C "$BUILD_DIR"
7070
LIBSSH2_SRC="$BUILD_DIR/libssh2-$LIBSSH2_VERSION"
71+
72+
for patch in "$SCRIPT_DIR/../patches"/*.patch; do
73+
[ -e "$patch" ] || continue
74+
echo "=> Applying $(basename "$patch")"
75+
patch -p1 -d "$LIBSSH2_SRC" -i "$patch"
76+
done
77+
7178
echo " Done."
7279

7380
# --- Build function ---
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
CVE-2026-55200: out-of-bounds write in ssh2_transport_read()
2+
3+
libssh2 through 1.11.1 enforces no upper bound on the packet_length field when the cipher
4+
requires a full packet (the encrypted + REQUIRES_FULL_PACKET branch). A malicious server can
5+
send a crafted packet length, corrupt the heap before authentication completes, and reach
6+
remote code execution. CVSS 4.0 base score 9.2.
7+
8+
The sibling branch already carries this bound check; only this path was missed.
9+
10+
Backported from upstream 97acf3dfda80c91c3a8c9f2372546301d4a1a7a8 ("transport.c: Additional
11+
boundary checks for packet length", libssh2/libssh2#2052). The upstream commit does not apply
12+
as-is: master renamed _libssh2_ntohu32() to ssh2_ntohu32() after 1.11.1 was cut. The guard
13+
itself is unchanged.
14+
15+
1.11.1 is the newest release and no release carries the fix yet. Delete this patch and bump
16+
LIBSSH2_VERSION once one does.
17+
18+
https://nvd.nist.gov/vuln/detail/CVE-2026-55200
19+
https://github.com/libssh2/libssh2/pull/2052
20+
21+
--- a/src/transport.c
22+
+++ b/src/transport.c
23+
@@ -639,8 +639,12 @@
24+
total_num = 4;
25+
26+
p->packet_length = _libssh2_ntohu32(block);
27+
- if(p->packet_length < 1)
28+
+ if(p->packet_length < 1) {
29+
return LIBSSH2_ERROR_DECRYPT;
30+
+ }
31+
+ else if(p->packet_length > LIBSSH2_PACKET_MAXPAYLOAD) {
32+
+ return LIBSSH2_ERROR_OUT_OF_BOUNDARY;
33+
+ }
34+
35+
/* total_num may include size field, however due to existing
36+
* logic it needs to be removed after the entire packet is read

0 commit comments

Comments
 (0)