CVE-2022-21658
Bottlerocket vulnerability analysis and mitigation

Overview

The Rust Security Response WG identified a race condition vulnerability (CVE-2022-21658) in the std::fs::removedirall standard library function that enables symlink following (CWE-363). The vulnerability affects Rust versions 1.0.0 through 1.58.0. This security issue could allow an attacker to trick a privileged program into deleting files and directories that the attacker couldn't otherwise access or delete (Rust Blog).

Technical details

The vulnerability stems from an incorrect implementation of symlink protection in std::fs::removedirall. Instead of instructing the system not to follow symlinks, the standard library first checked if the target was a symlink before proceeding with recursive deletion. This created a Time-of-check Time-of-use (TOCTOU) race condition where an attacker could create a directory and replace it with a symlink between the check and deletion. While not guaranteed to succeed on first attempt, the attack could be reliably executed within seconds (Rust Blog, Hacker News).

Impact

An unprivileged attacker could exploit this vulnerability to delete files and directories they normally wouldn't have permission to access by tricking privileged programs that use std::fs::removedirall. This is particularly concerning for system daemons and setuid binaries running with elevated privileges (Rust Blog).

Mitigation and workarounds

The vulnerability was fixed in Rust 1.58.1. Users are strongly recommended to update to this version, especially for programs running in privileged contexts. Adding manual checks before calling removedirall does not mitigate the vulnerability as they would be subject to the same race condition. Some platforms including macOS before version 10.10 and REDOX remain vulnerable even with patched toolchains due to API limitations (Rust Blog).

Community reactions

The vulnerability received significant attention in the Rust community and broader security industry. Multiple Linux distributions including Fedora and Gentoo issued security advisories and updates. Apple also incorporated fixes for this vulnerability in their iOS 15.4, iPadOS 15.4, macOS Monterey 12.3, tvOS 15.4 and watchOS 8.5 releases (Fedora Update, Gentoo Security).

Additional resources


SourceThis report was generated using AI

Related Bottlerocket vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2024-45492CRITICAL9.8
  • BottlerocketBottlerocket
  • expat-docs
NoYesAug 30, 2024
CVE-2024-45491CRITICAL9.8
  • BottlerocketBottlerocket
  • thunderbird
NoYesAug 30, 2024
CVE-2022-21505MEDIUM6.7
  • NixOSNixOS
  • linux-azure-fde-5.15
NoYesDec 24, 2024
CVE-2022-28693MEDIUM4.7
  • Linux KernelLinux Kernel
  • VMware_bootbank_bmcal
NoYesFeb 14, 2025
CVE-2024-45310LOW3.6
  • cAdvisorcAdvisor
  • k3s
NoYesSep 03, 2024

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management