# CVE-2025-8277: libssh memory exhaustion via repeated key exchange guesses

Source: https://junglewise.ai/threats/cve-2025-8277-libssh-memory-exhaustion-via-repeated-key-exchange-guesses  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2025-09-09. Updated: 2026-05-19  
License: CC BY 4.0 with a link back

CVE-2025-8277 · Severity: low · CVSS 3.1 · Published 2025-09-09

libssh is a software library used by applications to provide secure communication via the SSH protocol. A flaw in how it handles security key updates allows an authenticated user to cause the application to consume excessive memory by repeatedly sending incorrect security guesses. This can eventually lead to the application crashing or becoming unresponsive, impacting service availability.

Technologies: [Libssh](https://junglewise.ai/threats/technologies/libssh). Vendors: [Libssh](https://junglewise.ai/threats/vendors/libssh).

## Quick answers

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

**How severe is CVE-2025-8277?** Low severity, with a CVSS score of 3.1, published 9 September 2025.

**Which products and versions are affected?** Libssh >= 0.6.0, < 0.11.3.

**Is there a fix for CVE-2025-8277?** A patch was published on 2026-05-19: Red Hat released patches for RHEL 9 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

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

**Am I affected by CVE-2025-8277?** Check whether you run Libssh 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 memory leak exists in libssh's key exchange (KEX) logic when the 'first_kex_packet_follows' flag is used in a KEXINIT message. When a client repeatedly provides incorrect KEX guesses during rekeying operations, the library fails to free previously allocated ephemeral key pairs in 'session->next_crypto' before allocating new ones. This flaw affects multiple KEX algorithms (Curve25519, ECDH, DH-GEX) across various crypto backends including OpenSSL, libgcrypt, and mbedTLS. While exploitation requires an authenticated client and does not affect the server side, it can lead to system memory exhaustion or crashes, particularly in environments using libgcrypt's fixed-size secure memory pool. The issue is resolved in libssh version 0.11.3.

## Affected products

- libssh libssh >= 0.6.0, < 0.11.3
- Red Hat Enterprise Linux 9 libssh-0.10.4-18.el9

## Timeline

- 2025-07-28: other: Reported to Red Hat Bugzilla
- 2025-09-09: disclosed: CVE published
- 2026-05-06: advisory: libssh project advisory released
- 2026-05-19: patched: Red Hat released patches for RHEL 9

## References

- [https://access.redhat.com/errata/RHSA-2026:18683](https://access.redhat.com/errata/RHSA-2026:18683)
- [https://access.redhat.com/security/cve/CVE-2025-8277](https://access.redhat.com/security/cve/CVE-2025-8277)
- [https://bugzilla.redhat.com/show_bug.cgi?id=2383888](https://bugzilla.redhat.com/show_bug.cgi?id=2383888)
- [https://www.libssh.org/security/advisories/CVE-2025-8277.txt](https://www.libssh.org/security/advisories/CVE-2025-8277.txt)

## Related threats

- [libssh authentication bypass in GSSAPIKeyExchange](https://junglewise.ai/threats/cve-2026-59851-libssh-authentication-bypass-in-gssapikeyexchange)
- [libssh use-after-free in channel data callbacks](https://junglewise.ai/threats/cve-2026-59850-libssh-use-after-free-in-channel-data-callbacks)
- [libssh infinite loop in certificate-based authentication](https://junglewise.ai/threats/cve-2026-59849-libssh-infinite-loop-in-certificate-based-authentication)
- [libssh denial of service via memory exhaustion in SFTP client](https://junglewise.ai/threats/cve-2026-59848-libssh-denial-of-service-via-memory-exhaustion-in-sftp-client)
- [libssh integrity protection bypass in OpenSSL AES-GCM backend](https://junglewise.ai/threats/cve-2026-59847-libssh-integrity-protection-bypass-in-openssl-aes-gcm-backend)
