CVE-2025-5351: Libssh: double free vulnerability in libssh key export functions
A Double Free vulnerability exists in libssh’s key export mechanism when built against OpenSSL 3.0 or later. The flaw lies in the pkikeytoblob() function, where a memory structure (params) is deallocated during error handling but not properly nullified. If a subsequent operation encounters an error, the same structure may be freed again, leading to undefined behavior and potential process crashes. Although exploitation requires authenticated access and specific memory failure conditions, the flaw could be leveraged to destabilize applications using libssh for exporting SSH key material.
Affected versions : libssh >= 0.10.0, built with OpenSSL >= 3.0
Other sources
A flaw was found in the key export functionality of libssh. The issue occurs in the internal function responsible for converting cryptographic keys into serialized formats. During error handling, a memory structure is freed but not cleared, leading to a potential double free issue if an additional failure occurs later in the function. This condition may result in heap corruption or application instability in low-memory scenarios, posing a risk to system reliability where key export operations are performed.
— MITRE
Libssh: double free vulnerability in libssh key export functions
— Microsoft
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2025-5351?
CVE-2025-5351 is classified as a critical severity vulnerability due to its potential to cause memory corruption.
How do I fix CVE-2025-5351?
To fix CVE-2025-5351, ensure you update libssh and OpenSSL to the latest versions that contain the patch.
Which versions are affected by CVE-2025-5351?
CVE-2025-5351 affects libssh versions starting from 0.10.0 and OpenSSL versions starting from 3.0.
What should I do if I cannot upgrade due to compatibility issues related to CVE-2025-5351?
If you cannot upgrade, you should apply any available mitigations or workarounds as outlined by the vendor until an upgrade is possible.
Is it safe to use OpenSSL 3.0 with libssh given CVE-2025-5351?
Using OpenSSL 3.0 with libssh is not safe without applying the necessary patches for CVE-2025-5351.