Windows: New 'BatBadBut' Rust Vulnerability Given Highest CVSS Score
Vulnerabilities mentionedAll →
| CVE | Vulnerability | CVSS | EPSS | Flags | Affected | Exposure | Published |
|---|---|---|---|---|---|---|---|
| CVE-2024-24576 | Rust is a programming language. 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. NVD description · AI analysis pending | 10.0 | 20% |
| — |
Full article451 words · extracted from infosecurity-magazine.com · click to collapse
A critical vulnerability in the Rust standard library could be exploited to target Windows systems and perform command injection attacks.
The flaw was discovered by a security engineer from Flatt Security known as RyotaK. They named it BatBadBut, reported it to the CERT Coordination Center (CERT/CC) and published an analysis on April 9, 2024.
That same day, GitHub registered it as CVE-2024-24576, with a severity score (CVSS) of 10.0.
Decoding the BatBadBut Vulnerability
BatBadBut is a vulnerability that allows an attacker to perform command injection on Windows applications that indirectly depend on the ‘CreateProcess’ function when the specific conditions are satisfied.
RyotaK explained: “CreateProcess() implicitly spawns cmd.exe when executing batch files (.bat, .cmd, etc.), even if the application didn’t specify them in the command line. The problem is that the cmd.exe has complicated parsing rules for the command arguments, and programming language runtimes fail to escape the command arguments properly.”
The researcher said that because of this, it is possible to inject commands if someone can control the part of command arguments of the batch file.
In an advisory published on April 9, the Rust Security Response Working Group said it was notified that the Rust standard library did not properly escape arguments when invoking batch files (with the bat and cmd extensions) on Windows using the Command API.
“An attacker able to control the arguments passed to the spawned process could execute arbitrary shell commands by bypassing the escaping,” the advisory read.
High CVSS, Lower Risk?
BatBadBut has been attributed the highest severity score.
However, in their post, RyotaK suggested that the vulnerability's real-world exploitability might be lower than initially feared.
First, successful exploitation of BatBadBut only occurs when the following conditions are met:
- The application executes a command on Windows
- The application doesn’t specify the file extension of the command, or the file extension is .bat or .cmd
- The command being executed contains user-controlled input as part of the command arguments
- The runtime of the programming language fails to escape the command arguments for cmd.exe properly
Additionally, BatBadBut only impacts versions of Rust before 1.77.2 – no other platform or use is affected.
The high CVSS score comes from how such a score is attributed to a library.
“The user guide of CVSS v3.1 states that the CVSS score of a library should be calculated based on the worst-case scenario, and this is why the recent vulnerabilities for programming languages got high scores despite the requirement of specific conditions,” RyotaK explained.
The security researcher recommends recalculating the CVSS score based on the Forum Incident Response and Security Team’s (FIRST) implementation recommendations for software libraries.

Text extracted automatically; images, tables and formatting may be missing. Original: https://www.infosecurity-magazine.com/news/windows-batbadbut-rust/