cve.bz

CVE-2022-21658 Race Condition Enabling Link Following

6.3 mediumExploit referenceEPSS 1.5%Fix available

Medium (6.3). EPSS 1.5% estimated probability of exploitation activity in the next 30 days.

On this page
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.

Severity

CVSS 3.1

6.3 medium
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H
EPSS
1.5% (unchanged from 1.5% a week ago; 1.4% 30 days ago) estimated probability of exploitation activity in the next 30 days; 74th percentile. Scored 2026-11-21. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: PoC · Automatable: no · Technical impact: partial, assessed 2025-04-22. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWEs
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
CWE-363 Race Condition Enabling Link Following
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2022-21658 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2022-21658?via=ask-ai-copy and https://cve.bz/cve/CVE-2022-21658?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2022-21658 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
rust-lang:rustfrom 1.0.0 through 1.58.0
fedoraproject:fedora34
fedoraproject:fedora35
apple:ipadosbefore 15.4
apple:iphone_osbefore 15.4
apple:macosfrom 12.0.0 before 12.3
apple:tvosbefore 15.4
apple:watchosbefore 8.5

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian12, 13, 14rustc1.57.0+dfsg1-1DEBIAN-CVE-2022-21658
Ubuntu20.04:LTSrustc1.59.0+dfsg1~ubuntu1~llvm-1~ubuntu1~20.04.2UBUNTU-CVE-2022-21658
UbuntuPro:14.04:LTS, Pro:16.04:LTSrustcno fix listedUBUNTU-CVE-2022-21658
Red Hatenterprise_linux:8::appstreamrls, rust, cargo and 19 more0:1.58.1-1.module+el8.6.0+14021+586eff1aRHSA-2022:1894
SUSEEnterprise Storage 6, Enterprise Storage 7, Linux Enterprise High Performance Computing 15 SP1-ESPOS and 13 morerust1.53.0-22.1SUSE-SU-2022:0491-1
SUSELinux Enterprise High Performance Computing 15-ESPOS, Linux Enterprise High Performance Computing 15-LTSS, Linux Enterprise Server 15-LTSS and 1 morerust1.53.0-3.40.1SUSE-SU-2022:0200-1
SUSELinux Enterprise Module for Development Tools 15 SP3rust1.59.0-150300.21.20.1SUSE-SU-2022:0843-1
SUSELinux Enterprise Module for Development Tools 15 SP3rust1.551.55.0-150300.7.6.1SUSE-SU-2022:0171-1
SUSELinux Enterprise Module for Development Tools 15 SP3rust1.561.56.1-150300.7.6.1SUSE-SU-2022:0149-1
SUSELinux Enterprise Module for Development Tools 15 SP3rust1.571.57.0-150300.7.7.1SUSE-SU-2022:0175-1
SUSELinux Enterprise Module for Development Tools 15 SP3rust1.581.58.0-150300.7.3.1SUSE-SU-2022:0843-1
SUSELinux Enterprise Module for Development Tools 15 SP3rust1.591.59.0-150300.7.4.2SUSE-SU-2022:0843-1
SUSEPackage Hub 15 SP3libredwg0.12.5-bp153.2.3.1openSUSE-SU-2022:0149-1
openSUSELeap 15.3libredwg0.12.5-bp153.2.3.1openSUSE-SU-2022:0149-1
openSUSELeap 15.3rust1.53.0-22.1openSUSE-SU-2022:0491-1
openSUSELeap 15.3rust1.59.0-150300.21.20.1openSUSE-SU-2022:0843-1
openSUSELeap 15.3rust1.551.55.0-150300.7.6.1openSUSE-SU-2022:0171-1
openSUSELeap 15.3rust1.561.56.1-150300.7.6.1openSUSE-SU-2022:0149-1
openSUSELeap 15.3rust1.571.57.0-150300.7.7.1openSUSE-SU-2022:0175-1
openSUSELeap 15.3rust1.581.58.0-150300.7.3.1openSUSE-SU-2022:0843-1
openSUSELeap 15.3rust1.591.59.0-150300.7.4.2openSUSE-SU-2022:0843-1
openSUSETumbleweedrust1.561.56.1-4.1openSUSE-SU-2024:11767-1
openSUSETumbleweedrust1.571.57.0-3.1openSUSE-SU-2024:11768-1
openSUSETumbleweedrust1.581.58.0-2.1openSUSE-SU-2024:11769-1
AlmaLinux8rls, rust, cargo and 13 more1.58.1-1.module_el8.6.0+2748+176088b3ALSA-2022:1894
Rocky Linux8rust, rust-toolset0:1.58.1-1.module+el8.6.0+826+60f85975RLSA-2022:1894
Azure Linux2rust1.59.0-1AZL-8337

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; Red Hat Security Data © Red Hat, Inc., CC BY 4.0; SUSE security data, CC BY 4.0; AlmaLinux's OSV database, MIT; Rocky Linux's errata, BSD-3-Clause; Microsoft's Azure Linux vulnerability data, MIT. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · Red Hat · SUSE · openSUSE.

Red Hat

Red Hat rates this Moderate.

Red Hat's statement

This flaw has been given a Severity of Moderate because it is not exploitable at will on every Rust program as it requires a specific scenario where a privileged program uses a specific Rust stdlib function, the attacker has some knowledge of the program's file operations, and has the normal limitations and challenges of a

Time-of-check to time-of-use (TOCTOU). It must also be carried out by an unprivileged attacker.

Red Hat's mitigation

Mitigation for this issue is either not available or the currently available options do not meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.

ProductPackageStateAdvisory
Red Hat Enterprise Linux 8rust-toolset:rhel8-8060020220125235043.eab6f2eaFixed 2022-05-10RHSA-2022:1894
Red Hat Enterprise Linux 8stratisdWill not fix
Red Hat Enterprise Linux 9rustNot affected
Red Hat Enterprise Linux 9stratisdWill not fix
Red Hat OpenShift Container Platform 4kata-containersNot affected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2022-21658.

ICS advisories (CISA)

AdvisoryTitlePublishedSectorsAffectedFixed
ICSA-25-100-02Siemens SIDIS Prime2025-04-08Chemical, Critical Manufacturing, Energy, Food and Agriculture, Water and Wastewater SystemsSIDIS Primenone listed

From CISA's ICS advisories (CSAF), provided under CISA's notification. Only the facts are shown; each advisory is on CISA's page. Credits.

Attack patterns (CAPEC)

  • CAPEC-26 Leveraging Race Conditions Likelihood: High · Severity: High
  • CAPEC-27 Leveraging Race Conditions via Symbolic Links Likelihood: Medium · Severity: High
  • CAPEC-29 Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions Likelihood: High · Severity: High

The attack patterns MITRE's CAPEC relates to this record's weaknesses, as MITRE names them. Credits.

References

Check your stackJSON