# GHSA-mpg5-fvwp-42m2: Unsoundness in `dashmap` references

> A memory safety flaw in the dashmap Rust library allows references to outlive locks, causing undefined behavior and potential application 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:** 10 Jan 2022
- **Also known as:** RUSTSEC-2022-0002

## What is GHSA-mpg5-fvwp-42m2?

GHSA-mpg5-fvwp-42m2 is a memory corruption vulnerability in dashmap, published on 10 Jan 2022. 

### Official description

Reference returned by some methods of `Ref` (and similar types) may outlive the `Ref` and escape the lock.
This causes undefined behavior and may result in a segfault.

More information in [`dashmap#167`](https://github.com/xacrimon/dashmap/issues/167) issue.

## Which versions are affected by GHSA-mpg5-fvwp-42m2?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `dashmap` | crates.io | From 5.0.0 | 5.1.0 |
| `dashmap` | crates.io | From 5.0.0 | 5.1.0 |
| `dashmap` | crates.io | From 5.0.0 | 5.1.0 |

## How do I fix GHSA-mpg5-fvwp-42m2?

Upgrade dashmap to 5.1.0 or later.

## Is GHSA-mpg5-fvwp-42m2 being exploited?

There is no known exploitation of GHSA-mpg5-fvwp-42m2 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-mpg5-fvwp-42m2 and fix it if it is affected.

What it is: GHSA-mpg5-fvwp-42m2 is a memory corruption vulnerability in dashmap, published on 10 Jan 2022. 
Exploitation: There is no known exploitation of GHSA-mpg5-fvwp-42m2 in the wild and no public exploit code.

Affected packages and fixed versions:
- dashmap (crates.io): affected from 5.0.0; fixed in 5.1.0
- dashmap (crates.io): affected from 5.0.0; fixed in 5.1.0
- dashmap (crates.io): affected from 5.0.0; fixed in 5.1.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-mpg5-fvwp-42m2/ (Markdown: https://insights.sbomify.com/GHSA-mpg5-fvwp-42m2/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-mpg5-fvwp-42m2

---
From sbomify Insights: https://insights.sbomify.com/GHSA-mpg5-fvwp-42m2/
Summaries are generated and may contain mistakes; the official description above is the record.
