Skip to content
FlawDB
Sign in
Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

CVE-2022-21658

HIGH 7.3PoCEPSS 66%

Race condition in std::fs::remove_dir_all in rustlang

Mitigation

  • Upgrade rust to 1.58.1 or later.

Who should check

  • Anyone running rust-lang rust < 1.58.1

Vulnerability facts

Affected
rust-lang rust < 1.58.1
Fixed in
rust-lang rust 1.58.1
Exploited in the wild
Not in CISA KEV
Public exploit / PoC
Yes: see the exploit references below
Remote exploitation
Not remotely exploitable (local or adjacent access needed)
CVSS
7.3 (v3.1, CNA)CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:HOpen in CVSS calculator
Show all 8 CVSS metrics
  • Attack vector: Local
  • Attack complexity: Low
  • Privileges required: Low
  • User interaction: None
  • Scope: Changed (impact reaches other components)
  • Confidentiality impact: None
  • Integrity impact: Low
  • Availability impact: High
EPSS
1.12% chance of exploitation in 30 days (percentile 66, 2026-11-26)
CWE
CWE-363, CWE-367
Published
Modified

Description

Rust is a multi-paradigm, general-purpose programming language designed for performance and safety, especially safe concurrency. The Rust Security Response WG was notified that the `std::fs::remove_dir_all` standard library function is vulnerable a race condition enabling symlink following (CWE-363). An attacker could use this security issue to trick a privileged program into deleting files and directories the attacker couldn't otherwise access or delete. Rust 1.0.0 through Rust 1.58.0 is affected by this vulnerability with 1.58.1 containing a patch. Note that the following build targets don't have usable APIs to properly mitigate the attack, and are thus still vulnerable even with a patched toolchain: macOS before version 10.10 (Yosemite) and REDOX. We recommend everyone to update to Rust 1.58.1 as soon as possible, especially people developing programs expected to run in privileged contexts (including system daemons and setuid binaries), as those have the highest risk of being affected by this. Note that adding checks in your codebase before calling remove_dir_all will not mitigate the vulnerability, as they would also be vulnerable to race conditions like remove_dir_all itself. The existing mitigation is working as intended outside of race conditions.

Affected and fixed versions

Package / productAffectedFixedSource
rust-lang rust< 1.58.1—cvelist

Check your systems with an agent

Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.

Check whether anything I run is affected by CVE-2022-21658. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2022-21658.md
Affected: rust-lang rust < 1.58.1
Fixed in: rust-lang rust 1.58.1

Steps:
1. Search this machine and project for rust-lang rust: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.

References

FAQ

Is CVE-2022-21658 being exploited?

There is no confirmed exploitation: CVE-2022-21658 is not in the CISA Known Exploited Vulnerabilities catalog. Public exploit code or a proof of concept is available. EPSS estimates a 1.12% chance of exploitation in the next 30 days (as of 2026-11-26).

How serious is CVE-2022-21658?

High: CVSS 7.3 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

Which versions are affected by CVE-2022-21658?

rust-lang rust < 1.58.1.

Is there a fix for CVE-2022-21658?

Yes. Fixed in rust-lang rust 1.58.1. Upgrade rust to 1.58.1 or later.

How do I check if I'm affected by CVE-2022-21658?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

Sponsors