# GHSA-gw5w-5j7f-jmjj: Unsound usages of `std::slice::from_raw_parts`


- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 4 Dec 2024
- **Also known as:** RUSTSEC-2024-0408

## What is GHSA-gw5w-5j7f-jmjj?

GHSA-gw5w-5j7f-jmjj is a vulnerability in pprof, published on 4 Dec 2024. 

### Official description

The library breaks the safety assumptions when using unsafe API `std::slice::from_raw_parts`. First, when using the API in iterator implementation (`TempFdArrayIterator.next`), generic type could be any type, which would create and pass a misaligned pointer to the unsafe API. Second, when validating the address, the code passed the type `c_void`, which could also be any type, leading to potential uninitialized memory exposure.  

Two unsound usages here highlight the necessity for developers to perform type checks before doing type conversion with unsafe API.  

The panic caused by the misalignment causes several downstream applications (e.g., `greptimedb`) to crash when using `pprof::report::ReportBuilder::build`.  

This was patched in 0.14.0.  

The developer also suggested moving to [pprof2](https://crates.io/crates/pprof2).

## Which versions are affected by GHSA-gw5w-5j7f-jmjj?

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


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

## How do I fix GHSA-gw5w-5j7f-jmjj?

Upgrade pprof to 0.14.0 or later.

## Is GHSA-gw5w-5j7f-jmjj being exploited?

There is no known exploitation of GHSA-gw5w-5j7f-jmjj in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-gw5w-5j7f-jmjj and fix it if it is affected.

What it is: GHSA-gw5w-5j7f-jmjj is a vulnerability in pprof, published on 4 Dec 2024. 
Exploitation: There is no known exploitation of GHSA-gw5w-5j7f-jmjj in the wild and no public exploit code.

Affected packages and fixed versions:
- pprof (crates.io): affected all versions; fixed in 0.14.0
- pprof (crates.io): affected all versions; fixed in 0.14.0
- pprof (crates.io): affected from 0.0.0-0; fixed in 0.14.0

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-gw5w-5j7f-jmjj/ (Markdown: https://insights.sbomify.com/GHSA-gw5w-5j7f-jmjj/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-gw5w-5j7f-jmjj

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