NA

CVE-2024-24576

Published: 09/04/2024 Updated: 19/04/2024

Vulnerability 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.

Vulnerability Trend

Mailing Lists

<!--X-Body-Begin--> <!--X-User-Header--> oss-sec mailing list archives <!--X-User-Header-End--> <!--X-TopPNI--> By Date By Thread </form> <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> CVE-2024-24576: Rust 1771 and earlier did not properly escape arguments of batch files on Windows <!--X-Subject-Header-End-- ...

Github Repositories

CVE-2024-24576-Poc-Python A quick POC for the vulnerability disclosed here flatttech/research/posts/batbadbut-you-cant-securely-execute-commands-on-windows/ After you run the script it will ask for an arg to be passed to the BAT file In the screenshot you can see that by adding " the underlying API that windows uses to call cmd can be escaped allowing for arbitra

CVE-2024-24576 Proof of Concept

CVE-2024-24576-Exploit 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 platfor

CVE-2024-24576 PoC for Nim Lang

CVE-2024-24576-PoC---Nim CVE-2024-24576 PoC for Nim Lang

CVE Research Here is some information about my research on CVE Lists CVE-2024-24576

CVE-2024-24576-PoC-Python nvdnistgov/vuln/detail/CVE-2024-24576 Why the fuck did this get 10/10 rating ?

CVE-2024-24576 PoC in Julia

CVE-2024-24576 PoC in Julia λ julia mainjl Enter arguments: hello Output: Argument received: hello λ julia mainjl

Proof of Concept of the newaly found Vuln ie CVE 2024 24576, here I used python to demonstrate that You can read about this more on here

investigating the BatBadBut vulnerability,

outcome of the here implemented batbadbut_incsharpexe &gt; batbadbut_incsharpexe Hello! I am going to run following command Guess what will happen ;-) cmd /C echo "\"&amp;calcexe" See? The calcexe was started on your computer Bye! Press any key to stop this console program "\" BatBadBut vulnar

Example of CVE-2024-24576 use case.

CVE-2024-24576 Running the mainrs file with the following payloads give C:\Users\frost\testing&gt;cargo run Compiling testing v010 (C:\Users\frost\testing) Finished dev [unoptimized + debuginfo] target(s) in 049s Running `target\debug\testingexe` enter payload here aaa Output: Argument received: aaa C:\Users\frost\tes

Example of CVE-2024-24576 use case.

CVE-2024-24576 PoC Running the mainrs file with the following payloads give C:\Users\frost\testing&gt;cargo run Compiling testing v010 (C:\Users\frost\testing) Finished dev [unoptimized + debuginfo] target(s) in 049s Running `target\debug\testingexe` enter payload here aaa Output: Argument received: aaa C:\Users\frost

PoC for CVE-2024-24576 vulnerability "BatBadBut"

CVE-2024-24576-PoC-BatBadBut- PoC for CVE-2024-24576 vulnerability "BatBadBut"

a python proof of concept for cve-2024-24576

cve-2024-24576-python a python proof of concept for cve-2024-24576

Recent Articles

Critical Rust flaw enables Windows command injection attacks
BleepingComputer • Sergiu Gatlan • 09 Apr 2024

Critical Rust flaw enables Windows command injection attacks By Sergiu Gatlan April 9, 2024 04:20 PM 0 Threat actors can exploit a security vulnerability in the Rust standard library to target Windows systems in command injection attacks. Tracked as CVE-2024-24576, this flaw is due to OS command and argument injection weaknesses that can let attackers execute unexpected and potentially malicious commands on the operating system. GitHub rated this vulnerability as critica...

Rust rustles up fix for 10/10 critical command injection bug on Windows
The Register

Topics Security Off-Prem On-Prem Software Offbeat Special Features Vendor Voice Vendor Voice Resources BatBadBut hits Erlang, Go, Python, Ruby as well

Programmers are being urged to update their Rust versions after the security experts working on the language addressed a critical vulnerability that could lead to malicious command injections on Windows machines. The vulnerability, which carries a perfect 10 base severity score, is tracked as CVE-2024-24576. It affects the Rust standard library, which was found to be improperly escaping arguments when invoking batch files on Windows using the Command API. "An attacker able to control the argumen...