# CVE-2025-5318: Libssh: out-of-bounds read in sftp_handle()

> An authenticated remote attacker can trigger an out-of-bounds read in libssh's sftp_handle function, potentially exposing sensitive memory or causing service disruption.

- **Severity:** Medium 5.4 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N`)
- **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:** 24 Jun 2025
- **Updated:** 8 Sep 2026
- **Also known as:** ALSA-2025:18231, ALSA-2025:18275, ALSA-2025:18286, ALSA-2025:20943, ALSA-2025:21013, AZL-64346, AZL-64358, BELL-CVE-2025-5318, CLSA-2025-1757499160, CLSA-2025-1757662564, CLSA-2025-1757691233, CLSA-2025-1758705355, CLSA-2025-1759157346, CLSA-2025-1759248061, CLSA-2025-1759248327, DEBIAN-CVE-2025-5318, GHSA-98qw-prqm-9f4p, JLSEC-2025-96, MINI-v466-42qh-99qf, OESA-2025-1707, OESA-2025-1804, OESA-2025-1805, OESA-2025-1806, OESA-2025-1807, OESA-2025-1808, RHSA-2025:18231, RHSA-2025:18275, RHSA-2025:18286, RHSA-2025:19012, RHSA-2025:19098, RHSA-2025:19101, RHSA-2025:19400, RHSA-2025:19401, RHSA-2025:19470, RHSA-2025:19472, RHSA-2025:20943, RHSA-2025:21013, RLSA-2025:18231, RLSA-2025:18275, RLSA-2025:18286, RLSA-2025:20943, UBUNTU-CVE-2025-5318

## What is CVE-2025-5318?

CVE-2025-5318 is a medium-severity vulnerability in Redhat Enterprise Linux, published on 24 Jun 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 libssh library in versions less than 0.11.2. An out-of-bounds read can be triggered in the sftp_handle function due to an incorrect comparison check that permits the function to access memory beyond the valid handle list and to return an invalid pointer, which is used in further processing. This vulnerability allows an authenticated remote attacker to potentially read unintended memory regions, exposing sensitive information or affect service behavior.

Weakness: CWE-125 (Out-of-bounds Read)

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

It affects 3 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `libssh` | AlmaLinux:10 | All versions | 0.11.1-4.el10_1 |
| `libssh-config` | AlmaLinux:10 | All versions | 0.11.1-4.el10_0 |
| `libssh-config` | AlmaLinux:10 | All versions | 0.11.1-4.el10_1 |
| `libssh-devel` | AlmaLinux:10 | All versions | 0.11.1-4.el10_1 |
| `libssh` | AlmaLinux:8 | All versions | 0.9.6-15.el8_10 |
| `libssh-config` | AlmaLinux:8 | All versions | 0.9.6-15.el8_10 |
| `libssh-devel` | AlmaLinux:8 | All versions | 0.9.6-15.el8_10 |
| `libssh` | AlmaLinux:9 | All versions | 0.10.4-15.el9_6 |
| `libssh` | AlmaLinux:9 | All versions | 0.10.4-15.el9_7 |
| `libssh-config` | AlmaLinux:9 | All versions | 0.10.4-15.el9_6 |
| `libssh-config` | AlmaLinux:9 | All versions | 0.10.4-15.el9_7 |
| `libssh-devel` | AlmaLinux:9 | All versions | 0.10.4-15.el9_6 |
| `libssh-devel` | AlmaLinux:9 | All versions | 0.10.4-15.el9_7 |
| `libssh` | Red Hat:enterprise_linux:10.0 | All versions | 0:0.11.1-4.el10_0 |
| `libssh-config` | Red Hat:enterprise_linux:10.0 | All versions | 0:0.11.1-4.el10_0 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:10.0 | All versions | 0:0.11.1-4.el10_0 |
| `libssh-debugsource` | Red Hat:enterprise_linux:10.0 | All versions | 0:0.11.1-4.el10_0 |
| `libssh-devel` | Red Hat:enterprise_linux:10.0 | All versions | 0:0.11.1-4.el10_0 |
| `libssh` | Red Hat:enterprise_linux:10.1 | All versions | 0:0.11.1-4.el10_1 |
| `libssh-config` | Red Hat:enterprise_linux:10.1 | All versions | 0:0.11.1-4.el10_1 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:10.1 | All versions | 0:0.11.1-4.el10_1 |
| `libssh-debugsource` | Red Hat:enterprise_linux:10.1 | All versions | 0:0.11.1-4.el10_1 |
| `libssh-devel` | Red Hat:enterprise_linux:10.1 | All versions | 0:0.11.1-4.el10_1 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.9.6-15.el8_10 |
| `libssh-debugsource` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.9.6-15.el8_10 |
| `libssh-devel` | Red Hat:enterprise_linux:8::appstream | All versions | 0:0.9.6-15.el8_10 |
| `libssh` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-15.el8_10 |
| `libssh-config` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-15.el8_10 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-15.el8_10 |
| `libssh-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.9.6-15.el8_10 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.10.4-15.el9_6 |
| `libssh-debuginfo` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.10.4-15.el9_7 |
| `libssh-debugsource` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.10.4-15.el9_6 |
| `libssh-debugsource` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.10.4-15.el9_7 |
| `libssh-devel` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.10.4-15.el9_6 |
| `libssh-devel` | Red Hat:enterprise_linux:9::appstream | All versions | 0:0.10.4-15.el9_7 |
| `libssh` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.10.4-15.el9_6 |
| `libssh` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.10.4-15.el9_7 |
| `libssh-config` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.10.4-15.el9_6 |
| `libssh-config` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.10.4-15.el9_7 |

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

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

Upgrade to a fixed version.

## Is CVE-2025-5318 being exploited?

There is no known exploitation of CVE-2025-5318 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-5318 and fix it if it is affected.

What it is: CVE-2025-5318 is a medium-severity vulnerability in Redhat Enterprise Linux, published on 24 Jun 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-5318 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-5318/ (Markdown: https://insights.sbomify.com/CVE-2025-5318/index.md)
```

## Sources

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

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