CVE-2024-24576

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.
Configurations

No configuration.

History

01 May 2024, 18:15

Type Values Removed Values Added
References
  • () http://www.openwall.com/lists/oss-security/2024/04/09/16 -

19 Apr 2024, 23:15

Type Values Removed Values Added
References
  • () https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/N323QAEEUVTJ354BTVQ7UB6LYXUX2BCL/ -

19 Apr 2024, 04:15

Type Values Removed Values Added
References
  • () https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RPH3PF7DVSS2LVIRLW254VWUPVKJN46P/ -

12 Apr 2024, 02:15

Type Values Removed Values Added
References
  • {'url': 'https://www.kb.cert.org/vuls/id/123335', 'source': 'security-advisories@github.com'}
  • () https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W7WRFOIAZXYUPGXGR5UEEW7VTTOD4SZ3/ -
Summary
  • (es) Rust es un lenguaje de programación. Se notificó al Grupo de Trabajo de Respuesta de Seguridad de Rust que la librería estándar de Rust anterior a la versión 1.77.2 no escapaba correctamente a los argumentos al invocar archivos por lotes (con las extensiones `bat` y `cmd`) en Windows usando el `Comando`. Un atacante capaz de controlar los argumentos pasados al proceso generado podría ejecutar comandos de shell arbitrarios evitando el escape. La gravedad de esta vulnerabilidad es crítica para quienes invocan archivos por lotes en Windows con argumentos que no son de confianza. Ninguna otra plataforma o uso se ve afectado. Las API `Command::arg` y `Command::args` establecen en su documentación que los argumentos se pasarán al proceso generado tal cual, independientemente del contenido de los argumentos, y no serán evaluados por un shell. Esto significa que debería ser seguro pasar entradas que no sean de confianza como argumento. En Windows, la implementación de esto es más compleja que en otras plataformas, porque la API de Windows solo proporciona una única cadena que contiene todos los argumentos del proceso generado, y depende del proceso generado dividirlos. La mayoría de los programas utilizan el argv estándar en tiempo de ejecución de C, que en la práctica da como resultado una forma mayoritariamente consistente de dividir los argumentos. Sin embargo, una excepción es `cmd.exe` (utilizado, entre otras cosas, para ejecutar archivos por lotes), que tiene su propia lógica de división de argumentos. Eso obliga a la librería estándar a implementar un escape personalizado para los argumentos pasados a archivos por lotes. Desafortunadamente, se informó que nuestra lógica de escape no era lo suficientemente exhaustiva y era posible pasar argumentos maliciosos que darían como resultado una ejecución arbitraria del shell. Debido a la complejidad de `cmd.exe`, no identificamos una solución que escapara correctamente de los argumentos en todos los casos. Para mantener nuestras garantías de API, mejoramos la solidez del código de escape y cambiamos la API `Command` para que devuelva un error [`InvalidInput`][4] cuando no puede escapar de forma segura de un argumento. Este error se emitirá al generar el proceso. La solución está incluida en Rust 1.77.2. Tenga en cuenta que la nueva lógica de escape para archivos por lotes es conservadora y podría rechazar argumentos válidos. Aquellos que implementan el escape ellos mismos o solo manejan entradas confiables en Windows también pueden usar el método `CommandExt::raw_arg` para evitar la lógica de escape de la librería estándar.
Summary (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`][4] 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. (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.

10 Apr 2024, 16:15

Type Values Removed Values Added
References
  • () https://www.kb.cert.org/vuls/id/123335 -

09 Apr 2024, 18:15

Type Values Removed Values Added
New CVE

Information

Published : 2024-04-09 18:15

Updated : 2024-05-01 18:15


NVD link : CVE-2024-24576

Mitre link : CVE-2024-24576

CVE.ORG link : CVE-2024-24576


JSON object : View

Products Affected

No product.

CWE
CWE-78

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CWE-88

Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')