# GHSA-x3f4-45xf-rjm7: `ruzstd` uninit and out-of-bounds memory reads

> Attackers can read up to 15 bytes of memory per overshoot by crafting a zstd archive, potentially leaking sensitive data during decompression.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 28 Nov 2024
- **Also known as:** RUSTSEC-2024-0400

## What is GHSA-x3f4-45xf-rjm7?

GHSA-x3f4-45xf-rjm7 is a memory corruption vulnerability in ruzstd, published on 28 Nov 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Affected versions of `ruzstd` miscalculate the length of the allocated and init section of its internal `RingBuffer`, leading to uninitialized or out-of-bounds reads in `copy_bytes_overshooting` of up to 15 bytes.

This may result in up to 15 bytes of memory contents being written into the decoded data when decompressing a crafted archive. This may occur multiple times per archive.

## Which versions are affected by GHSA-x3f4-45xf-rjm7?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `ruzstd` | crates.io | From 0.7.0 | 0.7.3 |
| `ruzstd` | crates.io | From 0.7.0 | 0.7.3 |
| `ruzstd` | crates.io | From 0.7.0 | 0.7.3 |

## How do I fix GHSA-x3f4-45xf-rjm7?

Upgrade ruzstd to 0.7.3 or later.

## Is GHSA-x3f4-45xf-rjm7 being exploited?

There is no known exploitation of GHSA-x3f4-45xf-rjm7 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-x3f4-45xf-rjm7 and fix it if it is affected.

What it is: GHSA-x3f4-45xf-rjm7 is a memory corruption vulnerability in ruzstd, published on 28 Nov 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-x3f4-45xf-rjm7 in the wild and no public exploit code.

Affected packages and fixed versions:
- ruzstd (crates.io): affected from 0.7.0; fixed in 0.7.3
- ruzstd (crates.io): affected from 0.7.0; fixed in 0.7.3
- ruzstd (crates.io): affected from 0.7.0; fixed in 0.7.3

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-x3f4-45xf-rjm7/ (Markdown: https://insights.sbomify.com/GHSA-x3f4-45xf-rjm7/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-x3f4-45xf-rjm7

---
From sbomify Insights: https://insights.sbomify.com/GHSA-x3f4-45xf-rjm7/
Summaries are generated and may contain mistakes; the official description above is the record.
