ID CVE-2022-21658
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.
References
Vulnerable Configurations
  • cpe:2.3:a:rust-lang:rust:1.0.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.0.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.0.0:-:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.0.0:-:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.0.0:alpha:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.0.0:alpha:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.0.0:alpha2:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.0.0:alpha2:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.0.0:alpha_2:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.0.0:alpha_2:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.0.0:beta:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.0.0:beta:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.1.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.1.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.2.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.2.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.3.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.3.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.4.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.4.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.5.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.5.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.6.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.6.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.7.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.7.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.8.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.8.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.9.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.9.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.10.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.10.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.11.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.11.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.12.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.12.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.12.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.12.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.13.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.13.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.14.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.14.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.15.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.15.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.15.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.15.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.16.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.16.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.17.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.17.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.18.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.18.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.19.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.19.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.20.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.20.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.21.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.21.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.22.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.22.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.22.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.22.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.23.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.23.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.24.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.24.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.24.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.24.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.25.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.25.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.26.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.26.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.26.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.26.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.26.2:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.26.2:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.27.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.27.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.27.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.27.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.27.2:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.27.2:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.28.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.28.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.29.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.29.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.29.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.29.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.29.2:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.29.2:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.30.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.30.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.30.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.30.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.31.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.31.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.31.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.31.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.32.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.32.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.33.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.33.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.34.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.34.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.34.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.34.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.34.2:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.34.2:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.35.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.35.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.36.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.36.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.37.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.37.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.38.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.38.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.39.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.39.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.40.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.40.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.41.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.41.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.41.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.41.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.42.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.42.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.43.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.43.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.43.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.43.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.44.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.44.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.44.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.44.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.45.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.45.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.45.1:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.45.1:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.45.2:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.45.2:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.46.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.46.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.47.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.47.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.48.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.48.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.49.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.49.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.50.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.50.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.51.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.51.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.52.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.52.0:*:*:*:*:*:*:*
  • cpe:2.3:a:rust-lang:rust:1.53.0:*:*:*:*:*:*:*
    cpe:2.3:a:rust-lang:rust:1.53.0:*:*:*:*:*:*:*
  • cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*
    cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*
  • cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*
    cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*
CVSS
Base: 3.3 (as of 26-05-2022 - 03:15)
Impact:
Exploitability:
CWE CWE-367
CAPEC
  • Leveraging Race Conditions via Symbolic Links
    This attack leverages the use of symbolic links (Symlinks) in order to write to sensitive files. An attacker can create a Symlink link to a target file not otherwise accessible to her. When the privileged program tries to create a temporary file with the same name as the Symlink link, it will actually write to the target file pointed to by the attackers' Symlink link. If the attacker can insert malicious content in the temporary file she will be writing to the sensitive file by using the Symlink. The race occurs because the system checks if the temporary file exists, then creates the file. The attacker would typically create the Symlink during the interval between the check and the creation of the temporary file.
  • Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
    This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.
Access
VectorComplexityAuthentication
LOCAL MEDIUM NONE
Impact
ConfidentialityIntegrityAvailability
NONE PARTIAL PARTIAL
cvss-vector via4 AV:L/AC:M/Au:N/C:N/I:P/A:P
Last major update 26-05-2022 - 03:15
Published 20-01-2022 - 18:15
Last modified 26-05-2022 - 03:15
Back to Top