# CVE-2025-5372: Libssh: incorrect return code handling in ssh_kdf() in libssh

> Attackers can compromise SSH session confidentiality and integrity due to incorrect return code handling in libssh when using older OpenSSL versions.

- **Severity:** Medium 5.0 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Jul 2025
- **Updated:** 1 Sep 2026
- **Also known as:** ALSA-2025:21977, AZL-64650, AZL-64656, BELL-CVE-2025-5372, CLSA-2025-1759330475, CLSA-2025-1759782399, CLSA-2025-1759857168, CLSA-2025-1759951300, DEBIAN-CVE-2025-5372, GHSA-59w5-j22f-h3rv, JLSEC-2025-97, MINI-wx9w-xv2w-99pj, RHSA-2025:21977, RHSA-2025:23024, RHSA-2026:20610, RHSA-2026:24349, RHSA-2026:25911, RLSA-2025:21977, UBUNTU-CVE-2025-5372

## What is CVE-2025-5372?

CVE-2025-5372 is a medium-severity 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 libssh versions built with OpenSSL versions older than 3.0, specifically in the ssh_kdf() function responsible for key derivation. Due to inconsistent interpretation of return values where OpenSSL uses 0 to indicate failure and libssh uses 0 for success—the function may mistakenly return a success status even when key derivation fails. This results in uninitialized cryptographic key buffers being used in subsequent communication, potentially compromising SSH sessions' confidentiality, integrity, and availability.

Weakness: CWE-682 (Incorrect Calculation)

## Which versions are affected by CVE-2025-5372?

It affects 3 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libssh` | AlmaLinux:8 | All versions | 0.9.6-16.el8_10 |
| `libssh-config` | AlmaLinux:8 | All versions | 0.9.6-16.el8_10 |
| `libssh-devel` | AlmaLinux:8 | All versions | 0.9.6-16.el8_10 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.9.6-16.el8_10 |
| `libssh-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.9.6-16.el8_10 |
| `libssh-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.9.6-16.el8_10 |
| `libssh` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-16.el8_10 |
| `libssh-config` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-16.el8_10 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-16.el8_10 |
| `libssh-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-16.el8_10 |
| `libssh-debuginfo` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-debugsource` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-devel` | Red Hat:rhel_aus:8.4::appstream | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh` | Red Hat:rhel_aus:8.4::baseos | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-config` | Red Hat:rhel_aus:8.4::baseos | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-debuginfo` | Red Hat:rhel_aus:8.4::baseos | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-debugsource` | Red Hat:rhel_aus:8.4::baseos | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-debuginfo` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh-debugsource` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh-devel` | Red Hat:rhel_aus:8.6::appstream | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh` | Red Hat:rhel_aus:8.6::baseos | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh-config` | Red Hat:rhel_aus:8.6::baseos | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh-debuginfo` | Red Hat:rhel_aus:8.6::baseos | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh-debugsource` | Red Hat:rhel_aus:8.6::baseos | All versions | 0:0.9.6-4.el8_6.2 |
| `libssh-debuginfo` | Red Hat:rhel_e4s:8.8::appstream | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh-debugsource` | Red Hat:rhel_e4s:8.8::appstream | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh-devel` | Red Hat:rhel_e4s:8.8::appstream | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh` | Red Hat:rhel_e4s:8.8::baseos | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh-config` | Red Hat:rhel_e4s:8.8::baseos | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh-debuginfo` | Red Hat:rhel_e4s:8.8::baseos | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh-debugsource` | Red Hat:rhel_e4s:8.8::baseos | All versions | 0:0.9.6-13.el8_8.2 |
| `libssh-debuginfo` | Red Hat:rhel_e4s:9.0::appstream | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh-debugsource` | Red Hat:rhel_e4s:9.0::appstream | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh-devel` | Red Hat:rhel_e4s:9.0::appstream | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh` | Red Hat:rhel_e4s:9.0::baseos | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh-config` | Red Hat:rhel_e4s:9.0::baseos | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh-debuginfo` | Red Hat:rhel_e4s:9.0::baseos | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh-debugsource` | Red Hat:rhel_e4s:9.0::baseos | All versions | 0:0.9.6-3.el9_0.2 |
| `libssh-debuginfo` | Red Hat:rhel_eus_long_life:8.4::appstream | All versions | 0:0.9.4-2.el8_4.2 |
| `libssh-debugsource` | Red Hat:rhel_eus_long_life:8.4::appstream | All versions | 0:0.9.4-2.el8_4.2 |

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

## How do I fix CVE-2025-5372?

Apply the vendor's patch.

## Is CVE-2025-5372 being exploited?

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

## Other vulnerabilities in Redhat Enterprise Linux

- [CVE-2026-59851](https://insights.sbomify.com/CVE-2026-59851/): Libssh: libssh: authentication bypass via missing gssapi principal check (high 8.8)
- [CVE-2025-5987](https://insights.sbomify.com/CVE-2025-5987/): Libssh: invalid return code for chacha20 poly1305 with openssl backend (high 8.1)
- [CVE-2025-14821](https://insights.sbomify.com/CVE-2025-14821/): Libssh: libssh: insecure default configuration leads to local man-in-the-middle attacks on windows (high 7.8)
- [CVE-2012-4560](https://insights.sbomify.com/CVE-2012-4560/): Memory corruption in n/a (high 7.5)
- [CVE-2012-4562](https://insights.sbomify.com/CVE-2012-4562/): Integer overflow in n/a (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-5372 and fix it if it is affected.

What it is: CVE-2025-5372 is a medium-severity 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.
Exploitation: There is no known exploitation of CVE-2025-5372 in the wild and no public exploit code.

Affected product: Redhat Enterprise Linux. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-5372/ (Markdown: https://insights.sbomify.com/CVE-2025-5372/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-5372
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-5372
- OSV: https://osv.dev/vulnerability/CVE-2025-5372

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-5372/
Summaries are generated and may contain mistakes; the official description above is the record.
