1. Archivio CVE
  2. 2021
  3. CVE-2021-29472

CVE-2021-29472

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

Descrizione

Composer is a dependency manager for PHP. URLs for Mercurial repositories in the root composer.json and package source download URLs are not sanitized correctly. Specifically crafted URL values allow code to be executed in the HgDriver if hg/Mercurial is installed on the system. The impact to Composer users directly is limited as the composer.json file is typically under their own control and source download URLs can only be supplied by third party Composer repositories they explicitly trust to download and execute source code from, e.g. Composer plugins. The main impact is to services passing user input to Composer, including Packagist.org and Private Packagist. This allowed users to trigger remote code execution. The vulnerability has been patched on Packagist.org and Private Packagist within 12h of receiving the initial vulnerability report and based on a review of logs, to the best of our knowledge, was not abused by anyone. Other services/tools using VcsRepository/VcsDriver or derivatives may also be vulnerable and should upgrade their composer/composer dependency immediately. Versions 1.10.22 and 2.0.13 include patches for this issue.

Prodotti coinvolti

FornitoreProdottoVersionePiattaforma
debian debian linux 9.0 –
debian debian linux 10.0 –
fedoraproject fedora 33 –
fedoraproject fedora 34 –
getcomposer composer < 1.10.22 –
getcomposer composer >= 2.0 < 2.0.13 –
Tutte le 9 vulnerabilità di Getcomposer Composer

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