CVE-2025-5987
📋 TL;DR
This vulnerability in libssh occurs when using ChaCha20 cipher with OpenSSL, where heap exhaustion errors aren't properly detected, leading to use of partially initialized cipher contexts. This can result in undefined behavior including data compromise or crashes. Systems using libssh with OpenSSL and ChaCha20 cipher are affected.
💻 Affected Systems
- libssh
- applications using libssh library
⚠️ Risk & Real-World Impact
Worst Case
Complete compromise of SSH session confidentiality and integrity, allowing attackers to decrypt or manipulate traffic, potentially leading to full system compromise.
Likely Case
SSH session crashes or data corruption, causing service disruption and potential information disclosure.
If Mitigated
Limited impact with proper network segmentation and monitoring, though risk remains for vulnerable systems.
🎯 Exploit Status
Requires attacker to exhaust heap memory and trigger the specific error condition during SSH session establishment with ChaCha20 cipher.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Check Red Hat advisories for specific patched versions (RHSA-2025:23483, RHSA-2025:23484, RHSA-2026:0427, RHSA-2026:0428, RHSA-2026:0430)
Vendor Advisory: https://access.redhat.com/errata/RHSA-2025:23483
Restart Required: Yes
Instructions:
1. Identify affected libssh packages. 2. Apply vendor patches via package manager. 3. Restart SSH services and applications using libssh. 4. Verify patch application.
🔧 Temporary Workarounds
Disable ChaCha20 cipher
linuxRemove ChaCha20 from allowed SSH ciphers to prevent exploitation
In sshd_config: Ciphers aes256-ctr,aes192-ctr,aes128-ctr,aes256-gcm@openssh.com,aes128-gcm@openssh.com
🧯 If You Can't Patch
- Implement strict network segmentation to limit SSH access to trusted sources only
- Deploy additional monitoring and alerting for SSH connection failures and memory exhaustion events
🔍 How to Verify
Check if Vulnerable:
Check libssh version and configuration: 'ssh -Q cipher' to see if ChaCha20 is enabled, and verify libssh version against patched releases
Check Version:
rpm -q libssh || dpkg -l libssh* || ldd --version | grep libssh
Verify Fix Applied:
Verify patched libssh version is installed and ChaCha20 cipher is either disabled or patched version is confirmed
📡 Detection & Monitoring
Log Indicators:
- SSH connection failures with memory allocation errors
- Unexpected SSH session terminations
- System logs showing memory exhaustion
Network Indicators:
- Multiple failed SSH connection attempts targeting ChaCha20 cipher
- Unusual SSH traffic patterns
SIEM Query:
source="sshd" AND ("memory" OR "heap" OR "allocation") AND ("error" OR "failed" OR "terminated")
🔗 References
- https://access.redhat.com/errata/RHSA-2025:23483
- https://access.redhat.com/errata/RHSA-2025:23484
- https://access.redhat.com/errata/RHSA-2026:0427
- https://access.redhat.com/errata/RHSA-2026:0428
- https://access.redhat.com/errata/RHSA-2026:0430
- https://access.redhat.com/errata/RHSA-2026:0431
- https://access.redhat.com/errata/RHSA-2026:0702
- https://access.redhat.com/errata/RHSA-2026:0978
- https://access.redhat.com/errata/RHSA-2026:0980
- https://access.redhat.com/errata/RHSA-2026:0985
- https://access.redhat.com/errata/RHSA-2026:0996
- https://access.redhat.com/errata/RHSA-2026:1539
- https://access.redhat.com/errata/RHSA-2026:1541
- https://access.redhat.com/security/cve/CVE-2025-5987
- https://bugzilla.redhat.com/show_bug.cgi?id=2376219