# GHSA-pqpw-89w5-82v5: `simd-json-derive` vulnerable to `MaybeUninit` misuse

> Misuse of MaybeUninit in simd-json-derive causes undefined behavior, potentially leading to crashes or arbitrary code execution in release builds.

- **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:** 14 Oct 2023
- **Also known as:** RUSTSEC-2023-0087

## What is GHSA-pqpw-89w5-82v5?

GHSA-pqpw-89w5-82v5 is a memory corruption vulnerability in simd-json-derive, published on 14 Oct 2023. 

### Official description

An invalid use of `MaybeUninit::uninit().assume_init()` in `simd-json-derive`'s derive macro can cause undefined behavior. The original code used `MaybeUninit` to avoid initialisation of the struct and then set the fields using `ptr::write`. The undefined behavior triggered by this misuse of `MaybeUninit` can lead to invlaid memory access and panics in binaries compiled in release mode (aka simd-json-derive prior to version 0.12 has UB and optimizes into some nonsense)

The version `0.12.0` removes this section of code, avoiding the use of MaybeUninit alltogether.

## Which versions are affected by GHSA-pqpw-89w5-82v5?

3 open source packages ship an affected version, including simd-json-derive.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `simd-json-derive` | crates.io | All versions | 0.12.0 |
| `simd-json-derive` | crates.io | All versions | 0.12.0 |
| `simd-json-derive` | crates.io | From 0.0.0-0 | 0.12.0 |

## How do I fix GHSA-pqpw-89w5-82v5?

Upgrade simd-json-derive to 0.12.0 or later.

## Is GHSA-pqpw-89w5-82v5 being exploited?

There is no known exploitation of GHSA-pqpw-89w5-82v5 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-pqpw-89w5-82v5 and fix it if it is affected.

What it is: GHSA-pqpw-89w5-82v5 is a memory corruption vulnerability in simd-json-derive, published on 14 Oct 2023. 
Exploitation: There is no known exploitation of GHSA-pqpw-89w5-82v5 in the wild and no public exploit code.

Affected packages and fixed versions:
- simd-json-derive (crates.io): affected all versions; fixed in 0.12.0
- simd-json-derive (crates.io): affected all versions; fixed in 0.12.0
- simd-json-derive (crates.io): affected from 0.0.0-0; fixed in 0.12.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-pqpw-89w5-82v5/ (Markdown: https://insights.sbomify.com/GHSA-pqpw-89w5-82v5/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-pqpw-89w5-82v5

---
From sbomify Insights: https://insights.sbomify.com/GHSA-pqpw-89w5-82v5/
Summaries are generated and may contain mistakes; the official description above is the record.
