# GHSA-qm2p-4w45-v2vr: grcov has an out of bounds write triggered by crafted coverage data

> An attacker can achieve arbitrary code execution by providing crafted coverage data to the grcov tool, which fails to validate array indices.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 13 Jan 2025
- **Also known as:** RUSTSEC-2025-0005

## What is GHSA-qm2p-4w45-v2vr?

GHSA-qm2p-4w45-v2vr is a memory corruption vulnerability in grcov, published on 13 Jan 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

Function `grcov::covdir::get_coverage` uses the `unsafe` function `get_unchecked_mut` without validating that the index is in bounds.

This results in memory corruption, and could potentially allow arbitrary code execution provided that an attacker can feed the tool crafted coverage data.

## Which versions are affected by GHSA-qm2p-4w45-v2vr?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `grcov` | crates.io | All versions | 0.8.20 |
| `grcov` | crates.io | All versions | 0.8.20 |
| `grcov` | crates.io | From 0.0.0-0 | 0.8.21-0 |

## How do I fix GHSA-qm2p-4w45-v2vr?

Upgrade grcov to a fixed version for your release line: 0.8.20 or 0.8.21-0.

## Is GHSA-qm2p-4w45-v2vr being exploited?

There is no known exploitation of GHSA-qm2p-4w45-v2vr in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-qm2p-4w45-v2vr and fix it if it is affected.

What it is: GHSA-qm2p-4w45-v2vr is a memory corruption vulnerability in grcov, published on 13 Jan 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-qm2p-4w45-v2vr in the wild and no public exploit code.

Affected packages and fixed versions:
- grcov (crates.io): affected all versions; fixed in 0.8.20
- grcov (crates.io): affected all versions; fixed in 0.8.20
- grcov (crates.io): affected from 0.0.0-0; fixed in 0.8.21-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-qm2p-4w45-v2vr/ (Markdown: https://insights.sbomify.com/GHSA-qm2p-4w45-v2vr/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-qm2p-4w45-v2vr

---
From sbomify Insights: https://insights.sbomify.com/GHSA-qm2p-4w45-v2vr/
Summaries are generated and may contain mistakes; the official description above is the record.
