Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-58050

CVE-2026-58050: Libssh2 Buffer Overflow Vulnerability

CVE-2026-58050 is a heap buffer overflow flaw in Libssh2 through 1.11.1 that lets malicious SSH servers exploit undersized buffer allocations on 32-bit platforms. This article covers technical details, impact, and mitigation.

Published:

CVE-2026-58050 Overview

CVE-2026-58050 is an integer overflow vulnerability [CWE-190] in libssh2 through version 1.11.1. The library reads an attacker-controlled 32-bit attribute count from a publickey-subsystem response and passes it directly into the allocation expression num_attrs * sizeof(libssh2_publickey_attribute) without bounds checking. On 32-bit platforms, this multiplication wraps around and produces an undersized heap buffer. A malicious SSH server can then drive the subsequent attribute-parsing loop to write past the allocation, corrupting the heap in the connecting libssh2 client.

Critical Impact

A hostile SSH server can trigger a heap buffer overflow in any 32-bit libssh2 client that uses the publickey subsystem, enabling memory corruption and potential code execution against the client.

Affected Products

  • libssh2 versions up to and including 1.11.1
  • Applications statically linking vulnerable libssh2 releases on 32-bit platforms
  • SSH clients and tooling that invoke the publickey subsystem via libssh2

Discovery Timeline

  • 2026-06-28 - CVE-2026-58050 published to the National Vulnerability Database (NVD)
  • 2026-06-30 - Last updated in NVD database

Technical Details for CVE-2026-58050

Vulnerability Analysis

The flaw lives in the publickey subsystem parser implemented in src/publickey.c. When the client requests a listing of keys, the server responds with a count field followed by attribute records. libssh2 treats the 32-bit num_attrs value as trusted input and uses it to size a heap buffer for libssh2_publickey_attribute entries.

On 32-bit builds, the product num_attrs * sizeof(libssh2_publickey_attribute) can overflow size_t. The allocator then returns a buffer far smaller than the loop expects. As parsing continues, the client writes attacker-controlled attribute names, values, and lengths beyond the allocation, producing a linear heap buffer overflow. Because the overflow content is drawn directly from the server, an attacker controls both the size and the payload of the corruption.

Root Cause

The root cause is missing overflow validation on a size computation derived from untrusted network input. The code path does not check that num_attrs fits within reasonable bounds, nor does it use a checked multiplication before calling the allocator. This is a classic [CWE-190] Integer Overflow leading to an undersized heap allocation.

Attack Vector

Exploitation requires a victim libssh2 client to connect to a server the attacker controls and to invoke the publickey subsystem, for example when enumerating or managing authorized keys. The attacker sends a crafted publickey response with an inflated num_attrs value chosen to overflow the multiplication on 32-bit targets. Subsequent attribute records overflow the shrunken heap buffer. Refer to the VulnCheck Security Advisory and the libssh2 source in publickey.c for the affected code, and the proof-of-concept repository for a working trigger.

Detection Methods for CVE-2026-58050

Indicators of Compromise

  • Client-side crashes, heap corruption assertions, or ASan reports in processes linked against libssh21.11.1 or earlier after SSH sessions
  • Outbound SSH connections from build agents, CI runners, or automation hosts to unrecognized SSH endpoints that immediately issue publickey subsystem requests
  • Unusually large num_attrs values or oversized attribute records observed in captured SSH publickey subsystem traffic

Detection Strategies

  • Inventory binaries and containers linked against libssh2 and flag any build at 1.11.1 or earlier, prioritizing 32-bit images
  • Perform SBOM (Software Bill of Materials) queries for libssh2:libssh2 to identify transitive dependencies in shipped software
  • Instrument test environments with AddressSanitizer to catch heap-overflow signatures during SSH client interactions with untrusted servers

Monitoring Recommendations

  • Log and alert on SSH client processes crashing shortly after publickey subsystem negotiation
  • Monitor egress SSH traffic from servers, developer workstations, and CI systems for connections to unapproved destinations
  • Track library versions across fleet endpoints and correlate outbound SSH sessions with vulnerable binary versions

How to Mitigate CVE-2026-58050

Immediate Actions Required

  • Upgrade libssh2 to the fixed release once available and rebuild all statically linked dependents
  • Restrict outbound SSH from build servers, CI/CD runners, and automation hosts to a known allowlist of destinations
  • Audit code paths that call libssh2_publickey_init and the publickey subsystem, and disable them where not strictly required

Patch Information

At publication, upstream fix commits should be tracked through the libssh2 repository and the VulnCheck advisory. The corrective change validates num_attrs before allocation and uses a checked multiplication to reject overflowing sizes.

Workarounds

  • Avoid using the publickey subsystem against untrusted or third-party SSH servers until patched builds are deployed
  • Prefer 64-bit builds of applications that depend on libssh2, since the specific overflow condition is triggered on 32-bit size_t
  • Isolate SSH client operations to hardened, network-segmented hosts to reduce blast radius if heap corruption is triggered
bash
# Verify installed libssh2 version and locate linked binaries
ldconfig -p | grep libssh2
strings $(ldconfig -p | awk '/libssh2/ {print $NF; exit}') | grep -i '^libssh2-'

# Enumerate processes currently linked against libssh2
lsof 2>/dev/null | grep libssh2

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.