# GHSA-f2wx-xjfw-xjv6: topgrade Time-of-check Time-of-use (TOCTOU) Race Condition in remove_dir_all

> A race condition in the remove_dir_all function allows attackers to manipulate file system operations, potentially leading to privilege escalation or data modification.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Jul 2023

## What is GHSA-f2wx-xjfw-xjv6?

GHSA-f2wx-xjfw-xjv6 is a vulnerability in topgrade, published on 17 Jul 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

### Summary
https://github.com/advisories/GHSA-mc8h-8q98-g5hr
https://github.com/XAMPPRocky/remove_dir_all/commit/7247a8b6ee59fc99bbb69ca6b3ca4bfd8c809ead

`tempfile` v0.4.26 ships with affected `remove_dir_all` v0.5.3 and so blocks my deployment of v12 to openSUSE distribution because it imposes a clean `cargo audit`

Updating `tempfile` is warranted

## Which versions are affected by GHSA-f2wx-xjfw-xjv6?

2 open source packages ship an affected version, including topgrade.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `topgrade` | crates.io | All versions | 12.0.1 |
| `topgrade` | crates.io | All versions | 12.0.1 |

## How do I fix GHSA-f2wx-xjfw-xjv6?

Upgrade topgrade to 12.0.1 or later.

## Is GHSA-f2wx-xjfw-xjv6 being exploited?

There is no known exploitation of GHSA-f2wx-xjfw-xjv6 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-f2wx-xjfw-xjv6 and fix it if it is affected.

What it is: GHSA-f2wx-xjfw-xjv6 is a vulnerability in topgrade, published on 17 Jul 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-f2wx-xjfw-xjv6 in the wild and no public exploit code.

Affected packages and fixed versions:
- topgrade (crates.io): affected all versions; fixed in 12.0.1
- topgrade (crates.io): affected all versions; fixed in 12.0.1

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-f2wx-xjfw-xjv6/ (Markdown: https://insights.sbomify.com/GHSA-f2wx-xjfw-xjv6/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-f2wx-xjfw-xjv6

---
From sbomify Insights: https://insights.sbomify.com/GHSA-f2wx-xjfw-xjv6/
Summaries are generated and may contain mistakes; the official description above is the record.
