CVE-2025-5987: Libssh: invalid return code for chacha20 poly1305 with openssl backend

Published Jul 3, 2025
·
Updated

A flaw was found in libssh when using the ChaCha20 cipher with the OpenSSL library. If an attacker manages to exhaust the heap space, this error is not detected and may lead to libssh using a partially initialized cipher context. This occurs because the OpenSSL error code returned aliases with the SSHOK code, resulting in libssh not properly detecting the error returned by the OpenSSL library. This issue can lead to undefined behavior, including compromised data confidentiality and integrity or crashes.

Other sources

If there is an error in initializing ChaCha20 cipher with OpenSSL, an invalid error code is returned. This can happen if there is an heap exhaustion. This error is not correctly detected and could allow libssh to use partially initialized cipher context. This is caused by the mismatch of return value meaning from OpenSSL and libssh, where OpenSSL error (rv=0) aliases with SSHOK (0) and is returned directly from the function chacha20poly1305setkey(). This will likely cause error somewhere down the road.

Red Hat

Libssh: invalid return code for chacha20 poly1305 with openssl backend

Microsoft

Affected Software

8 affected componentsFixes available
libssh libssh
OpenSSL OpenSSL
libssh libssh>=0.10.0<0.11.2
Microsoft azl3 libssh 0.10.6-2
Microsoft azl3 libssh 0.10.6-1
Microsoft cbl2 libssh 0.10.6-1
Microsoft cbl2 libssh 0.10.6-2
Microsoft cbl2 libssh 0.10.6-1

Event History

Jul 3, 2025
Data Sourced
via Red Hat·09:58 PM
DescriptionSeverityAffected Software
Jul 7, 2025
CVE Published
via MITRE·02:24 PM
Data Sourced
via MITRE·02:24 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:15 PM
DescriptionSeverityWeaknessAffected Software
Jul 17, 2025
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
SeverityAffected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity

Frequently Asked Questions

1

What is the severity of CVE-2025-5987?

CVE-2025-5987 has a high severity due to the potential for attackers to exploit heap exhaustion leading to security breaches.

2

How do I fix CVE-2025-5987?

To fix CVE-2025-5987, it is recommended to update both libssh and OpenSSL to their latest versions where the vulnerability has been patched.

3

What systems are affected by CVE-2025-5987?

CVE-2025-5987 affects systems utilizing libssh with the ChaCha20 cipher in conjunction with the OpenSSL library.

4

What type of vulnerability is CVE-2025-5987?

CVE-2025-5987 is a cryptographic vulnerability that arises from improper handling of memory related to cipher context initialization.

5

Can CVE-2025-5987 be exploited remotely?

Yes, CVE-2025-5987 can potentially be exploited remotely by an attacker if they manage to craft requests that exhaust the heap space.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203