# CVE-2025-5987: libssh improper error handling in ChaCha20 cipher initialization

Source: https://junglewise.ai/threats/cve-2025-5987-libssh-improper-error-handling-in-chacha20-cipher-initialization  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2025-07-07. Updated: 2026-06-25  
License: CC BY 4.0 with a link back

CVE-2025-5987 · Severity: high · CVSS 8.1 · Published 2025-07-07

libssh is a widely used library that allows applications to communicate securely using the SSH protocol. A flaw was found where the library fails to properly detect errors when using specific encryption methods (ChaCha20) in combination with the OpenSSL security toolkit. If an attacker can trigger a memory exhaustion state, they may be able to compromise the confidentiality and integrity of the encrypted data or cause the application to crash.

Technologies: [Libssh](https://junglewise.ai/threats/technologies/libssh), [Red Hat Enterprise Linux 10](https://junglewise.ai/threats/technologies/enterprise-linux-10), [Red Hat Enterprise Linux 9](https://junglewise.ai/threats/technologies/enterprise-linux-9). Vendors: [Libssh](https://junglewise.ai/threats/vendors/libssh), [Red Hat](https://junglewise.ai/threats/vendors/red-hat).

## Quick answers

**Is CVE-2025-5987 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2025-5987 being exploited in the wild.

**How severe is CVE-2025-5987?** High severity, with a CVSS score of 8.1, published 7 July 2025.

**Which products and versions are affected?** Libssh >= 0.10.0, < 0.11.2; Red Hat Enterprise Linux 10 libssh < 0.11.1-5.el10_1; Red Hat Enterprise Linux 9 libssh < 0.10.4-17.el9_7.

**Is there a fix for CVE-2025-5987?** A patch was published on 2025-12-17: Red Hat released security advisories RHSA-2025:23483 and RHSA-2025:23484 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2025-5987 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2025-5987?** Check whether you run Libssh, Red Hat Enterprise Linux 10 or Red Hat Enterprise Linux 9 at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

A vulnerability exists in libssh's OpenSSL backend when handling the ChaCha20-Poly1305 cipher. The root cause is a return code aliasing issue where an OpenSSL error code (typically resulting from heap exhaustion during cipher initialization) is incorrectly interpreted as SSH_OK. This leads to the use of a partially initialized or uninitialized cipher context. An attacker who can influence memory pressure or trigger specific allocation failures could potentially cause undefined behavior, including memory corruption, crashes, or the compromise of encrypted communication. The issue is fixed in libssh 0.11.2 and 0.12.0, with backported patches available for various Red Hat Enterprise Linux versions.

## Affected products

- libssh libssh >= 0.10.0, < 0.11.2
- Red Hat Red Hat Enterprise Linux 9 libssh < 0.10.4-17.el9_7
- Red Hat Red Hat Enterprise Linux 10 libssh < 0.11.1-5.el10_1

## Timeline

- 2025-07-07: disclosed: Initial CVE publication date
- 2025-12-17: patched: Red Hat released security advisories RHSA-2025:23483 and RHSA-2025:23484

## References

- [https://www.libssh.org/](https://www.libssh.org/)
- [https://access.redhat.com/downloads/content/package-browser/](https://access.redhat.com/downloads/content/package-browser/)
- [https://access.redhat.com/errata/RHSA-2025:23483](https://access.redhat.com/errata/RHSA-2025:23483)
- [https://access.redhat.com/errata/RHSA-2025:23484](https://access.redhat.com/errata/RHSA-2025:23484)
- [https://access.redhat.com/errata/RHSA-2026:0427](https://access.redhat.com/errata/RHSA-2026:0427)
- [https://access.redhat.com/errata/RHSA-2026:0428](https://access.redhat.com/errata/RHSA-2026:0428)
- [https://access.redhat.com/errata/RHSA-2026:0430](https://access.redhat.com/errata/RHSA-2026:0430)

## Related threats

- [Red Hat yggdrasil-worker-package-manager argument injection in APT backend](https://junglewise.ai/threats/cve-2026-18157-red-hat-yggdrasil-worker-package-manager-argument-injection-in)
- [Samba AD DC LDAP filter injection and ACL bypass in Compare requests](https://junglewise.ai/threats/cve-2026-58222-samba-ad-dc-ldap-filter-injection-and-acl-bypass-in-compare)
- [Samba KDC out-of-bounds read in kpasswd service](https://junglewise.ai/threats/cve-2026-58216-samba-kdc-out-of-bounds-read-in-kpasswd-service)
- [Samba internal DNS server denial of service via TKEY cache exhaustion](https://junglewise.ai/threats/cve-2026-58218-samba-internal-dns-server-denial-of-service-via-tkey-cache)
- [Red Hat PCP auth bypass in pmproxy /store endpoint](https://junglewise.ai/threats/cve-2026-16527-red-hat-pcp-auth-bypass-in-pmproxy-store-endpoint)
