CVE-2021-43809
Vulnerability from cvelistv5
Published
2021-12-08 18:50
Modified
2024-08-04 04:03
Severity ?
EPSS score ?
Summary
`Bundler` is a package for managing application dependencies in Ruby. In `bundler` versions before 2.2.33, when working with untrusted and apparently harmless `Gemfile`'s, it is not expected that they lead to execution of external code, unless that's explicit in the ruby code inside the `Gemfile` itself. However, if the `Gemfile` includes `gem` entries that use the `git` option with invalid, but seemingly harmless, values with a leading dash, this can be false. To handle dependencies that come from a Git repository instead of a registry, Bundler uses various commands, such as `git clone`. These commands are being constructed using user input (e.g. the repository URL). When building the commands, Bundler versions before 2.2.33 correctly avoid Command Injection vulnerabilities by passing an array of arguments instead of a command string. However, there is the possibility that a user input starts with a dash (`-`) and is therefore treated as an optional argument instead of a positional one. This can lead to Code Execution because some of the commands have options that can be leveraged to run arbitrary executables. Since this value comes from the `Gemfile` file, it can contain any character, including a leading dash.
To exploit this vulnerability, an attacker has to craft a directory containing a `Gemfile` file that declares a dependency that is located in a Git repository. This dependency has to have a Git URL in the form of `-u./payload`. This URL will be used to construct a Git clone command but will be interpreted as the upload-pack argument. Then this directory needs to be shared with the victim, who then needs to run a command that evaluates the Gemfile, such as `bundle lock`, inside.
This vulnerability can lead to Arbitrary Code Execution, which could potentially lead to the takeover of the system. However, the exploitability is very low, because it requires a lot of user interaction. Bundler 2.2.33 has patched this problem by inserting `--` as an argument before any positional arguments to those Git commands that were affected by this issue. Regardless of whether users can upgrade or not, they should review any untrustred `Gemfile`'s before running any `bundler` commands that may read them, since they can contain arbitrary ruby code.
References
{ "containers": { "adp": [ { "providerMetadata": { "dateUpdated": "2024-08-04T04:03:08.862Z", "orgId": "af854a3a-2127-422b-91ae-364da2661108", "shortName": "CVE" }, "references": [ { "name": "https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43", "tags": [ "x_refsource_CONFIRM", "x_transferred" ], "url": "https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43" }, { "name": "https://github.com/rubygems/rubygems/pull/5142", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://github.com/rubygems/rubygems/pull/5142" }, { "name": "https://github.com/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://github.com/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3" }, { "name": "https://github.com/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://github.com/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f" }, { "name": "https://www.sonarsource.com/blog/securing-developer-tools-package-managers/", "tags": [ "x_refsource_MISC", "x_transferred" ], "url": "https://www.sonarsource.com/blog/securing-developer-tools-package-managers/" } ], "title": "CVE Program Container" } ], "cna": { "affected": [ { "product": "rubygems", "vendor": "rubygems", "versions": [ { "status": "affected", "version": "\u003c 2.2.33" } ] } ], "descriptions": [ { "lang": "en", "value": "`Bundler` is a package for managing application dependencies in Ruby. In `bundler` versions before 2.2.33, when working with untrusted and apparently harmless `Gemfile`\u0027s, it is not expected that they lead to execution of external code, unless that\u0027s explicit in the ruby code inside the `Gemfile` itself. However, if the `Gemfile` includes `gem` entries that use the `git` option with invalid, but seemingly harmless, values with a leading dash, this can be false. To handle dependencies that come from a Git repository instead of a registry, Bundler uses various commands, such as `git clone`. These commands are being constructed using user input (e.g. the repository URL). When building the commands, Bundler versions before 2.2.33 correctly avoid Command Injection vulnerabilities by passing an array of arguments instead of a command string. However, there is the possibility that a user input starts with a dash (`-`) and is therefore treated as an optional argument instead of a positional one. This can lead to Code Execution because some of the commands have options that can be leveraged to run arbitrary executables. Since this value comes from the `Gemfile` file, it can contain any character, including a leading dash.\n\nTo exploit this vulnerability, an attacker has to craft a directory containing a `Gemfile` file that declares a dependency that is located in a Git repository. This dependency has to have a Git URL in the form of `-u./payload`. This URL will be used to construct a Git clone command but will be interpreted as the upload-pack argument. Then this directory needs to be shared with the victim, who then needs to run a command that evaluates the Gemfile, such as `bundle lock`, inside.\n\nThis vulnerability can lead to Arbitrary Code Execution, which could potentially lead to the takeover of the system. However, the exploitability is very low, because it requires a lot of user interaction. Bundler 2.2.33 has patched this problem by inserting `--` as an argument before any positional arguments to those Git commands that were affected by this issue. Regardless of whether users can upgrade or not, they should review any untrustred `Gemfile`\u0027s before running any `bundler` commands that may read them, since they can contain arbitrary ruby code." } ], "metrics": [ { "cvssV3_1": { "attackComplexity": "HIGH", "attackVector": "LOCAL", "availabilityImpact": "HIGH", "baseScore": 6.7, "baseSeverity": "MEDIUM", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "privilegesRequired": "LOW", "scope": "UNCHANGED", "userInteraction": "REQUIRED", "vectorString": "CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H", "version": "3.1" } } ], "problemTypes": [ { "descriptions": [ { "cweId": "CWE-88", "description": "CWE-88: Improper Neutralization of Argument Delimiters in a Command (\u0027Argument Injection\u0027)", "lang": "en", "type": "CWE" } ] } ], "providerMetadata": { "dateUpdated": "2023-10-24T23:03:38.116Z", "orgId": "a0819718-46f1-4df5-94e2-005712e83aaa", "shortName": "GitHub_M" }, "references": [ { "name": "https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43", "tags": [ "x_refsource_CONFIRM" ], "url": "https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43" }, { "name": "https://github.com/rubygems/rubygems/pull/5142", "tags": [ "x_refsource_MISC" ], "url": "https://github.com/rubygems/rubygems/pull/5142" }, { "name": "https://github.com/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3", "tags": [ "x_refsource_MISC" ], "url": "https://github.com/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3" }, { "name": "https://github.com/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f", "tags": [ "x_refsource_MISC" ], "url": "https://github.com/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f" }, { "name": "https://www.sonarsource.com/blog/securing-developer-tools-package-managers/", "tags": [ "x_refsource_MISC" ], "url": "https://www.sonarsource.com/blog/securing-developer-tools-package-managers/" } ], "source": { "advisory": "GHSA-fj7f-vq84-fh43", "discovery": "UNKNOWN" }, "title": "Local Code Execution through Argument Injection via dash leading git url parameter in Gemfile" } }, "cveMetadata": { "assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa", "assignerShortName": "GitHub_M", "cveId": "CVE-2021-43809", "datePublished": "2021-12-08T18:50:12", "dateReserved": "2021-11-16T00:00:00", "dateUpdated": "2024-08-04T04:03:08.862Z", "state": "PUBLISHED" }, "dataType": "CVE_RECORD", "dataVersion": "5.1", "meta": { "nvd": "{\"cve\":{\"id\":\"CVE-2021-43809\",\"sourceIdentifier\":\"security-advisories@github.com\",\"published\":\"2021-12-08T19:15:10.067\",\"lastModified\":\"2024-11-21T06:29:50.260\",\"vulnStatus\":\"Modified\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"`Bundler` is a package for managing application dependencies in Ruby. In `bundler` versions before 2.2.33, when working with untrusted and apparently harmless `Gemfile`\u0027s, it is not expected that they lead to execution of external code, unless that\u0027s explicit in the ruby code inside the `Gemfile` itself. However, if the `Gemfile` includes `gem` entries that use the `git` option with invalid, but seemingly harmless, values with a leading dash, this can be false. To handle dependencies that come from a Git repository instead of a registry, Bundler uses various commands, such as `git clone`. These commands are being constructed using user input (e.g. the repository URL). When building the commands, Bundler versions before 2.2.33 correctly avoid Command Injection vulnerabilities by passing an array of arguments instead of a command string. However, there is the possibility that a user input starts with a dash (`-`) and is therefore treated as an optional argument instead of a positional one. This can lead to Code Execution because some of the commands have options that can be leveraged to run arbitrary executables. Since this value comes from the `Gemfile` file, it can contain any character, including a leading dash.\\n\\nTo exploit this vulnerability, an attacker has to craft a directory containing a `Gemfile` file that declares a dependency that is located in a Git repository. This dependency has to have a Git URL in the form of `-u./payload`. This URL will be used to construct a Git clone command but will be interpreted as the upload-pack argument. Then this directory needs to be shared with the victim, who then needs to run a command that evaluates the Gemfile, such as `bundle lock`, inside.\\n\\nThis vulnerability can lead to Arbitrary Code Execution, which could potentially lead to the takeover of the system. However, the exploitability is very low, because it requires a lot of user interaction. Bundler 2.2.33 has patched this problem by inserting `--` as an argument before any positional arguments to those Git commands that were affected by this issue. Regardless of whether users can upgrade or not, they should review any untrustred `Gemfile`\u0027s before running any `bundler` commands that may read them, since they can contain arbitrary ruby code.\"},{\"lang\":\"es\",\"value\":\"\\\"Bundler\\\" es un paquete para administrar las dependencias de las aplicaciones en Ruby. En \\\"bundler\\\" versiones anteriores a 2.2.33, cuando se trabaja con \\\"Gemfile\\\" no confiables y aparentemente inofensivos, no se espera que conlleven a una ejecuci\u00f3n de c\u00f3digo externo, a menos que est\u00e9 expl\u00edcito en el c\u00f3digo ruby dentro del propio \\\"Gemfile\\\". Sin embargo, si el \\\"Gemfile\\\" incluye entradas \\\"gem\\\" que usan la opci\u00f3n \\\"git\\\" con valores inv\u00e1lidos, pero aparentemente inofensivos, con un guion inicial, esto puede ser falso. Para manejar las dependencias que provienen de un repositorio Git en lugar de un registro, Bundler usa varios comandos, como \\\"git clone\\\". Estos comandos son construidos usando la entrada del usuario (por ejemplo, la URL del repositorio). Cuando son construidos los comandos, las versiones de Bundler anteriores a la 2.2.33, evitan correctamente las vulnerabilidades de inyecci\u00f3n de comandos pasando una matriz de argumentos en lugar de una cadena de comandos. Sin embargo, se presenta la posibilidad de que una entrada del usuario comience con un guion (\\\"-\\\") y por lo tanto sea tratada como un argumento opcional en lugar de posicional. Esto puede conllevar a una ejecuci\u00f3n de c\u00f3digo porque algunos de los comandos presentan opciones que pueden ser aprovechadas para ejecutar ejecutables arbitrarios. Como este valor proviene del archivo \\\"Gemfile\\\", puede contener cualquier car\u00e1cter, incluyendo un guion inicial. Para explotar esta vulnerabilidad, un atacante tiene que dise\u00f1ar un directorio que contenga un archivo \\\"Gemfile\\\" que declare una dependencia que sea encontrada en un repositorio Git. Esta dependencia tiene que tener una URL Git en forma de \\\"-u./payload\\\". Esta URL ser\u00e1 usada para construir un comando de clonaci\u00f3n de Git pero ser\u00e1 interpretada como el argumento de upload-pack. Entonces este directorio necesita ser compartido con la v\u00edctima, que entonces necesita ejecutar un comando que eval\u00fae el Gemfile, como \\\"bundle lock\\\", dentro. Esta vulnerabilidad puede conllevar a una ejecuci\u00f3n de c\u00f3digo arbitrario, que potencialmente podr\u00eda llevar a una toma de control del sistema. Sin embargo, la explotabilidad es muy baja, porque requiere mucha interacci\u00f3n del usuario. Bundler versi\u00f3n 2.2.33 ha parcheado este problema insertando \\\"--\\\" como argumento antes de cualquier argumento posicional a aquellos comandos Git que estaban afectados por este problema. Independientemente de si los usuarios pueden actualizar o no, deber\u00edan revisar cualquier \\\"Gemfile\\\" no confiable antes de ejecutar cualquier comando \\\"bundler\\\" que pueda leerlo, ya que puede contener c\u00f3digo ruby arbitrario\"}],\"metrics\":{\"cvssMetricV31\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H\",\"baseScore\":6.7,\"baseSeverity\":\"MEDIUM\",\"attackVector\":\"LOCAL\",\"attackComplexity\":\"HIGH\",\"privilegesRequired\":\"LOW\",\"userInteraction\":\"REQUIRED\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"HIGH\",\"integrityImpact\":\"HIGH\",\"availabilityImpact\":\"HIGH\"},\"exploitabilityScore\":0.8,\"impactScore\":5.9},{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"cvssData\":{\"version\":\"3.1\",\"vectorString\":\"CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H\",\"baseScore\":7.3,\"baseSeverity\":\"HIGH\",\"attackVector\":\"LOCAL\",\"attackComplexity\":\"LOW\",\"privilegesRequired\":\"LOW\",\"userInteraction\":\"REQUIRED\",\"scope\":\"UNCHANGED\",\"confidentialityImpact\":\"HIGH\",\"integrityImpact\":\"HIGH\",\"availabilityImpact\":\"HIGH\"},\"exploitabilityScore\":1.3,\"impactScore\":5.9}],\"cvssMetricV2\":[{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"cvssData\":{\"version\":\"2.0\",\"vectorString\":\"AV:N/AC:M/Au:N/C:C/I:C/A:C\",\"baseScore\":9.3,\"accessVector\":\"NETWORK\",\"accessComplexity\":\"MEDIUM\",\"authentication\":\"NONE\",\"confidentialityImpact\":\"COMPLETE\",\"integrityImpact\":\"COMPLETE\",\"availabilityImpact\":\"COMPLETE\"},\"baseSeverity\":\"HIGH\",\"exploitabilityScore\":8.6,\"impactScore\":10.0,\"acInsufInfo\":false,\"obtainAllPrivilege\":false,\"obtainUserPrivilege\":false,\"obtainOtherPrivilege\":false,\"userInteractionRequired\":true}]},\"weaknesses\":[{\"source\":\"security-advisories@github.com\",\"type\":\"Secondary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-88\"}]},{\"source\":\"nvd@nist.gov\",\"type\":\"Primary\",\"description\":[{\"lang\":\"en\",\"value\":\"CWE-88\"}]}],\"configurations\":[{\"nodes\":[{\"operator\":\"OR\",\"negate\":false,\"cpeMatch\":[{\"vulnerable\":true,\"criteria\":\"cpe:2.3:a:bundler:bundler:*:*:*:*:*:ruby:*:*\",\"versionEndExcluding\":\"2.2.33\",\"matchCriteriaId\":\"5C134C42-9FAA-4E67-8F6B-BDA0E632BE0B\"}]}]}],\"references\":[{\"url\":\"https://github.com/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/rubygems/rubygems/pull/5142\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Exploit\",\"Vendor Advisory\"]},{\"url\":\"https://www.sonarsource.com/blog/securing-developer-tools-package-managers/\",\"source\":\"security-advisories@github.com\",\"tags\":[\"Exploit\",\"Mitigation\"]},{\"url\":\"https://github.com/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/rubygems/rubygems/pull/5142\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Patch\"]},{\"url\":\"https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Exploit\",\"Vendor Advisory\"]},{\"url\":\"https://www.sonarsource.com/blog/securing-developer-tools-package-managers/\",\"source\":\"af854a3a-2127-422b-91ae-364da2661108\",\"tags\":[\"Exploit\",\"Mitigation\"]}]}}" } }
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.