# GHSA-2fjw-whxm-9v4q: Heap-buffer-overflow in nftnl::Batch::with_page_size (nftnl-rs)

> A heap-buffer-overflow in the nftnl-rs library allows attackers to cause out-of-bounds writes and potential code execution via malformed page sizes.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 18 Oct 2025
- **Also known as:** RUSTSEC-2025-0126

## What is GHSA-2fjw-whxm-9v4q?

GHSA-2fjw-whxm-9v4q is a memory corruption vulnerability in nftnl, published on 18 Oct 2025. 

### Official description

A heap-buffer-overflow vulnerability exists in the Rust wrapper for libnftnl, triggered via the nftnl::Batch::with_page_size constructor. When a small or malformed page size is provided, the underlying C code allocates an insufficient buffer, leading to out-of-bounds writes during batch initialization.

The flaw was fixed in commit 94a286f by adding an overflow check:
```Rust
batch_page_size
    .checked_add(crate::nft_nlmsg_maxsize())
    .expect("batch_page_size is too large and would overflow");
```

## Mitigation

Upgrade to version `0.9.0` or later, which aborts instead.

## Which versions are affected by GHSA-2fjw-whxm-9v4q?

3 open source packages ship an affected version, including nftnl.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `nftnl` | crates.io | All versions | 0.9.0 |
| `nftnl` | crates.io | All versions | 0.9.0 |
| `nftnl` | crates.io | From 0.0.0-0 | 0.9.0 |

## How do I fix GHSA-2fjw-whxm-9v4q?

Upgrade nftnl to 0.9.0 or later.

## Is GHSA-2fjw-whxm-9v4q being exploited?

There is no known exploitation of GHSA-2fjw-whxm-9v4q in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2fjw-whxm-9v4q and fix it if it is affected.

What it is: GHSA-2fjw-whxm-9v4q is a memory corruption vulnerability in nftnl, published on 18 Oct 2025. 
Exploitation: There is no known exploitation of GHSA-2fjw-whxm-9v4q in the wild and no public exploit code.

Affected packages and fixed versions:
- nftnl (crates.io): affected all versions; fixed in 0.9.0
- nftnl (crates.io): affected all versions; fixed in 0.9.0
- nftnl (crates.io): affected from 0.0.0-0; fixed in 0.9.0

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/GHSA-2fjw-whxm-9v4q/ (Markdown: https://insights.sbomify.com/GHSA-2fjw-whxm-9v4q/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2fjw-whxm-9v4q

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2fjw-whxm-9v4q/
Summaries are generated and may contain mistakes; the official description above is the record.
