CVE-2022-21658Race condition in std::fs::remove_dir_all in rustlang
- 7.3HighCVSS base score
- 1.5%Exploitation in 30 daysEPSS · top 26% of all CVEs
- NoKnown exploitednot in CISA's KEV catalog
- YesPublic exploitsa reference or SSVC says so
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.
Public exploit
An exploit or proof of concept is public: anyone can try it against an unpatched system. CISA's SSVC rates its exploitation: a proof of concept is public.
Timeline
ID reserved
By GitHub_M
- 2 months later
· 2 months later
Published
- 3 years later
· 3 years later
Record updated
Changes after publication (a new score, a public exploit, EPSS crossing 1, 10 or 50 %, leaving KEV) are kept since November 2026; earlier ones are not known.
Scores
| Scored by | CVSS | Score | Vector |
|---|---|---|---|
| GitHub_MCNA (assigner) | 3.1 | High7.3 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:H |
| NVDNVD · Modified | 3.1 | Medium6.3 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H |
- EPSS (exploitation in 30 days)
- 1.5% · top 26% of all CVEs (13 Nov 2026)
- CISA SSVC
- Exploitation: poc · Automatable: no · Technical impact: partial
The list uses the assigner's score when there is one, then CISA's, then NVD's: High 7.3.
Affected products
References
References15
- https://github.com/rust-lang/rust/security/advisories/GHSA-r9cc-f5pr-p3j2 (opens in a new tab)x_transferred
- https://github.com/rust-lang/rust/pull/93110 (opens in a new tab)x_transferred
- https://github.com/rust-lang/rust/pull/93110/commits/32ed6e599bb4722efefd78bbc9cd7ec4613cb946 (opens in a new tab)x_transferred
- https://github.com/rust-lang/rust/pull/93110/commits/406cc071d6cfdfdb678bf3d83d766851de95abaf (opens in a new tab)x_transferred
- https://github.com/rust-lang/rust/pull/93110/commits/4f0ad1c92ca08da6e8dc17838070975762f59714 (opens in a new tab)x_transferred
- https://blog.rust-lang.org/2022/01/20/cve-2022-21658.html (opens in a new tab)x_transferred
- FEDORA-2022-1bafa3fc91 (opens in a new tab)vendor-advisoryx_transferred
- FEDORA-2022-2c73789458 (opens in a new tab)vendor-advisoryx_transferred
- FEDORA-2022-1b76e3a192 (opens in a new tab)vendor-advisoryx_transferred
- FEDORA-2022-06569a0a60 (opens in a new tab)vendor-advisoryx_transferred
- https://support.apple.com/kb/HT213183 (opens in a new tab)x_transferred
- https://support.apple.com/kb/HT213182 (opens in a new tab)x_transferred
- https://support.apple.com/kb/HT213186 (opens in a new tab)x_transferred
- https://support.apple.com/kb/HT213193 (opens in a new tab)x_transferred
- GLSA-202210-09 (opens in a new tab)vendor-advisoryx_transferred
Sources
The same CVE in the primary databases and aggregators, to check against.
- CVE.org record (opens in a new tab)
- CVE List JSON (GitHub) (opens in a new tab)
- NVD (opens in a new tab)
- FIRST EPSS (opens in a new tab)
- EUVD EUVD-2022-26876 (opens in a new tab)
- OSV.dev (opens in a new tab)
- GitHub Advisories (opens in a new tab)
- CIRCL Vulnerability-Lookup (opens in a new tab)
Badge for a README or a ticket
[](https://cveledger.app/cve/CVE-2022-21658)Record last updated .