# CVE-2022-21658: Race condition in std::fs::remove\_dir\_all in rustlang

- Priority: **Prioritise**
- Reason: Public exploit (GitHub, Date unknown)
- Next step: Check applicability and the vendor advisory: no fix release is recorded here
- Status: published
- Published: 2022-01-20 · Modified: 2025-04-22
- Aliases: MGASA-2022-0044, SUSE-SU-2022:0149-1, SUSE-SU-2022:0171-1, SUSE-SU-2022:0175-1, SUSE-SU-2022:0200-1, SUSE-SU-2022:0491-1, SUSE-SU-2022:0843-1, openSUSE-SU-2022:0149-1, RHSA-2022:1894, UBUNTU-CVE-2022-21658, DEBIAN-CVE-2022-21658, openSUSE-SU-2022:0171-1, openSUSE-SU-2022:0175-1, openSUSE-SU-2022:0491-1, openSUSE-SU-2022:0843-1, openSUSE-SU-2024:11767-1, openSUSE-SU-2024:11768-1, openSUSE-SU-2024:11769-1
- Record: https://cvemate.com/vulnerability/CVE-2022-21658 · JSON: https://cvemate.com/vulnerability/CVE-2022-21658/json

## Description

```text
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.
```

## Signals

- CVSS: 7.3 high (v3.1, CVE.org) CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:H
- EPSS: 1.456%, percentile 74.372%, as of 2026-12-04
- Known exploited (KEV): CISA not listed, ENISA not listed, CIRCL not listed
- Ransomware use: none recorded
- Public exploits: 2 (github, reference)

## Affected (first 20 of 69)

- apple ipados: \< 15.4
- apple iphone\_os: \< 15.4
- apple macos: ≥ 12.0.0, \< 12.3
- apple tvos: \< 15.4
- apple watchos: \< 8.5
- debian rustc (Debian): \< 1.57.0+dfsg1-1
- ubuntu rustc (Ubuntu): All versions (No fix recorded) \| \< 1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~20.04.2
- fedoraproject fedora: 34 \| 35
- mageia rust (Mageia): \< 1.57.0-1.1.mga8
- opensuse libredwg&distro=openSUSE Leap 15.3 (openSUSE): \< 0.12.5-bp153.2.3.1
- opensuse rust1.55&distro=openSUSE Leap 15.3 (openSUSE): \< 1.55.0-150300.7.6.1
- opensuse rust1.56&distro=openSUSE Leap 15.3 (openSUSE): \< 1.56.1-150300.7.6.1
- opensuse rust1.56&distro=openSUSE Tumbleweed (openSUSE): \< 1.56.1-4.1
- opensuse rust1.57&distro=openSUSE Leap 15.3 (openSUSE): \< 1.57.0-150300.7.7.1
- opensuse rust1.57&distro=openSUSE Tumbleweed (openSUSE): \< 1.57.0-3.1
- opensuse rust1.58&distro=openSUSE Leap 15.3 (openSUSE): \< 1.58.0-150300.7.3.1
- opensuse rust1.58&distro=openSUSE Tumbleweed (openSUSE): \< 1.58.0-2.1
- opensuse rust1.59&distro=openSUSE Leap 15.3 (openSUSE): \< 1.59.0-150300.7.4.2
- opensuse rust&distro=openSUSE Leap 15.3 (openSUSE): \< 1.53.0-22.1 \| \< 1.59.0-150300.21.20.1
- redhat cargo (Red Hat): \< 0:1.58.1-1.module+el8.6.0+14021+586eff1a

## References (first 20 of 45)

- <https://github.com/rust-lang/rust/security/advisories/GHSA-r9cc-f5pr-p3j2>
- <https://github.com/rust-lang/rust/pull/93110>
- <https://github.com/rust-lang/rust/pull/93110/commits/32ed6e599bb4722efefd78bbc9cd7ec4613cb946>
- <https://github.com/rust-lang/rust/pull/93110/commits/406cc071d6cfdfdb678bf3d83d766851de95abaf>
- <https://github.com/rust-lang/rust/pull/93110/commits/4f0ad1c92ca08da6e8dc17838070975762f59714>
- <https://blog.rust-lang.org/2022/01/20/cve-2022-21658.html>
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/BK32QZLHDC2OVLPKTUHNT2G3VHWHD4LX/>
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/C63NH72Q7UHJM5V3IVYRI7LVBGGFQMSQ/>
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/CKGTACKMKAPRDPWPTU26GYWBELIRFF5N/>
- <https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/7JKZDTBMGAWIFJSNWKBMPO5EAKRR4BEW/>
- <https://support.apple.com/kb/HT213183>
- <https://support.apple.com/kb/HT213182>
- <https://support.apple.com/kb/HT213186>
- <https://support.apple.com/kb/HT213193>
- <https://security.gentoo.org/glsa/202210-09>
- <https://advisories.mageia.org/MGASA-2022-0044.html>
- <https://bugs.mageia.org/show_bug.cgi?id=29912>
- <https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html>
- <https://www.suse.com/support/update/announcement/2022/suse-su-20220149-1/>
- <https://bugzilla.suse.com/1194767>

---

Data as of 2026-12-05T09:59:52.254Z. The priority label is CveMate's own model from public evidence, not an official rating, and it knows nothing about your assets. How labels are decided: https://cvemate.com/faq#priority
