Read the docs
TI-2022-06036 Aliases CVE-2022-21658

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

Priority HIGH 65CWE-363Published · Updated

Key facts

Attack vector
Local
Privileges required
Low
User interaction
None
Attack complexity
Low
Impact type
—
Confidentiality · integrity · availability
None · Low · High
Fix status
Partial Red Hat: 1 fixed, 2 without a fix

Attack profile from CVSS 3.1 · CNA. Fix status from CNA and Red Hat.

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.

Why it matters now

Exploitation Proof of concept CISA SSVC · not in CISA KEV
EPSS 0.01376 72nd percentileScored 2026-11-07
Public exploit Yes 2 exploit referencesTagged by NVD
Fix Partial rust (rust-lang): 1.58.1Red Hat: 1 advisoryRed Hat: 1 fixed, 2 without a fix

SSVC decision points

CISA ADP · SSVC 2.0.3

Exploitation
Poc
Automatable
No
Technical impact
Partial

The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.

Affected products

VendorProductAffected versionsFixed inStatusSource
rust-langrustbefore 1.58.11.58.1Patch availableCNA
  • rust Vendorrust-lang Affected before 1.58.1 Fixed in 1.58.1 Patch available CNA

CPE configurations NVD · 8

CPEVersionsRoleVendor
cpe:2.3:a:rust-lang:rust:*:*:*:*:*:*:*:*1.0.0 – 1.58.0Vulnerablerust-lang
cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*34VulnerableFedoraproject
cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*35VulnerableFedoraproject
cpe:2.3:o:apple:ipados:*:*:*:*:*:*:*:*before 15.4VulnerableApple
cpe:2.3:o:apple:iphone_os:*:*:*:*:*:*:*:*before 15.4VulnerableApple
cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*12.0.0 to before 12.3VulnerableApple
cpe:2.3:o:apple:tvos:*:*:*:*:*:*:*:*before 15.4VulnerableApple
cpe:2.3:o:apple:watchos:*:*:*:*:*:*:*:*before 8.5VulnerableApple
  • cpe:2.3:a:rust-lang:rust:*:*:*:*:*:*:*:* Versions 1.0.0 – 1.58.0 Vulnerable ·rust-lang
  • cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:* Versions 34 Vulnerable ·Fedoraproject
  • cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:* Versions 35 Vulnerable ·Fedoraproject
  • cpe:2.3:o:apple:ipados:*:*:*:*:*:*:*:* Versions before 15.4 Vulnerable ·Apple
  • cpe:2.3:o:apple:iphone_os:*:*:*:*:*:*:*:* Versions before 15.4 Vulnerable ·Apple
  • cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:* Versions 12.0.0 to before 12.3 Vulnerable ·Apple
  • cpe:2.3:o:apple:tvos:*:*:*:*:*:*:*:* Versions before 15.4 Vulnerable ·Apple
  • cpe:2.3:o:apple:watchos:*:*:*:*:*:*:*:* Versions before 8.5 Vulnerable ·Apple

Remediation

  • Fix · CNA rust (rust-lang) Fixed in 1.58.1

Red Hat 1 advisory

  • RHSA-2022:1894 Released 2022-05-10 · Red Hat rating Moderate
    rust-toolset:rhel8 security, bug fix, and enhancement update
    • Red Hat Enterprise Linux AppStream (v. 8) cargo-1.58.1-1.module+el8.6.0+14021+586eff1a.aarch64::rust-toolset:rhel8, cargo-1.58.1-1.module+el8.6.0+14021+586eff1a.ppc64le::rust-toolset:rhel8, cargo-1.58.1-1.module+el8.6.0+14021+586eff1a.s390x::rust-toolset:rhel8 +46

Vendor assessments

Red Hat

Red Hat rating: Moderate. Red Hat's page for this CVE →

ProductStatusPlan or fix
Red Hat Enterprise Linux 8AffectedNo fix planned: Will not fix
Red Hat Enterprise Linux 9AffectedNo fix planned: Will not fix
Red Hat Enterprise Linux AppStream (v. 8)Fixed RHSA-2022:1894
Not affected: 2 products
  • Red Hat Enterprise Linux 9
  • Red Hat OpenShift Container Platform 4

Timeline

  1. 2026-10-02 Threatist record created from CVE-2022-21658

References

  • TI-2024-16197 Rusts's `std::process::Command` did not properly escape arguments of batch files on Windows CVSS 3.1CRITICAL 10.0
  • TI-2024-03325 Command injection vulnerability in programing languages on Microsoft Windows operating system. CVSS 3.1CRITICAL 9.8
  • TI-2018-16034 The Rust Programming Language Standard Library version 1.29.0, 1.28.0, 1.27.2, 1.27.1… CVSS 3.0CRITICAL 9.8
  • TI-2021-11383 In the standard library in Rust before 1.52.0, a double free can occur in the… CVSS 3.1CRITICAL 9.8
  • TI-2021-09849 In the standard library in Rust before 1.52.0, the Zip implementation can report an… CVSS 3.1CRITICAL 9.8
  • TI-2020-18601 In the standard library in Rust before 1.49.0, VecDeque::make_contiguous has a bug that… CVSS 3.1CRITICAL 9.8
See all 23 →

Sources