Vulnerability
CVE-2022-21658
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.
24 advisories report this vulnerability, across 11 ecosystems.
Advisories
-
ALAS2-2022-1817
Amazon Linux 2 2017.12 - ALAS2-2022-1817: medium priority package update for rust
-
ALSA-2022:1894
Moderate: rust-toolset:rhel8 security, bug fix, and enhancement update
-
AZL-8337
CVE-2022-21658 affecting package rust for versions less than 1.59.0-1
-
CNA-CVE-2022-21658
Race condition in std::fs::remove_dir_all in rustlang
-
DEBIAN-CVE-2022-21658
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…
-
ELSA-2022-1894
ELSA-2022-1894: rust-toolset:ol8 security, bug fix, and enhancement update (MODERATE)
-
RHSA-2022:1894
Red Hat Security Advisory: rust-toolset:rhel8 security, bug fix, and enhancement update
-
RHVEX-CVE-2022-21658
rust: Race condition in remove_dir_all leading to removal of files outside of the directory being removed
-
RLSA-2022:1894
Moderate: rust-toolset:rhel8 security, bug fix, and enhancement update
-
SUSE-SU-2022:0149-1
Security update for rust1.56
-
SUSE-SU-2022:0171-1
Security update for rust1.55
-
SUSE-SU-2022:0175-1
Security update for rust1.57
-
SUSE-SU-2022:0200-1
Security update for rust
-
SUSE-SU-2022:0491-1
Security update for rust
-
SUSE-SU-2022:0843-1
Security update for rust, rust1.58, rust1.59
-
UBUNTU-CVE-2022-21658
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…
-
openSUSE-SU-2022:0149-1
Security update for rust1.56
-
openSUSE-SU-2022:0171-1
Security update for rust1.55
-
openSUSE-SU-2022:0175-1
Security update for rust1.57
-
openSUSE-SU-2022:0491-1
Security update for rust
-
openSUSE-SU-2022:0843-1
Security update for rust, rust1.58, rust1.59
-
openSUSE-SU-2024:11767-1
cargo1.56-1.56.1-4.1 on GA media
-
openSUSE-SU-2024:11768-1
cargo1.57-1.57.0-3.1 on GA media
-
openSUSE-SU-2024:11769-1
cargo1.58-1.58.0-2.1 on GA media
References
- https://blog.rust-lang.org/2022/01/20/cve-2022-21658.html
- 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://github.com/rust-lang/rust/security/advisories/GHSA-r9cc-f5pr-p3j2
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/7JKZDTBMGAWIFJSNWKBMPO5EAKRR4BEW/
- 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://security.gentoo.org/glsa/202210-09
- https://support.apple.com/kb/HT213182
- https://support.apple.com/kb/HT213183
- https://support.apple.com/kb/HT213186
- https://support.apple.com/kb/HT213193