CVE-2025-15661: libssh2 Out-of-Bounds Heap Read in SFTP Symlink Handling
libssh2 versions up to 1.11.1 contain a flaw in how they handle responses from SSH servers during SFTP file operations. A malicious or compromised SSH server can craft a specially-malformed response that causes the client library to read beyond the boundaries of its own memory buffer. This can leak sensitive data from the application's memory or cause the client to crash. The vulnerability exists in the symlink-related operations (READLINK and REALPATH) and requires network access to an SSH server, but does not require user interaction or special privileges.
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:L/I:N/A:H
- Weaknesses (CWE)
- CWE-125
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-18 / 2026-07-14
NVD description (verbatim)
libssh2 through 1.11.1, fixed in commit 2dae302, contains an out-of-bounds heap read vulnerability in the sftp_symlink() function in src/sftp.c that allows a malicious SSH server or man-in-the-middle attacker to disclose heap memory contents or cause a crash by sending a crafted SSH_FXP_NAME response. Attackers can supply a link_len value larger than the actual packet data in SSH_FXP_NAME responses for SFTP READLINK and REALPATH operations, triggering a heap buffer over-read of up to target_len minus one bytes due to the missing validation of available packet buffer size before the memcpy operation.
4 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability resides in the sftp_symlink() function within src/sftp.c. When libssh2 processes an SSH_FXP_NAME response packet during READLINK or REALPATH operations, it fails to validate that the link_len value advertised in the response matches the actual data present in the packet buffer. An attacker-controlled SSH server can supply a link_len larger than the genuine packet payload. The code then performs a memcpy operation without first confirming sufficient buffer data is available, resulting in an out-of-bounds heap read of up to (target_len - 1) bytes. This exposes adjacent heap memory contents and may trigger a segmentation fault. The fix, implemented in commit 2dae302, adds proper packet buffer boundary validation before the memory copy operation.
Business impact
Organizations relying on libssh2 for SFTP client functionality face two concurrent risks: potential disclosure of sensitive application data or keys resident in heap memory, and availability disruption through denial of service. The exposure is particularly acute in automated environments (CI/CD pipelines, remote backups, configuration management tools) where SFTP clients connect to external or less-trusted servers. Confidentiality impact is rated low because heap contents are not predictable; availability impact is high because a crash terminates the connection and may interrupt critical automation workflows. The medium CVSS score (6.5) reflects the network-only attack surface offset by the requirement for an active malicious SSH server.
Affected systems
Any application or system statically or dynamically linked against libssh2 versions 1.11.1 and earlier is vulnerable if that application uses SFTP symlink operations (READLINK or REALPATH). This includes but is not limited to Git clients with SSH support, SCP/SFTP utilities, configuration management agents, and backup solutions. Systems using libssh2 for non-SFTP SSH operations (pure SSH shells or port forwarding) or those with SFTP operations not involving symlink calls may have lower practical risk, though the underlying flaw remains present in the library itself.
Exploitability
Exploitation requires control or compromise of the SSH server to which the victim's application connects, or successful man-in-the-middle positioning between client and server. The attacker must craft a malicious SSH_FXP_NAME packet response. No user interaction is needed, and the attack can be fully automated. However, this is not a situation where random internet-facing servers are at risk—the attacker must intercept or control a specific, trusted SSH endpoint. Public availability of working exploit code is not typical for heap over-reads because reliable memory disclosure and crash conditions vary by application memory layout; the KEV catalog has not marked this as actively exploited.
Remediation
Upgrade libssh2 to a version containing commit 2dae302 or later. Verify the specific patch version with your vendor or release notes, as version numbering varies across distributions. For systems unable to upgrade immediately, isolate SFTP client connections to known, administratively-controlled SSH servers and enforce TLS/SSH channel security (certificate pinning, known-hosts verification) to reduce the likelihood of successful man-in-the-middle attacks. Applications should also implement SFTP operation timeouts and graceful error handling for unexpected crashes.
Patch guidance
Contact your distribution or software vendor for libssh2 updates containing commit 2dae302. Debian, Red Hat, Ubuntu, and other package maintainers will publish patched versions; check your vendor's security advisory. If you maintain local builds, pull the latest libssh2 source and verify the commit hash. Test patched builds against your SFTP workloads (particularly READLINK and REALPATH operations) in a staging environment before production deployment. No configuration changes or workarounds can fully mitigate the vulnerability—patching the library is mandatory for affected versions.
Detection guidance
Monitor for unexpected crashes or restarts of applications using libssh2, particularly those with SFTP workloads, especially after connections to external SSH servers. Review application logs for SFTP operation errors or timeouts. Network intrusion detection systems can be configured to flag malformed SSH_FXP_NAME packets with anomalously large link_len values during symlink operations, though this requires inspection of the SSH protocol layer (typically seen in high-interaction honeypots or detailed SSH protocol analysis). Inventory all systems and applications linked against libssh2 and cross-reference against your libssh2 version to identify exposure.
Why prioritize this
Although rated MEDIUM severity, this vulnerability should be prioritized for patching within 30 days because it affects a widely-used cryptographic library and has tangible impact on both confidentiality and availability. Applications in automation-heavy environments (CI/CD, deployment pipelines, backup systems) are at elevated risk due to frequent SFTP operations. The barrier to exploitation (control of or MITM on the target SSH server) limits urgency compared to unauthenticated remote code execution, but organizations should not delay patching indefinitely.
Risk score, explained
CVSS 6.5 (MEDIUM) is justified by: Network-only attack vector (no local access needed), no user interaction, but high complexity in achieving man-in-the-middle or server compromise; partial confidentiality impact (heap memory disclosure is possible but unpredictable and not easily weaponized to steal specific secrets); and high availability impact (crash of SFTP client processes). The score does not account for the widespread use of libssh2 or the criticality of SFTP in many automation workflows; context-specific risk may warrant internal elevation based on your organization's reliance on SFTP automation.
Frequently asked questions
Do I need to patch if we only use libssh2 for SSH shell access, not SFTP?
The vulnerability is specific to SFTP symlink operations (READLINK, REALPATH). If your application never invokes these operations, your practical risk is reduced. However, the underlying flaw exists in the library; if there is any possibility of SFTP usage or if you cannot definitively rule it out, patching is still recommended to eliminate the risk.
Can we mitigate this without upgrading libssh2?
Full mitigation requires upgrading to a patched version. Interim risk reduction measures include: restricting SFTP client connections to administratively-controlled, trusted SSH servers only; enforcing strict host key verification; and implementing robust error handling and monitoring for application crashes during SFTP operations. These do not eliminate the vulnerability but lower the probability of exploitation.
Is this vulnerability being actively exploited in the wild?
No. The National Vulnerability Database's Known Exploited Vulnerabilities (KEV) catalog has not listed this CVE as actively exploited. Heap over-reads are difficult to weaponize reliably across diverse application memory layouts, making opportunistic, mass-scale exploitation unlikely. However, targeted attacks against high-value SFTP users remain possible if an attacker controls or compromises their SSH server.
What versions of libssh2 are affected?
All versions through 1.11.1 are vulnerable. The fix is in commit 2dae302. Check your vendor or distribution release notes to identify the exact patched version number for your platform, as version numbering conventions vary.
This analysis is provided for informational purposes and should not be construed as professional security advice. Organizations must conduct their own risk assessments based on their specific infrastructure, threat model, and operational context. Patch version numbers and distribution timelines are subject to change; always verify against official vendor advisories before deployment. No liability is assumed for decisions made based on this information. Source: NVD (public-domain), retrieved 2026-07-27. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2025-70101MEDIUMlwext4 1.0.0 Out-of-Bounds Read Denial of Service
- CVE-2026-0127MEDIUMAndroid Out-of-Bounds Read in Communication Processor – Impact & Patch Guidance
- CVE-2026-0128MEDIUMAndroid RTCP Out-of-Bounds Read Information Disclosure
- CVE-2026-0136MEDIUMAndroid Modem Out-of-Bounds Read Denial of Service
- CVE-2026-0140MEDIUMAndroid RTP Integer Overflow Information Disclosure Vulnerability
- CVE-2026-0141MEDIUMAndroid RTCP Out-of-Bounds Read Information Disclosure
- CVE-2026-0155MEDIUMAndroid ImsMediaBitReader OOB Read Information Disclosure
- CVE-2026-0157MEDIUMAndroid RTCP Header Buffer Overflow – Remote Information Disclosure