CVE-2022-21658 json
Race condition in std::fs::remove_dir_all in rustlang
published 2022-01-20 4 y ago modified 2026-06-17 4 mo ago also EUVD-2022-26876
- cvss
- 7.3
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 1.4%
- EPSS 1.4% chance of exploitation in 30 days, percentile 72%
- public exploits
- 0
- none known
Summary
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.
Patch / fix
- apple ipados 15.4
- apple iphone_os 15.4
- apple macos 12.3
- apple tvos 15.4
- apple watchos 8.5
- rustc Debian 14, Debian 13, Debian 12 1.57.0+dfsg1-1
debian advisories DEBIAN-CVE-2022-21658
- rustc Ubuntu 20.04 LTS 1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~20.04.2
ubuntu advisories UBUNTU-CVE-2022-21658
Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- rls RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- rust RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- cargo RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- clippy RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- rustfmt RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- rust-gdb RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- rust-src RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
- rust-lldb RHEL 8 1.58.1-1.module+el8.6.0+14021+586eff1a
red hat advisories RHSA-2022:1894
- rust1.59 SLE Module for Development Tools 15 SP3 1.59.0-150300.7.4.2
- rust SLE Module for Development Tools 15 SP3 1.59.0-150300.21.20.1
- rust1.58 SLE Module for Development Tools 15 SP3 1.58.0-150300.7.3.1
- rust SLES for SAP 15 SP2, SLES for SAP 15 SP1, SLES 15 SP2-LTSS +13 more 1.53.0-22.1
- rust SLES for SAP 15, SLES 15-LTSS, SLE High Performance Computing 15-LTSS +1 more 1.53.0-3.40.1
- rust1.57 SLE Module for Development Tools 15 SP3 1.57.0-150300.7.7.1
- rust1.55 SLE Module for Development Tools 15 SP3 1.55.0-150300.7.6.1
- rust1.56 SLE Module for Development Tools 15 SP3 1.56.1-150300.7.6.1
suse advisories SUSE-SU-2022:0843-1SUSE-SU-2022:0491-1SUSE-SU-2022:0200-1SUSE-SU-2022:0175-1SUSE-SU-2022:0171-1SUSE-SU-2022:0149-1
- rust1.56 openSUSE Tumbleweed 1.56.1-4.1
- rust1.57 openSUSE Tumbleweed 1.57.0-3.1
- rust1.58 openSUSE Tumbleweed 1.58.0-2.1
- rust1.59 openSUSE Leap 15.3 1.59.0-150300.7.4.2
- rust openSUSE Leap 15.3 1.59.0-150300.21.20.1
- rust1.58 openSUSE Leap 15.3 1.58.0-150300.7.3.1
- rust openSUSE Leap 15.3 1.53.0-22.1
- rust1.57 openSUSE Leap 15.3 1.57.0-150300.7.7.1
opensuse advisories openSUSE-SU-2024:11767-1openSUSE-SU-2024:11768-1openSUSE-SU-2024:11769-1openSUSE-SU-2022:0843-1openSUSE-SU-2022:0491-1openSUSE-SU-2022:0175-1
- rls AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- rust AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- cargo AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- clippy AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- rustfmt AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- rust-gdb AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- rust-src AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
- rust-lldb AlmaLinux 8 1.58.1-1.module_el8.6.0+2748+176088b3
almalinux advisories ALSA-2022:1894
- rust Rocky Linux 8 1.58.1-1.module+el8.6.0+826+60f85975
- rust-toolset Rocky Linux 8 1.58.1-1.module+el8.6.0+826+60f85975
rocky linux advisories RLSA-2022:1894
- github.com/rust-lang/rust#93110 commit
- github.com/rust-lang/rust#93110 commit
- github.com/rust-lang/rust#93110 commit
- github.com/rust-lang/rust#93110 pull request
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2022-21658 updated cvss 5.3
rust: Race condition in remove_dir_all leading to removal of files outside of the directory being removed
-
Red Hat Enterprise Linux 8 stratisd, stratisd-dracut Red Hat Enterprise Linux 9 stratisd, stratisd-tools, stratisd-dracutaffected: workaround, no fix planned “Will not fix”
-
Red Hat Enterprise Linux AppStream (v. 8) rls 1.58.1-1.module+el8.6.0+14021+586eff1a, rust 1.58.1-1.module+el8.6.0+14021+586eff1a, cargo 1.58.1-1.module+el8.6.0+14021+586eff1a, clippy 1.58.1-1.module+el8.6.0+14021+586eff1a, rustfmt 1.58.1-1.module+el8.6.0+14021+586eff1a, rust-gdb 1.58.1-1.module+el8.6.0+14021+586eff1a, +7 morefixed: vendor fix RHSA-2022:1894
-
Red Hat Enterprise Linux 9 rust, cargo, clippy, rustfmt, rust-gdb, rust-src, +8 more Red Hat OpenShift Container Platform 4 kata-containersnot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
cisa ICSA-25-100-02 updated cvss 7.3
Siemens SIDIS Prime
-
Siemens SIDIS Prime <V4.0.700affected: fixed in V4.0.700
Facts from CISA's republication of the vendor's own advisory (CSAF); the linked advisory is the authoritative source. CISA notification · csaf
CISA SSVC
- Exploitation
- Proof of concept is public
- Automatable
- no
- Technical impact
- partial
- Assessed
- 18 mo ago
Exploit prediction
1.38% chance of exploitation in the next 30 days, higher than 72% of all scored CVEs (FIRST EPSS, 2026-11-08).
Exploits and checks
- github.com https://github.com/rust-lang/rust/security/advisories/GHSA-r9cc-f5pr-p3j2 referenced PoC, tagged "exploit" by a source, unverified
- blog.rust-lang.org https://blog.rust-lang.org/2022/01/20/cve-2022-21658.html referenced PoC, tagged "exploit" by a source, unverified
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 7.3 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:N/I:L/A:H |
| NVD | 3.1 | 6.3 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H |
| NVD | 2.0 | 3.3 | AV:L/AC:M/Au:N/C:N/I:P/A:P |
Affected products
- rust-lang rust
Classification
References
-
github.com
/rust-lang/rust/pull/93110
patch, third-party-advisory
-
github.com
/rust-lang/rust/pull/93110/commits/32ed6e599bb4722efefd78bbc9cd7ec4613cb946
patch, third-party-advisory
-
github.com
/rust-lang/rust/pull/93110/commits/406cc071d6cfdfdb678bf3d83d766851de95abaf
patch, third-party-advisory
-
github.com
/rust-lang/rust/pull/93110/commits/4f0ad1c92ca08da6e8dc17838070975762f59714
patch, third-party-advisory
-
github.com
/rust-lang/rust/security/advisories/GHSA-r9cc-f5pr-p3j2
exploit, mitigation, third-party-advisory
-
blog.rust-lang.org
/2022/01/20/cve-2022-21658.html
exploit, mitigation, vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/BK32QZLHDC2OVLPKTUHNT2G3VHWHD4LX/
vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/C63NH72Q7UHJM5V3IVYRI7LVBGGFQMSQ/
vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/CKGTACKMKAPRDPWPTU26GYWBELIRFF5N/
vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce%40lists.fedoraproject.org/message/7JKZDTBMGAWIFJSNWKBMPO5EAKRR4BEW/
vendor-advisory
-
security.gentoo.org
/glsa/202210-09
vendor-advisory, third-party-advisory
-
support.apple.com
/kb/HT213183
third-party-advisory
-
support.apple.com
/kb/HT213182
third-party-advisory
-
support.apple.com
/kb/HT213186
third-party-advisory
-
support.apple.com
/kb/HT213193
third-party-advisory
Sources
- CVE List CVE-2022-21658
- NVD CVE-2022-21658
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.