CVE-2024-24576 in the critical feed json
Rusts's `std::process::Command` did not properly escape arguments of batch files on Windows
published 2024-04-09 2 y ago modified 2026-06-17 4 mo ago also EUVD-2024-21981
- cvss
- 10.0
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 20.3%
- EPSS 20.3% chance of exploitation in 30 days, percentile 97%
- public exploits
- 0
- none known
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.
Patch / fix
- rust-lang rust 1.77.2
- rust1.77 openSUSE Tumbleweed 1.77.2-1.1
opensuse advisories openSUSE-SU-2024:13966-1
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2024-24576 updated
rust: Fail to Escape Arguments Properly in Microsoft Windows
-
Red Hat Enterprise Linux 8 rls, rust, cargo, clippy, rustfmt, rust-gdb, +8 more Red Hat Enterprise Linux 9 rust, cargo, clippy, rustfmt, rust-gdb, rust-src, +8 morenot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
CISA SSVC
- Exploitation
- Proof of concept is public
- Automatable
- yes
- Technical impact
- total
- Assessed
- 20 mo ago
Exploit prediction
20.34% chance of exploitation in the next 30 days, higher than 97% of all scored CVEs (FIRST EPSS, 2026-11-08).
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 10.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
| NVD | 3.1 | 10.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
Affected products
- rust-lang rust
Classification
References
-
github.com
/rust-lang/rust/security/advisories/GHSA-q455-m56c-85mh
mitigation, vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/W7WRFOIAZXYUPGXGR5UEEW7VTTOD4SZ3/
mailing-list, vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/RPH3PF7DVSS2LVIRLW254VWUPVKJN46P/
mailing-list, vendor-advisory
-
lists.fedoraproject.org
/archives/list/package-announce@lists.fedoraproject.org/message/N323QAEEUVTJ354BTVQ7UB6LYXUX2BCL/
mailing-list, vendor-advisory
-
doc.rust-lang.org
/std/io/enum.ErrorKind.html#variant.InvalidInput
technical-description
-
doc.rust-lang.org
/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg
technical-description
-
doc.rust-lang.org
/std/process/struct.Command.html
technical-description
-
doc.rust-lang.org
/std/process/struct.Command.html#method.arg
technical-description
-
doc.rust-lang.org
/std/process/struct.Command.html#method.args
technical-description
-
github.com
/rust-lang/rust/issues
issue-tracking
-
rust-lang.org
/policies/security
technical-description
-
openwall.com
/lists/oss-security/2024/04/09/16
mailing-list, third-party-advisory
-
kb.cert.org
/vuls/id/123335
third-party-advisory
Sources
- CVE List CVE-2024-24576
- NVD CVE-2024-24576
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.
CPEs and fixed versions use Anchore's correction of NVD's data: Added CPE configurations because not yet analyzed by NVD.