`std::process::Command` batch files argument escaping could be bypassed with trailing whitespace or periods
The fix for an earlier argument-escaping flaw in Rust's process spawning on Windows was incomplete: batch file names ending in whitespace or periods could still allow argument escaping. An attacker who controls arguments passed to such a batch script could potentially inject commands.
- Triaged in 2 hours
- Fixed in 37 days
- Paid in 37 days
- Disclosed after 2 months
Summary by the program
Full GHSA: https://github.com/rust-lang/rust/security/advisories/GHSA-2xg3-7mm6-98jj
The report
On April 9th, 2024, the Rust Security Response WG disclosed CVE-2024-24576, where std::process::Command incorrectly escaped arguments when invoking batch files on Windows. We were notified that our fix for the vulnerability was incomplete, and it was possible to bypass the fix when the batch file name had trailing whitespace or periods (which are ignored and stripped by Windows).
The severity of the incomplete fix is low, due to the niche conditions needed to trigger it. Note that calculating the CVSS score might assign a higher severity to this, but that doesn't take into account what is required to trigger the incomplete fix.
The incomplete fix is identified by CVE-2024-43402.
Impact
All Rust versions before 1.81.0 are affected, if your code or one of your dependencies invoke a batch script on Windows with trailing whitespace or trailing periods in the name, and pass untrusted arguments to it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the escaping logic did not account for Windows stripping trailing whitespace and periods from batch file names, so the name used for escaping differed from the name actually executed.
Impact
The severity is low because niche conditions are required: code must invoke a batch script whose name ends in whitespace or periods and pass it untrusted arguments.
What the attacker needed
Windows platform; batch script name ends in space or period; untrusted arguments passed to it
The fix
Rust versions before 1.81.0 are affected; the text does not state when the fix landed.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program starts another program, it has to pass along arguments carefully so that special characters are not treated as commands. Rust had fixed a problem where this was done wrongly for Windows batch files, but the fix missed names ending in spaces or dots, which Windows quietly ignores. That gap could let someone sneak extra commands in.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.