CVE-2025-5351 Libssh: double free vulnerability in libssh key export functions

Medium 6.5 Published Updated

A double free vulnerability in libssh key export functions can cause heap corruption and application instability, leading to denial of service.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2025-5351?

CVE-2025-5351 is a medium-severity use after free vulnerability in Redhat Enterprise Linux, published on 4 Jul 2025. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

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.

Weakness: CWE-415

Which versions are affected by CVE-2025-5351?

It affects 3 products.

Products include Libssh Libssh, Redhat Enterprise Linux, Redhat Openshift Container Platform.

How do I fix CVE-2025-5351?

Apply the vendor's patch.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is CVE-2025-5351 being exploited?

There is no known exploitation of CVE-2025-5351 in the wild and no public exploit code.

All Redhat Enterprise Linux vulnerabilities

Sources

Also known as AZL-64653, AZL-64659, BELL-CVE-2025-5351, DEBIAN-CVE-2025-5351, GHSA-pfqf-mv4p-9j4r, JLSEC-2025-98 and 2 more.

Is CVE-2025-5351 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free