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 products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| rust-lang | rust | < 1.58.1 | — |
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | rustc | 1.57.0+dfsg1-1 | — |
| Debian 13 | rustc | 1.57.0+dfsg1-1 | — |
| Debian 12 | rustc | 1.57.0+dfsg1-1 | — |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu 20.04 LTS | rustc | 1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~20.04.2 | — |
Show 2 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu Pro 16.04 LTS | rustc | No fix yet | — |
| Ubuntu Pro 14.04 LTS | rustc | No fix yet | — |
Red Hat
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| RHEL 8 | rls +15 | 1.58.1-1.module+el8.6.0+14021+586eff1a | RHSA-2022:1894 |
AlmaLinux
Errata ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| AlmaLinux 8 | rls +15 | 1.58.1-1.module_el8.6.0+2748+176088b3 | ALSA-2022:1894 |
Rocky Linux
Errata ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Rocky Linux 8 | rust +1 | 1.58.1-1.module+el8.6.0+826+60f85975 | RLSA-2022:1894 |
SUSE
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| SLES 15 SP3 | rust | 1.59.0-150300.21.20.1 | SUSE-SU-2022:0843-1 |
| SLES 15 SP3 | rust1.55 | 1.55.0-150300.7.6.1 | SUSE-SU-2022:0171-1 |
| SLES 15 SP3 | rust1.56 | 1.56.1-150300.7.6.1 | SUSE-SU-2022:0149-1 |
| SLES 15 SP3 | rust1.57 | 1.57.0-150300.7.7.1 | SUSE-SU-2022:0175-1 |
| SLES 15 SP3 | rust1.58 | 1.58.0-150300.7.3.1 | SUSE-SU-2022:0843-1 |
| SLES 15 SP3 | rust1.59 | 1.59.0-150300.7.4.2 | SUSE-SU-2022:0843-1 |
| SLES 15 SP2 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLES 15 SP1 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLES 15 | rust | 1.53.0-3.40.1 | SUSE-SU-2022:0200-1 |
Show 13 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| SLES for SAP 15 SP2 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLES for SAP 15 SP1 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLES for SAP 15 | rust | 1.53.0-3.40.1 | SUSE-SU-2022:0200-1 |
| SLE Real Time 15 SP2 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLE HPC 15 SP2 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLE HPC 15 SP1 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SLE HPC 15 | rust | 1.53.0-3.40.1 | SUSE-SU-2022:0200-1 |
| SUSE Package Hub 15 SP3 | libredwg | 0.12.5-bp153.2.3.1 | openSUSE-SU-2022:0149-1 |
| SUSE Manager Server 4.1 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SUSE Manager Retail Branch Server 4.1 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SUSE Manager Proxy 4.1 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SUSE Enterprise Storage 7 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
| SUSE Enterprise Storage 6 | rust | 1.53.0-22.1 | SUSE-SU-2022:0491-1 |
openSUSE
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| openSUSE Tumbleweed | rust1.56 | 1.56.1-4.1 | openSUSE-SU-2024:11767-1 |
| openSUSE Tumbleweed | rust1.57 | 1.57.0-3.1 | openSUSE-SU-2024:11768-1 |
| openSUSE Tumbleweed | rust1.58 | 1.58.0-2.1 | openSUSE-SU-2024:11769-1 |
| openSUSE Leap 15.3 | libredwg | 0.12.5-bp153.2.3.1 | openSUSE-SU-2022:0149-1 |
| openSUSE Leap 15.3 | rust | 1.53.0-22.1 | openSUSE-SU-2022:0843-1, openSUSE-SU-2022:0491-1 |
| openSUSE Leap 15.3 | rust1.55 | 1.55.0-150300.7.6.1 | openSUSE-SU-2022:0171-1 |
| openSUSE Leap 15.3 | rust1.56 | 1.56.1-150300.7.6.1 | openSUSE-SU-2022:0149-1 |
| openSUSE Leap 15.3 | rust1.57 | 1.57.0-150300.7.7.1 | openSUSE-SU-2022:0175-1 |
| openSUSE Leap 15.3 | rust1.58 | 1.58.0-150300.7.3.1 | openSUSE-SU-2022:0843-1 |
| openSUSE Leap 15.3 | rust1.59 | 1.59.0-150300.7.4.2 | openSUSE-SU-2022:0843-1 |
Amazon Linux
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Amazon Linux 2 | rls +11 | 1.61.0-2.amzn2.0.1 | ALAS2-2022-1817 |
Azure Linux
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Azure Linux 2 (CBL-Mariner) | rust | 1.59.0-1 | — |
Oracle Linux
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Oracle Linux 8 | rls +15 | 1.58.1-1.module+el8.6.0+20563+1eb4e043 | ELSA-2022-1894 |
Public exploits
Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.
GitHub 1 repository
-
sagittarius-a/cve-2022-21658 ★ 2 · Jan 21, 2022
POC for cve-2022-21658
Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.
Advisories 23
- ALSA-2022:1894 Moderate: rust-toolset:rhel8 security, bug fix, and enhancement update AlmaLinux Security Advisories · Oct 29, 2026
- RHSA-2022:1894 Red Hat Security Advisory: rust-toolset:rhel8 security, bug fix, and enhancement update Red Hat Security Advisories (RHSA) · Aug 7, 2026
- RLSA-2022:1894 Moderate: rust-toolset:rhel8 security, bug fix, and enhancement update Rocky Linux Security Advisories · Feb 5, 2026
- openSUSE-SU-2024:11769-1 cargo1.58-1.58.0-2.1 on GA media SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2022:0175-1 Security update for rust1.57 SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2022:0175-1 Security update for rust1.57 SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2024:11767-1 cargo1.56-1.56.1-4.1 on GA media SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2022:0200-1 Security update for rust SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2024:11768-1 cargo1.57-1.57.0-3.1 on GA media SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2022:0149-1 Security update for rust1.56 SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2022:0491-1 Security update for rust SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2022:0843-1 Security update for rust, rust1.58, rust1.59 SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2022:0843-1 Security update for rust, rust1.58, rust1.59 SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2022:0491-1 Security update for rust SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2022:0149-1 Security update for rust1.56 SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2022:0171-1 Security update for rust1.55 SUSE / openSUSE Security Updates · Feb 4, 2026
- ICSA-25-100-02 Siemens SIDIS Prime CISA ICS & IT advisories · May 6, 2025
- SUSE-SU-2022:0171-1 Security update for rust1.55 SUSE / openSUSE Security Updates · May 2, 2025
- NCSC-2025-0106 Kwetsbaarheden verholpen in Siemens producten NCSC-NL (Netherlands) · Apr 8, 2025
- SSA-277137 SSA-277137: Multiple Vulnerabilities in SIDIS Prime Before V4.0.700 Siemens ProductCERT · Apr 8, 2025
- WID-SEC-2023-0561 Xerox FreeFlow Print Server: Mehrere Schwachstellen BSI CERT-Bund (WID) · May 18, 2023
- ALAS2-2022-1817 Moderate: rust security update (Amazon Linux 2) Amazon Linux Security Center (ALAS) · Jul 14, 2022
- ELSA-2022-1894 Moderate: rust-toolset:ol8 security, bug fix, and enhancement update (Oracle Linux 8) Oracle Linux Security Advisories (ELSA) · May 17, 2022
References
- 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
- FEDORA-2022-1bafa3fc91 vendor-advisory
- FEDORA-2022-2c73789458 vendor-advisory
- FEDORA-2022-1b76e3a192 vendor-advisory
- FEDORA-2022-06569a0a60 vendor-advisory
- https://support.apple.com/kb/HT213183
- https://support.apple.com/kb/HT213182
- https://support.apple.com/kb/HT213186
- https://support.apple.com/kb/HT213193
- GLSA-202210-09 vendor-advisory