CVE-2026-58051: libssh2 Memory Corruption in Public Key Parsing
libssh2, a widely-used SSH protocol library, contains a memory safety bug affecting versions through 1.11.1. When a malicious SSH server sends a crafted response during publickey subsystem negotiation, libssh2 can fail to properly initialize new entries in its public key list. If parsing then fails, the cleanup routine attempts to free memory that was never initialized, potentially executing arbitrary code or causing a denial of service. An attacker controlling an SSH server can trigger this condition without any special privileges or user interaction.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 6.5 MEDIUM · CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H
- Weaknesses (CWE)
- CWE-908
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-28 / 2026-06-30
NVD description (verbatim)
libssh2 through 1.11.1 grows its publickey list with SSH2_REALLOC but does not zero-initialize new entries before parsing populates them, so a parse failure reaching the cleanup path leaves libssh2_publickey_list_free operating on an uninitialized entry. A malicious SSH server offering the publickey subsystem can use a malformed response to make cleanup free an uninitialized, attacker-influenceable attrs pointer 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 libssh2's allocation strategy for its public key list. The library uses SSH2_REALLOC to grow the list but does not zero-initialize newly allocated entries before parsing operations populate them. When a parse failure occurs, the cleanup path (libssh2_publickey_list_free) attempts to free an uninitialized attrs pointer within a list entry. Because the attacker can influence the contents of the newly allocated but uninitialized memory through server-side control, they can craft a scenario where this pointer references attacker-controlled data. This leads to a use-after-free or arbitrary free condition during cleanup, classified under CWE-908 (Use of Uninitialized Resource).
Business impact
Organizations relying on libssh2 for SSH client functionality face a two-pronged risk. A malicious or compromised SSH server can cause libssh2-based applications to crash (denial of service), disrupting SSH-dependent workflows. More critically, memory corruption during the free operation could enable code execution within the context of the connecting client application. This is particularly concerning in automated systems, deployment pipelines, or monitoring tools that establish SSH connections without human oversight.
Affected systems
libssh2 versions up to and including 1.11.1 are affected. Any application or system embedding libssh2 as an SSH client library is potentially vulnerable when connecting to untrusted or compromised SSH servers. This includes (but is not limited to) SSH clients, deployment automation tools, backup utilities, and embedded devices using libssh2 for remote access.
Exploitability
Exploitation requires the attacker to control or intercept the SSH server to which a libssh2 client connects. The CVSS vector (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H) indicates network-accessible attack surface with higher attack complexity, reflecting the conditional nature of reliable exploitation. No user interaction is needed once a client initiates a connection to the malicious server. Practical exploitation depends on the attacker's ability to serve as or modify an SSH server response, limiting opportunistic attacks but remaining feasible in targeted scenarios.
Remediation
Upgrade libssh2 to a patched version released after 1.11.1. Users should verify the exact version number against the official libssh2 project release notes and vendor advisories. In environments where immediate patching is not feasible, network segmentation to restrict SSH connections to known, trusted servers reduces exposure. Monitoring for unexpected crashes or hangs in SSH client applications may provide early detection of exploitation attempts.
Patch guidance
Consult the official libssh2 project repository and release notes for the specific patched version addressing CVE-2026-58051. Apply updates through your package manager or vendor distribution channel. Verify patch installation by confirming the libssh2 version in affected applications. Organizations using libssh2 indirectly through dependent applications should check with upstream vendors for patched releases.
Detection guidance
Monitor for crashes or resource exhaustion in applications using libssh2, particularly when connecting to external SSH servers. Log SSH connection attempts and server responses for anomalies. Memory debugging tools and sanitizers can catch use-after-free conditions in development and testing environments. Intrusion detection systems may flag malformed SSH protocol responses if configured to inspect SSH traffic, though the malformation is subtle and requires deep SSH protocol knowledge to detect reliably.
Why prioritize this
Assign medium priority based on the CVSS 6.5 score and exploitation constraints. The vulnerability is not on the Known Exploited Vulnerabilities (KEV) catalog, indicating limited evidence of in-the-wild exploitation at publication. However, the combination of denial of service and potential code execution, coupled with libssh2's widespread use in infrastructure tooling, warrants prompt patching. Organizations extensively using automated SSH connections should prioritize this update; others may phase patching alongside routine maintenance windows.
Risk score, explained
CVSS 3.1 score of 6.5 (MEDIUM severity) reflects moderate impact with higher barriers to exploitation. The attack vector is network-accessible (AV:N), but attack complexity is high (AC:H) because reliable trigger of the parse failure and memory corruption requires specific server responses and memory layout conditions. Confidentiality is not impacted (C:N), integrity is slightly impacted (I:L) through potential memory corruption, and availability is highly impacted (A:H) through denial of service. The attack requires no privileges (PR:N) and no user interaction (UI:N), but the conditional nature of successful exploitation prevents a higher score.
Frequently asked questions
Can an SSH server exploit this without the client connecting first?
No. The vulnerability requires an active SSH connection attempt from a libssh2 client. The malicious server crafts a response only after the client has initiated the connection and begun publickey subsystem negotiation.
Does this affect SSH servers running libssh2?
libssh2 is primarily used in SSH client implementations. SSH servers typically use libssh or other server-focused libraries. However, applications using libssh2 for both client and server functionality could theoretically be affected if they connect to malicious peer instances.
What should companies do if they cannot update libssh2 immediately?
Implement network controls to restrict SSH connections to explicitly trusted servers and network segments. Disable the publickey subsystem if not required. Deploy intrusion detection to monitor for SSH anomalies. Plan and schedule patching as a critical update in your change management process.
Is this vulnerability actively exploited in the wild?
As of the publication date, CVE-2026-58051 is not listed on CISA's Known Exploited Vulnerabilities catalog, suggesting limited in-the-wild exploitation. However, absence from the KEV list does not indicate absence of threat; organizations should not rely solely on KEV status for prioritization.
This analysis is based on the vulnerability description and CVSS assessment as of the publication date. Exploitation complexity and real-world impact may vary based on application-specific configurations, network topology, and attacker capability. Verify all patch version numbers and availability against official vendor advisories before deployment. SEC.co does not provide exploit code or detailed proof-of-concept information. Organizations should conduct internal risk assessments aligned with their threat model and operational environment. This page does not constitute security advice; consult with qualified security professionals for guidance specific to your infrastructure. Source: NVD (public-domain), retrieved 2026-08-06. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-11089MEDIUMGoogle Chrome Memory Disclosure in Media Handling
- CVE-2026-26825MEDIUMlibxls 1.6.3 Use-of-Uninitialized Memory Vulnerability
- CVE-2026-42969MEDIUMWindows Push Notifications Information Disclosure Vulnerability
- CVE-2026-46132MEDIUMLinux Kernel Stack Memory Leak via rtnetlink VF Information Disclosure
- CVE-2026-46139MEDIUMLinux SMB Client Uninitialized Buffer in Security Descriptors
- CVE-2026-46167MEDIUMLinux Kernel USB Printer Driver Uninitialized Heap Memory Leak via LPGETSTATUS ioctl
- CVE-2026-46169MEDIUMLinux HFS+ Catalog Record Validation Vulnerability
- CVE-2026-46186MEDIUMLinux Bluetooth Virtio Driver Memory Validation Flaw