CRITICAL🇬🇧 English

CVE-2024-24576

Command Injection w Rust stdlib – ucieczka argumentów batch na Windows

CVSS 10.0v3.1pub. 2024-04-09upd. 2026-01-05

Standardowa biblioteka języka Rust w wersjach przed 1.77.2 nieprawidłowo escapowała argumenty przekazywane do plików wsadowych (batch) na platformie Windows za pośrednictwem API `Command`. Atakujący mogący kontrolować argumenty przekazywane do uruchamianego procesu mógł wykonać dowolne polecenia powłoki, omijając mechanizm escapowania.

Pokaż oryginał (EN)

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.

🤖 Analiza AI
Jak działa

Windows API przekazuje do uruchamianego procesu wszystkie argumenty jako pojedynczy ciąg znaków, a ich podział należy do uruchamianego programu. Polecenie `cmd.exe`, używane m.in. do uruchamiania plików wsadowych (.bat, .cmd), stosuje własną logikę podziału argumentów, odmienną od standardowego C runtime. Standardowa biblioteka Rust implementowała własne escapowanie dla tego przypadku, jednak okazało się ono niewystarczające — specjalnie spreparowane argumenty pozwalały na ominięcie escapowania i wykonanie arbitralnych poleceń powłoki. Zgodnie z dokumentacją API `Command::arg` i `Command::args` argumenty miały być przekazywane bez interpretacji przez powłokę, co stanowi złamanie gwarancji bezpieczeństwa tych interfejsów.

Skutki

Atakujący mogący kontrolować argumenty przekazywane do pliku wsadowego uruchamianego przez aplikację Rust na Windows może wykonać dowolne polecenia powłoki z uprawnieniami procesu — co może prowadzić do przejęcia systemu, ujawnienia danych lub ich modyfikacji.

Mitygacja

Należy zaktualizować Rust do wersji 1.77.2 lub nowszej, która zawiera poprawkę. Po aktualizacji biblioteka zwraca błąd `InvalidInput` dla argumentów, których nie może bezpiecznie escapować. Deweloperzy implementujący własne escapowanie lub przetwarzający wyłącznie zaufane dane wejściowe mogą alternatywnie użyć metody `CommandExt::raw_arg`, aby ominąć logikę escapowania biblioteki standardowej.

Kogo dotyczy

Rust standard library w wersjach przed 1.77.2, wyłącznie na platformie Windows, w przypadkach gdy aplikacja uruchamia pliki wsadowe (.bat, .cmd) z niezaufanymi argumentami za pomocą API `Command`.

Uwagi

Podatność dotyczy wyłącznie platformy Windows i wyłącznie scenariuszy uruchamiania plików wsadowych (.bat, .cmd) z niezaufanymi argumentami. Pozostałe platformy oraz inne przypadki użycia API `Command` nie są objęte tym problemem. Poprawka celowo działa zachowawczo i może odrzucać niektóre poprawne argumenty.

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
  • Fedora Project Fedora

    OS
    Fedoraproject
    383940
  • Microsoft Windows

    OS
    Microsoft
    wszystkie wersje
  • Rust Lang Rust

    APP
    Rust-Lang
    < 1.77.2
🔵
ZWERYFIKUJ U PRODUCENTA
Brak jednoznacznych danych o patchu. Sprawdź referencje od producenta.
Tagi
Command Injection
CWE
Referencje

Powiązane podatności

CVE-2026-8398CRITICAL9.3⚠ KEVPL ✓ten sam produkt

Atak na łańcuch dostaw DAEMON Tools Lite — trojanizacja instalatorów

CVE-2025-10585CRITICAL9.8⚠ KEVPL ✓ten sam produkt

Type confusion w V8 (Google Chrome) — zdalne uszkodzenie sterty

CVE-2025-34028CRITICAL9.3⚠ KEVPL ✓ten sam produkt

Commvault Command Center – nieuwierzytelniony RCE przez path traversal w ZIP

CVE-2024-7262CRITICAL9.3⚠ KEVPL ✓ten sam produkt

Path Traversal w Kingsoft WPS Office — ładowanie dowolnej biblioteki Windows

CVE-2024-4577CRITICAL9.8⚠ KEVPL ✓ten sam produkt

PHP CGI argument injection – RCE na Windows przez mechanizm Best-Fit