Skip to main content
Vulnerability Database/CVE-2024-43402

CVE-2024-43402: Rust-lang Rust Auth Bypass Vulnerability

CVE-2024-43402 is an authentication bypass flaw in Rust-lang Rust that allows attackers to circumvent command escaping protections on Windows batch files. This post covers technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-43402 Overview

CVE-2024-43402 is an incomplete fix for the earlier CVE-2024-24576 command injection vulnerability in the Rust standard library. The std::process::Command API on Windows applies cmd.exe escaping rules only when a command name ends with .bat or .cmd. Windows strips trailing whitespace and periods when parsing file paths, so names such as script.bat. . bypass that check. Attackers who control arguments passed to a batch script with such a crafted file name can inject arbitrary commands. The flaw affects Rust versions from 1.77.2 up to, but not including, 1.81.0.

Critical Impact

Untrusted arguments passed to batch files with trailing whitespace or periods in the name can be weaponized to execute arbitrary commands through cmd.exe.

Affected Products

  • Rust standard library versions 1.77.2 through 1.80.x on Windows
  • Applications using std::process::Command to invoke .bat or .cmd files
  • Rust crates that wrap Command and forward untrusted arguments to batch scripts

Discovery Timeline

  • 2024-09-04 - CVE-2024-43402 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-43402

Vulnerability Analysis

The issue is a Command Injection flaw [CWE-78, CWE-88] in the Windows implementation of std::process::Command. The original mitigation for CVE-2024-24576 applied strict cmd.exe argument escaping only when the invoked program name ended with .bat or .cmd. That check compared the raw string suffix without normalizing the path the way Windows does at execution time.

Windows silently strips trailing ASCII space (0x20) and period (0x2E) characters from file paths before resolution. A name such as payload.bat. . resolves to payload.bat, yet the Rust suffix check sees . . and treats the invocation as a regular executable. The standard library then forwards arguments using generic Win32 quoting rather than the stricter cmd.exe escaping, re-opening the metacharacter injection path that CVE-2024-24576 was meant to close.

Root Cause

The root cause is an inconsistency between Rust's file name classification logic and the Windows path parser. The fix for CVE-2024-24576 assumed that the trailing extension observed by the application matched the extension used by the OS loader. Because Windows normalizes trailing whitespace and dots, this assumption fails and the hardened escaping is skipped.

Attack Vector

Exploitation requires an application that invokes a batch file whose on-disk name contains trailing spaces or periods and that forwards attacker-controlled strings as arguments. The attacker supplies arguments containing shell metacharacters such as &, |, or ". When cmd.exe interprets the command line, the unescaped metacharacters are parsed as new commands rather than as literal argument data, achieving arbitrary command execution in the context of the calling process.

No exploit is listed in CISA KEV and no public proof-of-concept URLs are referenced in the advisory. See the Rust Security Advisory GHSA-2xg3-7mm6-98jj for a technical description of the bypass.

Detect Identity Attacks the Moment Authentication Fails

Singularity™ Identity surfaces credential misuse, lateral movement, and privilege escalation in real time, so you can contain the breach before it spreads.

Stop Identity Attacks

Detection Methods for CVE-2024-43402

Indicators of Compromise

  • Batch files on disk whose names end with one or more trailing space (0x20) or period (0x2E) characters, which are typically abnormal on Windows file systems.
  • cmd.exe process executions spawned by Rust-compiled binaries where the command line contains unescaped shell metacharacters such as &, |, <, >, or ^.
  • Unexpected child processes (for example powershell.exe, net.exe, whoami.exe) descending from applications that normally only invoke a single batch script.

Detection Strategies

  • Inventory Rust-built Windows binaries and identify those compiled with a standard library version between 1.77.2 and 1.80.x that spawn batch files.
  • Perform static code review of Rust projects for Command::new or Command::args usages that reference .bat or .cmd targets with externally sourced arguments.
  • Audit application-controlled directories for file names containing trailing whitespace or periods using scripted enumeration of raw directory entries.

Monitoring Recommendations

  • Enable Windows process creation auditing (Event ID 4688) with full command-line logging to capture arguments passed to cmd.exe.
  • Alert on process ancestry where an application process launches cmd.exe /c with argument strings containing shell metacharacters.
  • Correlate file-write events that create .bat or .cmd files with trailing dots or spaces, which is a strong signal of staging for this bypass.

How to Mitigate CVE-2024-43402

Immediate Actions Required

  • Upgrade the Rust toolchain to version 1.81.0 or later and rebuild all affected Windows binaries.
  • Audit dependencies for crates that invoke batch scripts and ensure they are rebuilt against the patched standard library.
  • Validate that application code never passes untrusted input directly to .bat or .cmd targets without explicit sanitization.

Patch Information

Rust 1.81.0 updates the standard library so that CVE-2024-24576 escaping rules apply to every batch file invocation, regardless of trailing characters in the file name. Review the Rust Blog post on CVE-2024-24576 and the GitHub Security Advisory GHSA-2xg3-7mm6-98jj for distribution and crate-level guidance.

Workarounds

  • Rename batch scripts to remove trailing whitespace and periods, which forces the existing Rust 1.77.2+ mitigation path to activate.
  • Replace batch script invocations with direct calls to the underlying executable (for example powershell.exe or the target binary) and pass arguments explicitly.
  • Apply allow-list validation on arguments destined for batch files, rejecting any input containing &, |, <, >, ^, ", or newline characters. Refer to the Microsoft guidance on whitespace in file and folder names for Windows path normalization behavior.

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.