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

Published Apr 9, 2024
·
Updated

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::rawarg method to bypass the standard library's escaping logic.

Affected Software

6 affected components
Rust Rust<1.77.2
Fedoraproject Fedora=38
Fedoraproject Fedora=39
Fedoraproject Fedora=40
All of the following
rust-lang Rust<1.77.2
Microsoft Windows

Event History

Apr 9, 2024
CVE Published
via MITRE·05:28 PM
Data Sourced
via MITRE·05:28 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:15 PM
DescriptionSeverityWeaknessAffected Software
News Published
via BleepingComputer·08:20 PM
News Published
via BleepingComputer·08:22 PM
Apr 10, 2024
News Published
via The Register·01:15 PM
News Published
via The Register·01:20 PM
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-24576?

CVE-2024-24576 is classified as a critical severity vulnerability.

2

How do I fix CVE-2024-24576?

To fix CVE-2024-24576, upgrade the Rust standard library to version 1.77.2 or later.

3

What types of systems are affected by CVE-2024-24576?

CVE-2024-24576 affects systems running versions of the Rust standard library prior to 1.77.2 on Windows.

4

What kind of attack does CVE-2024-24576 enable?

CVE-2024-24576 enables command injection attacks through improperly escaped arguments in batch file executions.

5

Is there a workaround for CVE-2024-24576?

There are no confirmed workarounds; upgrading to the fixed version is the recommended action.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203