# GHSA-5m39-wx2q-mxg3: Invalid use of `mem::uninitialized` causes `use-of-uninitialized-value`

> Use of uninitialized memory in compression functions can lead to crashes or arbitrary code execution when processing malicious data.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 22 Oct 2022
- **Also known as:** RUSTSEC-2022-0067

## What is GHSA-5m39-wx2q-mxg3?

GHSA-5m39-wx2q-mxg3 is a memory corruption vulnerability in lzf, published on 22 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

The compression and decompression function used `mem:uninitialized` to create an array of uninitialized values, to later write values into it. This later leads to reads from uninitialized memory.

The flaw was corrected in commit b633bf265e41c60dfce3be7eac4e4dd5e18d06cf by using a heap-allocated `Vec` and removing out use of `mem::uninitialized`. The fix was released in v0.3.2 and v1.0.0

Subsequently, the crate was deprecated and its use is discouraged.

## Which versions are affected by GHSA-5m39-wx2q-mxg3?

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


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

## How do I fix GHSA-5m39-wx2q-mxg3?

Upgrade lzf to 0.3.2 or later.

## Is GHSA-5m39-wx2q-mxg3 being exploited?

There is no known exploitation of GHSA-5m39-wx2q-mxg3 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-5m39-wx2q-mxg3 and fix it if it is affected.

What it is: GHSA-5m39-wx2q-mxg3 is a memory corruption vulnerability in lzf, published on 22 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-5m39-wx2q-mxg3 in the wild and no public exploit code.

Affected packages and fixed versions:
- lzf (crates.io): affected all versions; fixed in 0.3.2
- lzf (crates.io): affected all versions; fixed in 0.3.2
- lzf (crates.io): affected from 0.0.0-0; fixed in 0.3.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/GHSA-5m39-wx2q-mxg3/ (Markdown: https://insights.sbomify.com/GHSA-5m39-wx2q-mxg3/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-5m39-wx2q-mxg3

---
From sbomify Insights: https://insights.sbomify.com/GHSA-5m39-wx2q-mxg3/
Summaries are generated and may contain mistakes; the official description above is the record.
