# CVE-2023-41051: Default functions in VolatileMemory trait lack bounds checks in vm-memory

> Out-of-bounds memory access in vm-memory allows attackers to cause crashes or execute code via custom implementations.

- **Severity:** Low 2.5 (`CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 1 Sep 2023
- **Updated:** 13 Feb 2025
- **Also known as:** DEBIAN-CVE-2023-41051, GHSA-49hh-fprx-m68g, RUSTSEC-2023-0056

## What is CVE-2023-41051?

CVE-2023-41051 is a low-severity memory corruption vulnerability in rust-vmm vm-memory, published on 1 Sep 2023. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

In a typical Virtual Machine Monitor (VMM) there are several components, such as boot loader, virtual device drivers, virtio backend drivers and vhost drivers, that need to access the VM physical memory. The vm-memory rust crate provides a set of traits to decouple VM memory consumers from VM memory providers. An issue was discovered in the default implementations of the `VolatileMemory::{get_atomic_ref, aligned_as_ref, aligned_as_mut, get_ref, get_array_ref}` trait functions, which allows out-of-bounds memory access if the `VolatileMemory::get_slice` function returns a `VolatileSlice` whose length is less than the function’s `count` argument. No implementations of `get_slice` provided in `vm_memory` are affected. Users of custom `VolatileMemory` implementations may be impacted if the custom implementation does not adhere to `get_slice`'s documentation. The issue started in version 0.1.0 but was fixed in version 0.12.2 by inserting a check that verifies that the `VolatileSlice` returned by `get_slice` is of the correct length. Users are advised to upgrade. There are no known workarounds for this issue.

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

## Which versions are affected by CVE-2023-41051?

3 open source packages ship an affected version, including vm-memory. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `vm-memory` | crates.io | All versions | 0.12.2 |
| `vm-memory` | crates.io | All versions | 0.12.2 |
| `vm-memory` | crates.io | From 0.0.0-0 | 0.12.2 |

Products: Vm-Memory Project Vm-Memory.

## How do I fix CVE-2023-41051?

Upgrade vm-memory to 0.12.2 or later.

## Is CVE-2023-41051 being exploited?

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

## Other vulnerabilities in rust-vmm vm-memory

- [CVE-2020-13759](https://insights.sbomify.com/CVE-2020-13759/): Improper Synchronization and Race Condition in vm-memory (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-41051 and fix it if it is affected.

What it is: CVE-2023-41051 is a low-severity memory corruption vulnerability in rust-vmm vm-memory, published on 1 Sep 2023. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2023-41051 in the wild and no public exploit code.

Affected packages and fixed versions:
- vm-memory (crates.io): affected all versions; fixed in 0.12.2
- vm-memory (crates.io): affected all versions; fixed in 0.12.2
- vm-memory (crates.io): affected from 0.0.0-0; fixed in 0.12.2

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-2023-41051/ (Markdown: https://insights.sbomify.com/CVE-2023-41051/index.md)
```

## Sources

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

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