p PatchFirst

CVE-2022-21658

CVE-2022-21658 · Race condition in std::fs::remove_dir_all in rustlang

This page contains facts from public vulnerability sources. Check the original advisory before updating.

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.

CVSS 7.3 · High · EPSS 1.4% · Fix available

Published
Updated

Stack: system

Affected products and versions

  • rust

    Versions
    • < 1.58.1: Affected

    No fix published

  • rustc Debian:12

    Affected ranges
    • ECOSYSTEM: < 1.57.0+dfsg1-1

    Update to 1.57.0+dfsg1-1

  • rustc Debian:13

    Affected ranges
    • ECOSYSTEM: < 1.57.0+dfsg1-1

    Update to 1.57.0+dfsg1-1

  • rustc Debian:14

    Affected ranges
    • ECOSYSTEM: < 1.57.0+dfsg1-1

    Update to 1.57.0+dfsg1-1

  • rustc Ubuntu:Pro:14.04:LTS

    Versions
    • 1.15.1+dfsg0-1~exp1ubuntu2~14.04.7
    • 1.17.0+dfsg2-8~ubuntu0.14.04.3
    • 1.21.0+dfsg1+llvm-0ubuntu3~14.04.5
    • 1.22.1+dfsg1+llvm-0ubuntu2~14.04.2
    • 1.24.1+dfsg1+llvm-0ubuntu1~14.04.1
    • 1.25.0+dfsg1+llvm-0ubuntu1~14.04.1
    • 1.28.0+dfsg1+llvm-0ubuntu1~14.04.1
    • 1.30.0+dfsg1+llvm-2ubuntu1~14.04.1
    • 1.31.0+dfsg1+llvm-2ubuntu1~14.04.1
    • 1.31.0+dfsg1+llvm-2ubuntu1~14.04.1ubuntu1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • rustc Ubuntu:Pro:16.04:LTS

    Versions
    • 1.7.0+dfsg1-1
    • 1.15.1+dfsg0-1~exp1ubuntu2~16.04.3
    • 1.17.0+dfsg2-8~ubuntu0.16.04.2
    • 1.21.0+dfsg1+llvm-0ubuntu3~16.04.1
    • 1.22.1+dfsg1+llvm-0ubuntu2~16.04.2
    • 1.24.1+dfsg1+llvm-0ubuntu1~16.04.1
    • 1.25.0+dfsg1+llvm-0ubuntu1~16.04.1
    • 1.28.0+dfsg1+llvm-0ubuntu1~16.04.1
    • 1.30.0+dfsg1+llvm-2ubuntu1~16.04.1
    • 1.31.0+dfsg1+llvm-2ubuntu1~16.04.1
    • 1.32.0+dfsg1+llvm-1ubuntu1~16.04.1
    • 1.34.1+dfsg2+llvm-0ubuntu1~16.04.1
    • 1.35.0+dfsg0.1+llvm-0ubuntu1~16.04.1
    • 1.36.0+dfsg1+llvm-2ubuntu1~16.04.1
    • 1.37.0+dfsg1+llvm-1ubuntu1~16.04.1
    • 1.39.0+dfsg1+llvm-3ubuntu1~16.04.1
    • 1.41.0+dfsg1+llvm-0ubuntu1~16.04.1
    • 1.43.0+dfsg1+llvm-1~exp1ubuntu2~16.04.1
    • 1.47.0+dfsg1+llvm-1ubuntu1~16.04.1
    • 1.47.0+dfsg1+llvm-1ubuntu1~16.04.1ubuntu2
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • rustc Ubuntu:20.04:LTS

    Versions
    • 1.37.0+dfsg1+llvm-1ubuntu1
    • 1.38.0+dfsg0.2+llvm-0ubuntu1
    • 1.38.0+dfsg0.2+llvm-0ubuntu2
    • 1.39.0+dfsg1+llvm-3ubuntu1
    • 1.40.0+dfsg1+llvm-5ubuntu1
    • 1.41.0+dfsg1+llvm-0ubuntu1
    • 1.41.0+dfsg1+llvm-0ubuntu2
    • 1.43.0+dfsg1+llvm-1~exp1ubuntu1~20.04.1
    • 1.47.0+dfsg1+llvm-1ubuntu1~20.04.1
    • 1.51.0+dfsg1+llvm-1~exp3ubuntu1~20.04.2
    • 1.53.0+dfsg1+llvm-4ubuntu1~20.04.1
    • 1.57.0+dfsg1+llvm-0ubuntu1~20.04.1
    Affected ranges
    • ECOSYSTEM: < 1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~20.04.2

    Update to 1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~20.04.2

Original sources

Check your server →