PT-2022-4311 · Rust+10 · Rust+10

Florian Weimer

+1

·

Published

2022-01-20

·

Updated

2025-03-24

·

CVE-2022-21658

CVSS v2.0

10

High

VectorAV:N/AC:L/Au:N/C:C/I:C/A:C
Name of the Vulnerable Software and Affected Versions Rust versions 1.0.0 through 1.58.0
Description The std::fs::remove dir all standard library function in Rust is vulnerable to a race condition enabling symlink following. This issue allows an attacker to trick a privileged program into deleting files and directories that the attacker could not otherwise access or delete. The vulnerability is particularly dangerous when the affected application runs with elevated privileges, as it could lead to the deletion of important system files.
Recommendations To resolve the issue, update to Rust 1.58.1 as soon as possible, especially if you are developing programs expected to run in privileged contexts, including system daemons and setuid binaries. For build targets that do not have usable APIs to properly mitigate the attack, such as macOS before version 10.10 (Yosemite) and REDOX, consider alternative mitigation strategies, but note that even with a patched toolchain, these targets are still vulnerable. As a temporary workaround, consider avoiding the use of the std::fs::remove dir all function in privileged contexts until the issue is fully resolved.

Exploit

Fix

Race Condition

Time Of Check To Time Of Use

Found an issue in the description? Have something to add? Feel free to write us 👾

Weakness Enumeration

Related Identifiers

ALSA-2022:1894
ALSA-2022_1894
ALT-PU-2022-1106
ALT-PU-2022-2927
ALT-PU-2023-1135
ALT-PU-2023-4337
AZL-8337
BDU:2022-05167
CESA-2022_1894
CVE-2022-21658
ELSA-2022-1894
GHSA-R9CC-F5PR-P3J2
MGASA-2022-0044
OPENSUSE-SU-2022:0149-1
OPENSUSE-SU-2022:0171-1
OPENSUSE-SU-2022:0175-1
OPENSUSE-SU-2022:0491-1
OPENSUSE-SU-2022:0843-1
OPENSUSE-SU-2022_0149-1
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
RHSA-2022:1894
RHSA-2022_1894
RLSA-2022:1894
RLSA-2022_1894
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
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

Affected Products

Alt Linux
Almalinux
Astra Linux
Centos
Debian
Apple Macos
Red Hat
Red Os
Rocky Linux
Rust
Suse