Skip to content
RCE Write-up Intermediate

CVE-2024–24576: A Critical Rust Vulnerability on Windows

The Rust standard library failed to properly escape arguments passed to batch files on Windows, allowing an attacker to inject shell commands. An attacker could execute arbitrary commands if untrusted input was used as an argument to a batch file.

infosecwriteups.com

Published on infosecwriteups.com

Swift action has been taken to mitigate potential threats in the ever-evolving landscape of cybersecurity. CVE-2024–24576 (CVS 10.0) Sin the Rust programming language’s standard library has critical impact on Windows platforms.

ElNiak, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the Rust standard library's escaping logic for arguments passed to batch files on Windows was insufficient to prevent command injection because it did not account for cmd.exe's argument parsing rules.

Impact

An attacker could execute arbitrary shell commands on a Windows system if untrusted input is passed as an argument to a batch file via Rust's Command API.

What the attacker needed

Rust version before 1.77.2; Windows platform; Application passes untrusted input as argument to a batch…

The fix

The vulnerability was fixed in Rust 1.77.2 by improving the escaping code and making the Command API return an error when it cannot safely escape an argument.

How it was found

  1. Create a Rust program that reads user input and passes it as an argument to a batch file using Command::arg.
  2. Run the program and enter a normal argument to see it passed as-is.
  3. Enter an argument containing shell metacharacters like & to attempt command injection.
  4. Observe that the injected command (e.g., whoami) is executed.

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 write-up has not been written yet. The Original tab links to the source.

When a program runs another program, it passes arguments. On Windows, batch files are run by the command interpreter, which has special rules for characters like & and ". Rust did not escape these characters correctly, so an attacker who controls an argument could sneak in extra commands. This is like writing a note that says 'buy milk & eggs' and the shop also buys eggs because & means 'and also do this'.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.