# RUSTSEC-2025-0162: `VMABuffer::set_data` may allow out-of-bounds writes from safe code

> Safe Rust code can trigger out-of-bounds writes in VMABuffer::set_data due to missing bounds checks, potentially leading to memory corruption or crashes.

- **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:** 23 Apr 2025

## What is RUSTSEC-2025-0162?

RUSTSEC-2025-0162 is a memory corruption vulnerability in vku, published on 23 Apr 2025. 

### Official description

`VMABuffer::set_data` was a publicly accessible safe function. It accepted an arbitrary `offset` and a data slice, then used the offset in unsafe pointer arithmetic before copying the slice into a mapped allocation.

Affected versions did not check that the requested write range fit within the allocation before calling `ptr.add(offset)` and `copy_from_nonoverlapping`. Safe Rust code could therefore trigger an out-of-bounds write by passing an offset outside the mapped allocation.

This makes the safe API unsound, since callers can trigger undefined behavior without using `unsafe`.

Version `0.4.0` added a bounds check before performing the pointer arithmetic and copy.

## Which versions are affected by RUSTSEC-2025-0162?

1 open source package ship an affected version, including vku.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `vku` | crates.io | From 0.0.0-0 | 0.4.0 |

## How do I fix RUSTSEC-2025-0162?

Upgrade vku to 0.4.0 or later.

## Is RUSTSEC-2025-0162 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for RUSTSEC-2025-0162 and fix it if it is affected.

What it is: RUSTSEC-2025-0162 is a memory corruption vulnerability in vku, published on 23 Apr 2025. 
Exploitation: There is no known exploitation of RUSTSEC-2025-0162 in the wild and no public exploit code.

Affected packages and fixed versions:
- vku (crates.io): affected from 0.0.0-0; fixed in 0.4.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/RUSTSEC-2025-0162/ (Markdown: https://insights.sbomify.com/RUSTSEC-2025-0162/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/RUSTSEC-2025-0162

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