# GHSA-2jq9-6xx7-3h29: Use of uninitialized memory in temporary

> Use of uninitialized memory for RNG seeding in a testing library causes undefined behavior, potentially leading to unpredictable results 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:** 22 Aug 2018
- **Also known as:** RUSTSEC-2018-0022

## What is GHSA-2jq9-6xx7-3h29?

GHSA-2jq9-6xx7-3h29 is a memory corruption vulnerability in temporary, published on 22 Aug 2018. 

### Official description

Uninit memory is used as a RNG seed in temporary

The following function is used as a way to get entropy from the system, which does operations on and exposes uninit memory, which is UB.

```rust
fn random_seed(_: &Path, _: &str) -> [u64; 2] {
    use std::mem::uninitialized as rand;
    unsafe { [rand::<u64>() ^ 0x12345678, rand::<u64>() ^ 0x87654321] }
}
```

This has been resolved in the 0.6.4 release.

The crate is not intended to be used outside of a testing environment.

For a general purpose crate to create temporary directories, [`tempfile`](https://crates.io/crates/tempfile) is an alternative for this crate.

## Which versions are affected by GHSA-2jq9-6xx7-3h29?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `temporary` | crates.io | From 0.3.0 | 0.6.4 |
| `temporary` | crates.io | From 0.3.0 | 0.6.4 |
| `temporary` | crates.io | From 0.3.0 | 0.6.4 |

## How do I fix GHSA-2jq9-6xx7-3h29?

Upgrade temporary to 0.6.4 or later.

## Is GHSA-2jq9-6xx7-3h29 being exploited?

There is no known exploitation of GHSA-2jq9-6xx7-3h29 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-2jq9-6xx7-3h29 and fix it if it is affected.

What it is: GHSA-2jq9-6xx7-3h29 is a memory corruption vulnerability in temporary, published on 22 Aug 2018. 
Exploitation: There is no known exploitation of GHSA-2jq9-6xx7-3h29 in the wild and no public exploit code.

Affected packages and fixed versions:
- temporary (crates.io): affected from 0.3.0; fixed in 0.6.4
- temporary (crates.io): affected from 0.3.0; fixed in 0.6.4
- temporary (crates.io): affected from 0.3.0; fixed in 0.6.4

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-2jq9-6xx7-3h29/ (Markdown: https://insights.sbomify.com/GHSA-2jq9-6xx7-3h29/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-2jq9-6xx7-3h29

---
From sbomify Insights: https://insights.sbomify.com/GHSA-2jq9-6xx7-3h29/
Summaries are generated and may contain mistakes; the official description above is the record.
