1. Archivio CVE
  2. 2024
  3. CVE-2024-43402

CVE-2024-43402

8.8 Gravità alta CVSS v3.1 · fonte NVD CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H 8.8 – Alta

Descrizione

Rust is a programming language. The fix for CVE-2024-24576, where `std::process::Command` incorrectly escaped arguments when invoking batch files on Windows, was incomplete. Prior to Rust version 1.81.0, it was possible to bypass the fix when the batch file name had trailing whitespace or periods (which are ignored and stripped by Windows). To determine whether to apply the `cmd.exe` escaping rules, the original fix for the vulnerability checked whether the command name ended with `.bat` or `.cmd`. At the time that seemed enough, as we refuse to invoke batch scripts with no file extension. Windows removes trailing whitespace and periods when parsing file paths. For example, `.bat. .` is interpreted by Windows as `.bat`, but the original fix didn't check for that. Affected users who are using Rust 1.77.2 or greater can remove the trailing whitespace (ASCII 0x20) and trailing periods (ASCII 0x2E) from the batch file name to bypass the incomplete fix and enable the mitigations. Users are affected if their code or one of their dependencies invoke a batch script on Windows with trailing whitespace or trailing periods in the name, and pass untrusted arguments to it. Rust 1.81.0 will update the standard library to apply the CVE-2024-24576 mitigations to all batch files invocations, regardless of the trailing chars in the file name.

Prodotti coinvolti

FornitoreProdottoVersionePiattaforma
rust-lang rust < 1.81.0 –
Tutte le 24 vulnerabilità di Rust-lang Rust

Tipo di vulnerabilità

CWE-88 Argument injection: delimitatori degli argomenti non neutralizzati in un comando

Il prodotto costruisce la stringa di un comando da far eseguire a un altro componente, ma non delimita correttamente argomenti, opzioni e parametri: un attaccante può aggiungerne di propri.

Impatto sui sistemi

AmbitoImpatto
Riservatezza, Integrità, Disponibilità, Altro Eseguire codice o comandi non autorizzati, Alterare la logica di esecuzione, Leggere i dati dell’applicazione, Modificare i dati dell’applicazione

Come si previene

Sviluppo · Parametrizzazione Where possible, avoid building a single string that contains the command and its arguments. Some languages or frameworks have functions that support specifying independent arguments, e.g. as an array, which is used to automatically perform the appropriate quoting or escaping while building the command. For example, in PHP, escapeshellarg() can be used to escape a single argument to system(), or exec() can be called with an array of arguments. In C, code can often be refactored from using system() - which accepts a single string - to using exec(), which requires separate function arguments for each parameter.
Architettura e progettazione · Validazione dell’input Understand all the potential areas where untrusted inputs can enter your product: parameters or arguments, cookies, anything read from the network, environment variables, request headers as well as content, URL components, e-mail, files, databases, and any external systems that provide data to the application. Perform input validation at well-defined interfaces.
Sviluppo · Validazione dell’input Considera ogni input come potenzialmente malevolo. Adotta una validazione per «elenco di valori ammessi»: accetta solo gli input che rispettano rigorosamente le specifiche e rifiuta, o trasforma in qualcosa di conforme, tutto il resto. Nel validare considera tutte le proprietà rilevanti: lunghezza, tipo, intervallo dei valori ammessi, input mancanti o in più, sintassi, coerenza tra campi collegati e rispetto delle regole di business (per esempio «barca» è sintatticamente valido perché contiene solo lettere, ma non lo è se il campo deve contenere solo colori come rosso o blu). Non limitarti a cercare input malevoli o malformati: quasi certamente ne sfuggirà qualcuno, soprattutto se l’ambiente del codice cambia, lasciando all’attaccante lo spazio per aggirare la validazione. Le liste di valori vietati restano utili per rilevare possibili attacchi o scartare subito gli input più malformati.
Sviluppo Converti subito l’input nel tipo di dato atteso, per esempio con una funzione che trasforma una stringa in un numero. Dopo la conversione, verifica che i valori rientrino nell’intervallo ammesso e che la coerenza tra campi collegati sia rispettata.
Sviluppo Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180, CWE-181). Make sure that your application does not inadvertently decode the same input twice (CWE-174). Such errors could be used to bypass allowlist schemes by introducing dangerous inputs after they have been checked. Use libraries such as the OWASP ESAPI Canonicalization control. Consider performing repeated canonicalization until your input does not change any more. This will avoid double-decoding and similar scenarios, but it might inadvertently modify inputs that are allowed to contain properly-encoded dangerous content.
Sviluppo When exchanging data between components, ensure that both components are using the same character encoding. Ensure that the proper encoding is applied at each interface. Explicitly set the encoding you are using whenever the protocol allows you to do so.
Sviluppo Quando l’applicazione combina dati provenienti da più fonti, esegui la validazione dopo averli combinati: i singoli dati possono superare la validazione ma violare le restrizioni previste una volta messi insieme.
Test Usa strumenti e tecniche dinamiche che sollecitano il prodotto con ampie batterie di input diversi, come il fuzz testing (fuzzing), i test di robustezza e la fault injection. Il prodotto può rallentare, ma non deve diventare instabile, bloccarsi o produrre risultati errati.

Le indicazioni di mitigazione sono riportate nella lingua originale del catalogo CWE del MITRE.

Tutte le 512 CVE di tipo CWE-88, con andamento e prevenzione

Fonte: catalogo CWE del MITRE · cwe.mitre.org