Local Code Execution through Argument Injection via dash leading git url parameter in Gemfile

Summary

CVECVE-2021-43809
StatePUBLISHED
AssignerGitHub_M
Source PriorityCVE Program / NVD first with legacy fallback
Published2021-12-08 19:15:10 UTC
Updated2026-11-02 19:17:45 UTC
Description`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.

Risk And Classification

Primary CVSS: v3.1 7.3 HIGH from [email protected]

CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H

EPSS: 0.029090000 probability, percentile 0.869870000 (date 2026-11-02)

Problem Types: CWE-88 | CWE-88 CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')


VersionSourceTypeScoreSeverityVector
3.1[email protected]Primary7.3HIGHCVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H
3.1[email protected]Secondary6.7MEDIUMCVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
3.1CNADECLARED6.7MEDIUMCVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H
2.0[email protected]Primary9.3AV:N/AC:M/Au:N/C:C/I:C/A:C

CVSS v3.1 Breakdown

Attack Vector
Local
Attack Complexity
Low
Privileges Required
Low
User Interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H

CVSS v2.0 Breakdown

Access Vector
Network
Access Complexity
Medium
Authentication
None
Confidentiality
Complete
Integrity
Complete
Availability
Complete

AV:N/AC:M/Au:N/C:C/I:C/A:C

NVD Known Affected Configurations (CPE 2.3)

TypeVendorProductVersionUpdateEditionLanguage
Application Bundler Bundler All All All All

Vendor Declared Affected Products

SourceVendorProductVersionPlatforms
CNA Rubygems Rubygems affected < 2.2.33 Not specified

References

ReferenceSourceLinkTags
Local Code Execution through Argument Injection via dash leading git url parameter in Gemfile · Advisory · rubygems/rubygems · GitHub af854a3a-2127-422b-91ae-364da2661108 github.com Exploit, Vendor Advisory
Pass "--" to git commands to separate positional and optional args by deivid-rodriguez · Pull Request #5142 · rubygems/rubygems · GitHub af854a3a-2127-422b-91ae-364da2661108 github.com Patch
lists.debian.org/debian-lts-announce/2025/05/msg00015.html af854a3a-2127-422b-91ae-364da2661108 lists.debian.org
Securing Developer Tools: Package Managers | Sonar af854a3a-2127-422b-91ae-364da2661108 www.sonarsource.com Exploit, Mitigation
Changelog for Bundler version 2.2.33 · rubygems/rubygems@0fad1cc · GitHub af854a3a-2127-422b-91ae-364da2661108 github.com Patch
Add require parameter to `bundle add`` · rubygems/rubygems@a4f2f8a · GitHub af854a3a-2127-422b-91ae-364da2661108 github.com Patch
CVE Program record CVE.ORG www.cve.org canonical
NVD vulnerability detail NVD nvd.nist.gov canonical, analysis

Legacy QID Mappings

  • 184005 Debian Security Update for rubygems (CVE-2021-43809)
  • 502023 Alpine Linux Security Update for ruby-bundler

© CVE.report 2026

Use of this information constitutes acceptance for use in an AS IS condition. There are NO warranties, implied or otherwise, with regard to this information or its use. Any use of this information is at the user's risk. It is the responsibility of user to evaluate the accuracy, completeness or usefulness of any information, opinion, advice or other content. EACH USER WILL BE SOLELY RESPONSIBLE FOR ANY consequences of his or her direct or indirect use of this web site. ALL WARRANTIES OF ANY KIND ARE EXPRESSLY DISCLAIMED. This site will NOT BE LIABLE FOR ANY DIRECT, INDIRECT or any other kind of loss.

CVE, CWE, and OVAL are registred trademarks of The MITRE Corporation and the authoritative source of CVE content is MITRE's CVE web site. This site includes MITRE data granted under the following license.

Free CVE JSON API cve.report/api

CVE.report and Source URL Uptime Status status.cve.report