CVE-2026-58050: libssh2 Heap Buffer Overflow in Public-Key Subsystem (32-bit)
libssh2, a widely used SSH client library, contains a heap buffer overflow vulnerability affecting versions through 1.11.1. When a libssh2 client connects to an SSH server, the library parses responses from the public-key subsystem. An attacker operating a malicious SSH server can craft a response with a specially crafted attribute count that causes integer overflow during memory allocation on 32-bit platforms, resulting in a smaller buffer than intended. The library then writes attribute data beyond the allocated buffer boundary, corrupting heap memory and potentially enabling code execution or denial of service.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 7.0 HIGH · CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:H
- Weaknesses (CWE)
- CWE-190
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-28 / 2026-06-30
NVD description (verbatim)
libssh2 through 1.11.1 reads an attacker-controlled 32-bit attribute count from a publickey-subsystem response and uses it in the allocation num_attrs * sizeof(libssh2_publickey_attribute) without bounds checking, so on 32-bit platforms the multiplication overflows to an undersized buffer. A malicious SSH server can then drive the attribute-parsing loop to write past the allocation, causing a heap buffer overflow in a connecting libssh2 client.
3 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from unsafe integer arithmetic in libssh2's public-key subsystem handler. The code reads an attacker-controlled 32-bit attribute count from the SSH server response without validation, then calculates the required allocation size using the formula: num_attrs * sizeof(libssh2_publickey_attribute). On 32-bit platforms, this multiplication can overflow, wrapping around to a much smaller value. The subsequent attribute-parsing loop treats this count as legitimate and writes attribute structures into the undersized heap buffer, causing an out-of-bounds write. The vulnerability is classified as CWE-190 (Integer Overflow or Wraparound) and requires specific conditions on the target architecture and library version, making exploitation dependent on the victim using a 32-bit build of libssh2.
Business impact
Organizations relying on libssh2 for SSH client functionality face potential compromise through malicious SSH servers. This includes embedded systems, appliances, IoT devices, and applications that bundle libssh2 as a dependency. A successful exploit could allow attackers to execute arbitrary code with the privileges of the affected application, or trigger denial of service. The attack surface includes any user or automated system that connects to untrusted or compromised SSH servers. Patching is critical for systems handling sensitive SSH operations, particularly those in networks where server compromise or man-in-the-middle attacks are plausible.
Affected systems
libssh2 versions through 1.11.1 are affected. The practical impact is primarily on 32-bit builds of libssh2; 64-bit builds are not vulnerable due to the absence of integer overflow in the multiplication on larger word sizes. Affected systems include applications and libraries that statically or dynamically link libssh2, particularly those deployed on ARM, x86, MIPS, and other 32-bit architectures. Verify your specific usage: check build configuration, architecture, and libssh2 version in your supply chain.
Exploitability
Exploitation requires the victim to connect to a malicious or compromised SSH server. No user interaction beyond initiating an SSH connection is needed, and the attack works across networks (AV:N). However, the attack complexity is rated as high (AC:H) due to the specific conditions required: the target must run a vulnerable 32-bit build, the SSH server must be under attacker control or compromised, and the exploit must precisely craft the overflow. Public exploit code is not known to exist, and this has not been added to the CISA KEV catalog. Real-world exploitation is possible but requires active server compromise or man-in-the-middle positioning.
Remediation
Update libssh2 to a patched version released after June 28, 2026. Verify the patch version against the vendor's official advisory to confirm the overflow is addressed. For systems unable to update immediately, implement network controls to restrict SSH connections to trusted, verified servers. Consider disabling public-key subsystem support if it is not required. Monitor process execution and memory access patterns for signs of exploitation. On 64-bit platforms, prioritize patching for other potential vulnerabilities, but treat 32-bit deployments as urgent.
Patch guidance
Contact your libssh2 vendor or check the official libssh2 release notes and security advisories for the specific patch version that resolves CVE-2026-58050. Apply updates in a staged manner: first to non-production systems to verify compatibility, then to production. For embedded systems and appliances, check with the device manufacturer for firmware updates that include the patched libssh2. If using libssh2 as a transitive dependency, ensure your build tooling and package manager pull the updated version. Test SSH client functionality after patching, particularly for applications using the public-key subsystem.
Detection guidance
On 32-bit platforms running vulnerable libssh2 versions, monitor for segmentation faults or memory corruption errors in applications during SSH connections to untrusted servers. Enable debug logging in libssh2 where available to detect anomalies in SSH protocol parsing. Check system logs and core dumps for crashes in the public-key subsystem handler. Network intrusion detection systems should flag SSH servers sending unusually large or suspicious attribute count values in public-key subsystem responses. Conduct binary analysis of deployed libssh2 builds to confirm they are 32-bit and identify the version. If feasible, use runtime memory sanitizers (ASan, MSan) in test environments to catch buffer overflows before production deployment.
Why prioritize this
This vulnerability merits immediate attention due to its high CVSS score (7.0), potential for remote code execution on 32-bit systems, and the commonality of libssh2 in embedded and client-side applications. Although 64-bit platforms are unaffected, organizations with mixed architectures or legacy 32-bit deployments face significant risk. The low barrier to triggering the overflow—merely initiating an SSH connection to a malicious server—increases practical risk in networks where server compromise or MITM attacks are credible threats. Patching should be prioritized for edge cases and mobile systems first, then extended to the broader estate.
Risk score, explained
The CVSS 3.1 score of 7.0 (HIGH) reflects a network-accessible attack vector, high potential impact on confidentiality and integrity, and the ability to cause denial of service. The high attack complexity moderates the score somewhat, accounting for the requirement that a 32-bit build be in use and that the attacker control or compromise the SSH server. The absence of privilege escalation or user interaction keeps the score below CRITICAL. The practical risk is significant for 32-bit deployments in untrusted network environments; organizations running only 64-bit builds should still patch to eliminate architectural variants in their supply chain.
Frequently asked questions
Does this vulnerability affect 64-bit builds of libssh2?
No. The integer overflow occurs only on 32-bit platforms where the multiplication of num_attrs * sizeof(libssh2_publickey_attribute) can wrap around. On 64-bit systems, the multiplication result remains within valid bounds, and no buffer overflow occurs. However, all organizations should verify their build configuration and patch regardless of platform to maintain consistent security posture across their fleet.
Do I need to connect to an untrusted SSH server for this to be exploited?
Yes. The attack requires the victim's libssh2 client to connect to a malicious or compromised SSH server that sends a crafted public-key subsystem response. If your systems connect only to internally managed, trusted SSH servers and those servers are not compromised, your immediate risk is lower. However, if your applications connect to third-party servers or user-supplied SSH endpoints, or if server compromise is plausible in your threat model, exploitation is feasible.
Is this vulnerability being actively exploited in the wild?
As of the publication date (June 28, 2026), this vulnerability has not been added to the CISA Known Exploited Vulnerabilities (KEV) catalog, indicating no confirmed widespread active exploitation. However, the relative ease of exploitation on vulnerable 32-bit systems means that once patches are widely available and discrepancies in patching become apparent, attackers may begin targeting unpatched systems. Do not delay patching in anticipation of future exploitation.
What should I do if I cannot patch libssh2 immediately?
Implement compensating controls: restrict SSH connections from your applications to known-good, trusted servers; deploy network segmentation to limit outbound SSH traffic; monitor for abnormal process termination or memory corruption errors that may indicate exploitation; and conduct a detailed inventory of libssh2 usage to prioritize patching of the highest-risk systems first. Prioritize patching of 32-bit builds and systems in untrusted network environments.
This analysis is provided for informational purposes based on publicly available vulnerability data and vendor advisories. SEC.co does not guarantee the accuracy, completeness, or timeliness of this information. Readers must verify all patch version numbers, affected products, and remediation steps against official vendor sources and their own system configurations. CVSS scores and severity ratings reflect industry-standard methodologies but should not be the sole basis for risk prioritization. Organizations must conduct their own risk assessment, testing, and validation of patches before production deployment. The timeline and availability of patches may vary by vendor and platform; consult your vendor directly for patch status and release schedules. Source: NVD (public-domain), retrieved 2026-08-06. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2023-29146HIGHInteger Overflow in Malwarebytes EDR 1.0.11 Linux Hash Functions
- CVE-2025-14098HIGHAvira Antivirus Engine Heap Buffer Overflow—Patch Guidance
- CVE-2025-66280HIGHQNAP Integer Overflow Vulnerability: Patch & Risk Assessment
- CVE-2026-0095HIGHAndroid Bluetooth Integer Overflow Privilege Escalation
- CVE-2026-0131HIGHAndroid RTP Integer Overflow Privilege Escalation Vulnerability
- CVE-2026-0148HIGHAndroid RTP Video Decoder Integer Overflow Remote Code Execution
- CVE-2026-0150HIGHAndroid EdgeTPU Firmware Privilege Escalation Vulnerability
- CVE-2026-0151HIGHAndroid Graphics Integer Overflow RCE Vulnerability