CVE-2024-24576
Vulnerability from cvelistv5
Published
2024-04-09 17:28
Modified
2024-08-01 23:19
Severity ?
EPSS score ?
Summary
Rusts's `std::process::Command` did not properly escape arguments of batch files on Windows
References
{ "containers": { "adp": [ { "affected": [ { "cpes": [ "cpe:2.3:a:rust-lang:rust:*:*:*:*:*:*:*:*" ], "defaultStatus": "affected", "product": "rust", "vendor": "rust-lang", "versions": [ { "lessThan": "1.77.2", "status": "affected", "version": "0", "versionType": "semver" } ] } ], "metrics": [ { "other": { "content": { "id": "CVE-2024-24576", "options": [ { "Exploitation": "poc" }, { "Automatable": "yes" }, { "Technical Impact": "total" } ], "role": "CISA Coordinator", "timestamp": "2024-05-18T04:00:45.735598Z", "version": "2.0.3" }, "type": "ssvc" } } ], "providerMetadata": { "dateUpdated": "2024-06-06T14:12:09.344Z", "orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "shortName": "CISA-ADP" }, "title": "CISA ADP Vulnrichment" }, { "providerMetadata": { "dateUpdated": "2024-08-01T23:19:52.921Z", "orgId": "af854a3a-2127-422b-91ae-364da2661108", "shortName": "CVE" }, "references": [ { "name": "https://github.com/rust-lang/rust/security/advisories/GHSA-q455-m56c-85mh", "tags": [ "x_refsource_CONFIRM", "x_transferred" ], "url": "https://github.com/rust-lang/rust/security/advisories/GHSA-q455-m56c-85mh" }, { "name": "https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput" }, { "name": "https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg" }, { "name": "https://doc.rust-lang.org/std/process/struct.Command.html", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://doc.rust-lang.org/std/process/struct.Command.html" }, { "name": "https://doc.rust-lang.org/std/process/struct.Command.html#method.arg", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://doc.rust-lang.org/std/process/struct.Command.html#method.arg" }, { "name": "https://doc.rust-lang.org/std/process/struct.Command.html#method.args", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://doc.rust-lang.org/std/process/struct.Command.html#method.args" }, { "name": "https://github.com/rust-lang/rust/issues", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://github.com/rust-lang/rust/issues" }, { "name": "https://www.rust-lang.org/policies/security", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://www.rust-lang.org/policies/security" }, { "tags": [ "x_transferred" ], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W7WRFOIAZXYUPGXGR5UEEW7VTTOD4SZ3/" }, { "tags": [ "x_transferred" ], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RPH3PF7DVSS2LVIRLW254VWUPVKJN46P/" }, { "tags": [ "x_transferred" ], "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/N323QAEEUVTJ354BTVQ7UB6LYXUX2BCL/" }, { "tags": [ "x_transferred" ], "url": "http://www.openwall.com/lists/oss-security/2024/04/09/16" } ], "title": "CVE Program Container" } ], "cna": { "affected": [ { "product": "rust", "vendor": "rust-lang", "versions": [ { "status": "affected", "version": "\u003c 1.77.2" } ] } ], "descriptions": [ { "lang": "en", "value": "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.\n\nThe `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.\n\nOn 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\u0027s 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.\n\nOne 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.\n\nDue to the complexity of `cmd.exe`, we didn\u0027t 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.\n\nThe 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\u0027s escaping logic. " } ], "metrics": [ { "cvssV3_1": { "attackComplexity": "LOW", "attackVector": "NETWORK", "availabilityImpact": "HIGH", "baseScore": 10, "baseSeverity": "CRITICAL", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "NONE", "scope": "CHANGED", "userInteraction": "NONE", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", "version": "3.1" } } ], "problemTypes": [ { "descriptions": [ { "cweId": "CWE-78", "description": "CWE-78: Improper Neutralization of Special Elements used in an OS Command (\u0027OS Command Injection\u0027)", "lang": "en", "type": "CWE" } ] }, { "descriptions": [ { "cweId": "CWE-88", "description": "CWE-88: Improper Neutralization of Argument Delimiters in a Command (\u0027Argument Injection\u0027)", "lang": "en", "type": "CWE" } ] } ], "providerMetadata": { "dateUpdated": "2024-04-11T20:35:14.650Z", "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa", "shortName": "GitHub_M" }, "references": [ { "name": "https://github.com/rust-lang/rust/security/advisories/GHSA-q455-m56c-85mh", "tags": [ "x_refsource_CONFIRM" ], "url": "https://github.com/rust-lang/rust/security/advisories/GHSA-q455-m56c-85mh" }, { "name": "https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput", "tags": [ "x_refsource_MISC" ], "url": "https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput" }, { "name": "https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg", "tags": [ "x_refsource_MISC" ], "url": "https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg" }, { "name": "https://doc.rust-lang.org/std/process/struct.Command.html", "tags": [ "x_refsource_MISC" ], "url": "https://doc.rust-lang.org/std/process/struct.Command.html" }, { "name": "https://doc.rust-lang.org/std/process/struct.Command.html#method.arg", "tags": [ "x_refsource_MISC" ], "url": "https://doc.rust-lang.org/std/process/struct.Command.html#method.arg" }, { "name": "https://doc.rust-lang.org/std/process/struct.Command.html#method.args", "tags": [ "x_refsource_MISC" ], "url": "https://doc.rust-lang.org/std/process/struct.Command.html#method.args" }, { "name": "https://github.com/rust-lang/rust/issues", "tags": [ "x_refsource_MISC" ], "url": "https://github.com/rust-lang/rust/issues" }, { "name": "https://www.rust-lang.org/policies/security", "tags": [ "x_refsource_MISC" ], "url": "https://www.rust-lang.org/policies/security" }, { "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W7WRFOIAZXYUPGXGR5UEEW7VTTOD4SZ3/" }, { "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RPH3PF7DVSS2LVIRLW254VWUPVKJN46P/" }, { "url": "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/N323QAEEUVTJ354BTVQ7UB6LYXUX2BCL/" }, { "url": "http://www.openwall.com/lists/oss-security/2024/04/09/16" } ], "source": { "advisory": "GHSA-q455-m56c-85mh", "discovery": "UNKNOWN" }, "title": "Rusts\u0027s `std::process::Command` did not properly escape arguments of batch files on Windows" } }, "cveMetadata": { "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa", "assignerShortName": "GitHub_M", "cveId": "CVE-2024-24576", "datePublished": "2024-04-09T17:28:41.800Z", "dateReserved": "2024-01-25T15:09:40.211Z", "dateUpdated": "2024-08-01T23:19:52.921Z", "state": "PUBLISHED" }, "dataType": "CVE_RECORD", "dataVersion": "5.1", "meta": { "nvd": "{\"cve\":{\"id\":\"CVE-2024-24576\",\"sourceIdentifier\":\"security-advisories@github.com\",\"published\":\"2024-04-09T18:15:08.420\",\"lastModified\":\"2024-05-01T18:15:14.607\",\"vulnStatus\":\"Awaiting Analysis\",\"descriptions\":[{\"lang\":\"en\",\"value\":\"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.\\n\\nThe `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.\\n\\nOn 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\u0027s 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.\\n\\nOne 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.\\n\\nDue to the complexity of `cmd.exe`, we didn\u0027t 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.\\n\\nThe 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\u0027s escaping logic. \"},{\"lang\":\"es\",\"value\":\"Rust es un lenguaje de programaci\u00f3n. Se notific\u00f3 al Grupo de Trabajo de Respuesta de Seguridad de Rust que la librer\u00eda est\u00e1ndar de Rust anterior a la versi\u00f3n 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\u00eda ejecutar comandos de shell arbitrarios evitando el escape. La gravedad de esta vulnerabilidad es cr\u00edtica 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\u00f3n que los argumentos se pasar\u00e1n al proceso generado tal cual, independientemente del contenido de los argumentos, y no ser\u00e1n evaluados por un shell. Esto significa que deber\u00eda ser seguro pasar entradas que no sean de confianza como argumento. En Windows, la implementaci\u00f3n de esto es m\u00e1s compleja que en otras plataformas, porque la API de Windows solo proporciona una \u00fanica cadena que contiene todos los argumentos del proceso generado, y depende del proceso generado dividirlos. La mayor\u00eda de los programas utilizan el argv est\u00e1ndar en tiempo de ejecuci\u00f3n de C, que en la pr\u00e1ctica da como resultado una forma mayoritariamente consistente de dividir los argumentos. Sin embargo, una excepci\u00f3n es `cmd.exe` (utilizado, entre otras cosas, para ejecutar archivos por lotes), que tiene su propia l\u00f3gica de divisi\u00f3n de argumentos. Eso obliga a la librer\u00eda est\u00e1ndar a implementar un escape personalizado para los argumentos pasados a archivos por lotes. Desafortunadamente, se inform\u00f3 que nuestra l\u00f3gica de escape no era lo suficientemente exhaustiva y era posible pasar argumentos maliciosos que dar\u00edan como resultado una ejecuci\u00f3n arbitraria del shell. Debido a la complejidad de `cmd.exe`, no identificamos una soluci\u00f3n que escapara correctamente de los argumentos en todos los casos. Para mantener nuestras garant\u00edas de API, mejoramos la solidez del c\u00f3digo 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\u00e1 al generar el proceso. La soluci\u00f3n est\u00e1 incluida en Rust 1.77.2. Tenga en cuenta que la nueva l\u00f3gica de escape para archivos por lotes es conservadora y podr\u00eda rechazar argumentos v\u00e1lidos. Aquellos que implementan el escape ellos mismos o solo manejan entradas confiables en Windows tambi\u00e9n pueden usar el m\u00e9todo `CommandExt::raw_arg` para evitar la l\u00f3gica de escape de la librer\u00eda est\u00e1ndar.\"}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H\",\"attackVector\":\"NETWORK\",\"attackComplexity\":\"LOW\",\"privilegesRequired\":\"NONE\",\"userInteraction\":\"NONE\",\"scope\":\"CHANGED\",\"confidentialityImpact\":\"HIGH\",\"integrityImpact\":\"HIGH\",\"availabilityImpact\":\"HIGH\",\"baseScore\":10.0,\"baseSeverity\":\"CRITICAL\"},\"exploitabilityScore\":3.9,\"impactScore\":6.0}]},\"weaknesses\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-78\"},{\"lang\":\"en\",\"value\":\"CWE-88\"}]}],\"references\":[{\"url\":\"http://www.openwall.com/lists/oss-security/2024/04/09/16\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://doc.rust-lang.org/std/io/enum.ErrorKind.html#variant.InvalidInput\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://doc.rust-lang.org/std/process/struct.Command.html\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://doc.rust-lang.org/std/process/struct.Command.html#method.arg\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://doc.rust-lang.org/std/process/struct.Command.html#method.args\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://github.com/rust-lang/rust/issues\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://github.com/rust-lang/rust/security/advisories/GHSA-q455-m56c-85mh\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/N323QAEEUVTJ354BTVQ7UB6LYXUX2BCL/\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RPH3PF7DVSS2LVIRLW254VWUPVKJN46P/\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/W7WRFOIAZXYUPGXGR5UEEW7VTTOD4SZ3/\",\"source\":\"security-advisories@github.com\"},{\"url\":\"https://www.rust-lang.org/policies/security\",\"source\":\"security-advisories@github.com\"}]}}" } }
Loading...
Loading...
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.