# CVE-2024-51756: cap-std doesn't fully sandbox all the Windows device filenames

> Attackers can bypass filesystem sandboxing on Windows using special device filenames with superscript digits to access peripheral devices or network resources.

- **Severity:** Low 2.3 (`CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA: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:** 5 Nov 2024
- **Updated:** 6 Nov 2024
- **Also known as:** GHSA-hxf5-99xg-86hw, RUSTSEC-2024-0445

## What is CVE-2024-51756?

CVE-2024-51756 is a low-severity path traversal vulnerability in bytecodealliance cap-std, published on 5 Nov 2024. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

The cap-std project is organized around the eponymous `cap-std` crate, and develops libraries to make it easy to write capability-based code. cap-std's filesystem sandbox implementation on Windows blocks access to special device filenames such as "COM1", "COM2", "LPT0", "LPT1", and so on, however it did not block access to the special device filenames which use superscript digits, such as "COM¹", "COM²", "LPT⁰", "LPT¹", and so on. Untrusted filesystem paths could bypass the sandbox and access devices through those special device filenames with superscript digits, and through them provide access peripheral devices connected to the computer, or network resources mapped to those devices. This can include modems, printers, network printers, and any other device connected to a serial or parallel port, including emulated USB serial ports. The bug is fixed in #371, which is published in cap-primitives 3.4.1, cap-std 3.4.1, and cap-async-std 3.4.1. There are no known workarounds for this issue. Affected Windows users are recommended to upgrade.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2024-51756?

7 open source packages ship an affected version, including cap-std, cap-async-std and cap-primitives.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cap-std` | crates.io | All versions | 3.4.1 |
| `cap-std` | crates.io | All versions | 3.4.1 |
| `cap-async-std` | crates.io | All versions | 3.4.1 |
| `cap-async-std` | crates.io | All versions | 3.4.1 |
| `cap-primitives` | crates.io | All versions | 3.4.1 |
| `cap-primitives` | crates.io | All versions | 3.4.1 |
| `cap-primitives` | crates.io | From 0.0.0-0 | 3.4.1 |

## How do I fix CVE-2024-51756?

Upgrade cap-std to 3.4.1 or later.

## Is CVE-2024-51756 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-51756 and fix it if it is affected.

What it is: CVE-2024-51756 is a low-severity path traversal vulnerability in bytecodealliance cap-std, published on 5 Nov 2024. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-51756 in the wild and no public exploit code.

Affected packages and fixed versions:
- cap-std (crates.io): affected all versions; fixed in 3.4.1
- cap-std (crates.io): affected all versions; fixed in 3.4.1
- cap-async-std (crates.io): affected all versions; fixed in 3.4.1
- cap-async-std (crates.io): affected all versions; fixed in 3.4.1
- cap-primitives (crates.io): affected all versions; fixed in 3.4.1
- cap-primitives (crates.io): affected all versions; fixed in 3.4.1
- cap-primitives (crates.io): affected from 0.0.0-0; fixed in 3.4.1

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

## Sources

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

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