# GHSA-9c9f-7x9p-4wqp: A malicious coder can get unsound access to TCell or TLCell memory

> A malicious coder can exploit covariance to bypass singleton checks, causing memory corruption and potential code execution in Rust applications using this library.

- **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:** 24 Jan 2022
- **Also known as:** RUSTSEC-2022-0007

## What is GHSA-9c9f-7x9p-4wqp?

GHSA-9c9f-7x9p-4wqp is a memory corruption vulnerability in qcell, published on 24 Jan 2022. 

### Official description

This is impossible to do by accident, but by carefully constructing
marker types to be covariant, a malicious coder can cheat the
singleton check in `TCellOwner` and `TLCellOwner`, giving unsound
access to cell memory.  This could take the form of getting two
mutable references to the same memory, or a mutable reference and an
immutable reference.

The fix is for the crate to internally force the marker type to be
invariant.  This blocks the conversion between covariant types which
Rust normally allows.

## Which versions are affected by GHSA-9c9f-7x9p-4wqp?

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


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

## How do I fix GHSA-9c9f-7x9p-4wqp?

Upgrade qcell to 0.4.3 or later.

## Is GHSA-9c9f-7x9p-4wqp being exploited?

There is no known exploitation of GHSA-9c9f-7x9p-4wqp in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-9c9f-7x9p-4wqp and fix it if it is affected.

What it is: GHSA-9c9f-7x9p-4wqp is a memory corruption vulnerability in qcell, published on 24 Jan 2022. 
Exploitation: There is no known exploitation of GHSA-9c9f-7x9p-4wqp in the wild and no public exploit code.

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

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-9c9f-7x9p-4wqp/ (Markdown: https://insights.sbomify.com/GHSA-9c9f-7x9p-4wqp/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-9c9f-7x9p-4wqp

---
From sbomify Insights: https://insights.sbomify.com/GHSA-9c9f-7x9p-4wqp/
Summaries are generated and may contain mistakes; the official description above is the record.
