Read the docs
TI-2024-16197 Aliases CVE-2024-24576

Rusts's `std::process::Command` did not properly escape arguments of batch files on Windows

Priority HIGH 82CWE-78Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
None
Attack complexity
Low
Impact type
Code execution
Confidentiality · integrity · availability
High · High · High
Fix status
Fixed

Attack profile from CVSS 3.1 · CNA. Fix status from CNA. Impact type from CWE-78.

Summary

Rust is a programming language. The Rust Security Response WG was notified that the Rust standard library prior to version 1.77.2 did not properly escape arguments when invoking batch files (with the `bat` and `cmd` extensions) on Windows using the `Command`. An attacker able to control the arguments passed to the spawned process could execute arbitrary shell commands by bypassing the escaping. The severity of this vulnerability is critical for those who invoke batch files on Windows with untrusted arguments. No other platform or use is affected. The `Command::arg` and `Command::args` APIs state in their documentation that the arguments will be passed to the spawned process as-is, regardless of the content of the arguments, and will not be evaluated by a shell. This means it should be safe to pass untrusted input as an argument. On Windows, the implementation of this is more complex than other platforms, because the Windows API only provides a single string containing all the arguments to the spawned process, and it's up to the spawned process to split them. Most programs use the standard C run-time argv, which in practice results in a mostly consistent way arguments are splitted. One exception though is `cmd.exe` (used among other things to execute batch files), which has its own argument splitting logic. That forces the standard library to implement custom escaping for arguments passed to batch files. Unfortunately it was reported that our escaping logic was not thorough enough, and it was possible to pass malicious arguments that would result in arbitrary shell execution. Due to the complexity of `cmd.exe`, we didn't identify a solution that would correctly escape arguments in all cases. To maintain our API guarantees, we improved the robustness of the escaping code, and changed the `Command` API to return an `InvalidInput` error when it cannot safely escape an argument. This error will be emitted when spawning the process. The fix is included in Rust 1.77.2. Note that the new escaping logic for batch files errs on the conservative side, and could reject valid arguments. Those who implement the escaping themselves or only handle trusted inputs on Windows can also use the `CommandExt::raw_arg` method to bypass the standard library's escaping logic.

Why it matters now

Exploitation Proof of concept CISA SSVC · not in CISA KEV
EPSS 0.20342 97th percentileScored 2026-11-07
Fix Fixed rust (rust-lang): 1.77.2

SSVC decision points

CISA ADP · SSVC 2.0.3

Exploitation
Poc
Automatable
Yes
Technical impact
Total

The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.

Affected products

VendorProductAffected versionsFixed inStatusSource
rust-langrustbefore 1.77.21.77.2Patch availableCNA
  • rust Vendorrust-lang Affected before 1.77.2 Fixed in 1.77.2 Patch available CNA

CPE configurations NVD · 5

CPEVersionsRoleVendor
cpe:2.3:o:fedoraproject:fedora:38:*:*:*:*:*:*:*38VulnerableFedoraproject
cpe:2.3:o:fedoraproject:fedora:39:*:*:*:*:*:*:*39VulnerableFedoraproject
cpe:2.3:o:fedoraproject:fedora:40:*:*:*:*:*:*:*40VulnerableFedoraproject
cpe:2.3:a:rust-lang:rust:*:*:*:*:*:*:*:*before 1.77.2Vulnerablerust-lang
cpe:2.3:o:microsoft:windows:-:*:*:*:*:*:*:*not specified by NVDRunning onMicrosoft
  • cpe:2.3:o:fedoraproject:fedora:38:*:*:*:*:*:*:* Versions 38 Vulnerable ·Fedoraproject
  • cpe:2.3:o:fedoraproject:fedora:39:*:*:*:*:*:*:* Versions 39 Vulnerable ·Fedoraproject
  • cpe:2.3:o:fedoraproject:fedora:40:*:*:*:*:*:*:* Versions 40 Vulnerable ·Fedoraproject
  • cpe:2.3:a:rust-lang:rust:*:*:*:*:*:*:*:* Versions before 1.77.2 Vulnerable ·rust-lang
  • cpe:2.3:o:microsoft:windows:-:*:*:*:*:*:*:* Versions not specified by NVD Running on ·Microsoft

Remediation

  • Fix · CNA rust (rust-lang) Fixed in 1.77.2

Vendor assessments

Red Hat

Red Hat rating: Low. Red Hat's page for this CVE →

Not affected: 2 products
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9

Timeline

  1. 2026-10-02 Threatist record created from CVE-2024-24576

References

  • TI-2024-03325 Command injection vulnerability in programing languages on Microsoft Windows operating system. CVSS 3.1CRITICAL 9.8
  • TI-2022-06036 Race condition in std::fs::remove_dir_all in rustlang CVSS 3.1HIGH 7.3
  • TI-2018-16034 The Rust Programming Language Standard Library version 1.29.0, 1.28.0, 1.27.2, 1.27.1… CVSS 3.0CRITICAL 9.8
  • TI-2021-11383 In the standard library in Rust before 1.52.0, a double free can occur in the… CVSS 3.1CRITICAL 9.8
  • TI-2021-09849 In the standard library in Rust before 1.52.0, the Zip implementation can report an… CVSS 3.1CRITICAL 9.8
  • TI-2020-18601 In the standard library in Rust before 1.49.0, VecDeque::make_contiguous has a bug that… CVSS 3.1CRITICAL 9.8
See all 23 →

Sources