CVE-2021-43809 json
Local Code Execution through Argument Injection via dash leading git url parameter in Gemfile
published 2021-12-08 4 y ago modified 2026-11-02 6 d ago also GHSA-fj7f-vq84-fh43 , EUVD-2021-2513
- cvss
- 6.7
- version 3.1, CNA
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 2.9%
- EPSS 2.9% chance of exploitation in 30 days, percentile 87%
- public exploits
- 0
- none known
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.
Patch / fix
- rubygems bundler 2.2.33
- bundler bundler 2.2.33
- rubygems Debian 14, Debian 13, Debian 12 3.3.5-1
debian advisories DEBIAN-CVE-2021-43809
- ruby RHEL 8 2.5.9-114.module+el8.10.0+23088+750dc6ca
- ruby-irb RHEL 8 2.5.9-114.module+el8.10.0+23088+750dc6ca
- rubygems RHEL 8 2.7.6.3-114.module+el8.10.0+23088+750dc6ca
- ruby-libs RHEL 8 2.5.9-114.module+el8.10.0+23088+750dc6ca
- rubygem-pg RHEL 8 1.0.0-3.module+el8.9.0+19193+435404ae
- rubygem-abrt RHEL 8 0.3.0-4.module+el8.10.0+22021+135c76a8
- rubygem-bson RHEL 8 4.3.0-2.module+el8.9.0+19193+435404ae
- rubygem-json RHEL 8 2.1.0-114.module+el8.10.0+23088+750dc6ca
red hat advisories RHSA-2025:7539
- rubygem-bundler SLE Module for Basesystem 15 SP7 2.2.34-150700.21.3.1
- rubygem-bundler SLES for SAP 15 SP3, SLES for SAP 15 SP2, SLES 15 SP4-LTSS +6 more 1.16.1-150000.3.6.1
suse advisories SUSE-SU-2026:1355-1SUSE-SU-2024:3873-1
- ruby AlmaLinux 8 2.5.9-114.module_el8.10.0+3991+5e651d4e
- ruby-irb AlmaLinux 8 2.5.9-114.module_el8.10.0+3991+5e651d4e
- rubygems AlmaLinux 8 2.7.6.3-114.module_el8.10.0+3991+5e651d4e
- ruby-libs AlmaLinux 8 2.5.9-114.module_el8.10.0+3991+5e651d4e
- rubygem-pg AlmaLinux 8 1.0.0-3.module_el8.9.0+3635+c6f99506
- rubygem-abrt AlmaLinux 8 0.3.0-4.module_el8.5.0+2625+ec418553
- rubygem-bson AlmaLinux 8 4.3.0-2.module_el8.5.0+2625+ec418553
- rubygem-bson AlmaLinux 8 4.3.0-2.module_el8.6.0+3170+4b08f9d4
almalinux advisories ALSA-2025:7539
- ruby Rocky Linux 8 2.5.9-114.module+el8.10.0+1979+815637df
- rubygem-pg Rocky Linux 8 1.0.0-3.module+el8.9.0+1536+5f79634e
- rubygem-abrt Rocky Linux 8 0.3.0-4.module+el8.5.0+738+032c9c02
- rubygem-abrt Rocky Linux 8 0.3.0-4.module+el8.9.0+1536+5f79634e
- rubygem-bson Rocky Linux 8 4.3.0-2.module+el8.9.0+1536+5f79634e
- rubygem-mongo Rocky Linux 8 2.5.1-2.module+el8.9.0+1536+5f79634e
- rubygem-mysql2 Rocky Linux 8 0.4.10-4.module+el8.9.0+1536+5f79634e
- rubygem-bundler Rocky Linux 8 1.16.1-5.module+el8.10.0+1979+815637df
rocky linux advisories RLSA-2025:7539
- ruby-bundler Alpine 3.15 2.2.33-r0
alpine advisories ALPINE-CVE-2021-43809
Alpine secdb © Alpine Linux, from https://secdb.alpinelinux.org via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- github.com/rubygems/rubygems@0fad1cc commit
- github.com/rubygems/rubygems@a4f2f8a commit
- github.com/rubygems/rubygems#5142 pull request
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2021-43809 updated cvss 7.3
rubygem-bundler: unexpected code execution in Gemfiles
-
Red Hat Enterprise Linux 7 rubygem-bundleraffected: no fix planned “Out of support scope”
-
Red Hat Enterprise Linux 8 ruby, ruby-irb, rubygems, ruby-libs, rubygem-pg, rubygem-irb, +25 moreaffected: no fix available
-
Red Hat Enterprise Linux AppStream (v. 8) ruby 2.5.9-114.module+el8.10.0+23088+750dc6ca, rubygem-pg 1.0.0-3.module+el8.9.0+19193+435404ae, ruby-irb 2.5.9-114.module+el8.10.0+23088+750dc6ca, ruby-libs 2.5.9-114.module+el8.10.0+23088+750dc6ca, rubygem-bson 4.3.0-2.module+el8.9.0+19193+435404ae, rubygem-abrt 0.3.0-4.module+el8.10.0+22021+135c76a8, +17 morefixed: vendor fix RHSA-2025:7539
-
Red Hat Enterprise Linux 8 ruby, ruby-irb, rubygems, ruby-libs, rubygem-pg, rubygem-irb, +25 morenot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
CISA SSVC
- Exploitation
- none
- Automatable
- no
- Technical impact
- partial
- Assessed
- 6 d ago
Exploit prediction
2.91% chance of exploitation in the next 30 days, higher than 87% of all scored CVEs (FIRST EPSS, 2026-11-08).
Exploits and checks
- github.com https://github.com/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43 referenced PoC, tagged "exploit" by a source, unverified
- sonarsource.com https://www.sonarsource.com/blog/securing-developer-tools-package-managers/ referenced PoC, tagged "exploit" by a source, unverified
CVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| CNA | 3.1 | 6.7 | CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H |
| NVD | 3.1 | 7.3 | CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H |
| NVD | 2.0 | 9.3 | AV:N/AC:M/Au:N/C:C/I:C/A:C |
| GitHub | 3.1 | 6.7 | CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| rubygems | bundler | <2.2.33 |
2.2.33 |
Affected products
- rubygems rubygems
Classification
- Weakness
-
- CWE-88 Improper Neutralization of Argument Delimiters in a Command
References
-
github.com
/rubygems/rubygems/pull/5142
web, patch
-
github.com
/rubygems/rubygems/commit/0fad1ccfe9dd7a3c5b82c1496df3c2b4842870d3
web, patch
-
github.com
/rubygems/rubygems/commit/a4f2f8ac17e6ce81c689527a8b6f14381060d95f
web, patch
-
github.com
/rubygems/rubygems/security/advisories/GHSA-fj7f-vq84-fh43
web, exploit, vendor-advisory
-
sonarsource.com
/blog/securing-developer-tools-package-managers/
exploit, mitigation
-
lists.debian.org
/debian-lts-announce/2025/05/msg00015.html
web
-
nvd.nist.gov
/vuln/detail/CVE-2021-43809
advisory
-
github.com
/rubygems/rubygems
package
-
github.com
/rubysec/ruby-advisory-db/blob/master/gems/bundler/CVE-2021-43809.yml
web
-
sonarsource.com
/blog/securing-developer-tools-package-managers
web
Sources
- CVE List CVE-2021-43809
- GitHub Advisory GHSA-fj7f-vq84-fh43
- NVD CVE-2021-43809
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.