Skip to content
OpenAdvisories
Medium · 6.7 CVE-2021-43809 EUVD-2021-2513GHSA-fj7f-vq84-fh43

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

Published Dec 8, 2021 · Updated Nov 2, 2026 · Assigned by GitHub_M

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.

Affected products

VendorProductAffectedFixed
rubygems rubygems < 2.2.33 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 rubygems 3.3.5-1 —
Debian 13 rubygems 3.3.5-1 —
Debian 12 rubygems 3.3.5-1 —
Debian 11 rubygems 3.2.5-2+deb11u1 DLA-4163-1
ReleasePackageFixed inAdvisory
Ubuntu 20.04 LTS bundler No fix yet —
Ubuntu 16.04 LTS bundler No fix yet —
Show 1 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 18.04 LTS bundler No fix yet —
ReleasePackageFixed inAdvisory
RHEL 8 ruby +4 2.5.9-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-abrt +1 0.3.0-4.module+el8.10.0+22021+135c76a8 RHSA-2025:7539
RHEL 8 rubygem-bigdecimal 1.3.4-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-bson +1 4.3.0-2.module+el8.9.0+19193+435404ae RHSA-2025:7539
RHEL 8 rubygem-bundler +1 1.16.1-5.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-did_you_mean 1.2.0-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-io-console 0.4.6-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-json 2.1.0-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-minitest 5.10.3-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-mongo +1 2.5.1-2.module+el8.9.0+19193+435404ae RHSA-2025:7539
RHEL 8 rubygem-mysql2 +1 0.4.10-4.module+el8.9.0+19193+435404ae RHSA-2025:7539
RHEL 8 rubygem-net-telnet 0.1.1-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-openssl 2.1.2-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-pg +1 1.0.0-3.module+el8.9.0+19193+435404ae RHSA-2025:7539
RHEL 8 rubygem-power_assert 1.1.1-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-psych 3.0.2-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-rake 12.3.3-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-rdoc 6.0.1.1-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-test-unit 3.2.7-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygem-xmlrpc 0.3.0-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539
RHEL 8 rubygems +1 2.7.6.3-114.module+el8.10.0+23088+750dc6ca RHSA-2025:7539

AlmaLinux

Errata ↗
ReleasePackageFixed inAdvisory
AlmaLinux 8 ruby +4 2.5.9-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-abrt 0.3.0-4.module_el8.5.0+2625+ec418553 ALSA-2025:7539
AlmaLinux 8 rubygem-abrt-doc 0.3.0-4.module_el8.10.0+3871+342e2c2f ALSA-2025:7539
AlmaLinux 8 rubygem-bigdecimal 1.3.4-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-bson 4.3.0-2.module_el8.5.0+259+8cec6917 ALSA-2025:7539
AlmaLinux 8 rubygem-bson-doc 4.3.0-2.module_el8.5.0+2625+ec418553 ALSA-2025:7539
AlmaLinux 8 rubygem-bundler +1 1.16.1-5.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-did_you_mean 1.2.0-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-io-console 0.4.6-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-json 2.1.0-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-minitest 5.10.3-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-mongo +1 2.5.1-2.module_el8.5.0+2625+ec418553 ALSA-2025:7539
AlmaLinux 8 rubygem-mysql2 0.4.10-4.module_el8.5.0+259+8cec6917 ALSA-2025:7539
AlmaLinux 8 rubygem-mysql2-doc 0.4.10-4.module_el8.5.0+2625+ec418553 ALSA-2025:7539
AlmaLinux 8 rubygem-net-telnet 0.1.1-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-openssl 2.1.2-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-pg +1 1.0.0-3.module_el8.9.0+3635+c6f99506 ALSA-2025:7539
AlmaLinux 8 rubygem-power_assert 1.1.1-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-psych 3.0.2-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-rake 12.3.3-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-rdoc 6.0.1.1-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-test-unit 3.2.7-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygem-xmlrpc 0.3.0-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539
AlmaLinux 8 rubygems +1 2.7.6.3-114.module_el8.10.0+3991+5e651d4e ALSA-2025:7539

Rocky Linux

Errata ↗
ReleasePackageFixed inAdvisory
Rocky Linux 8 ruby 2.5.9-114.module+el8.10.0+1979+815637df RLSA-2025:7539
Rocky Linux 8 rubygem-abrt 0.3.0-4.module+el8.5.0+738+032c9c02 RLSA-2025:7539
Rocky Linux 8 rubygem-bson 4.3.0-2.module+el8.9.0+1536+5f79634e RLSA-2025:7539
Rocky Linux 8 rubygem-bundler 1.16.1-5.module+el8.10.0+1979+815637df RLSA-2025:7539
Rocky Linux 8 rubygem-mongo 2.5.1-2.module+el8.9.0+1536+5f79634e RLSA-2025:7539
Rocky Linux 8 rubygem-mysql2 0.4.10-4.module+el8.9.0+1536+5f79634e RLSA-2025:7539
Rocky Linux 8 rubygem-pg 1.0.0-3.module+el8.9.0+1536+5f79634e RLSA-2025:7539
ReleasePackageFixed inAdvisory
SLES 15 SP7 rubygem-bundler 2.2.34-150700.21.3.1 SUSE-SU-2026:1355-1
SLES 15 SP6 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
SLES 15 SP5 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
SLES 15 SP4 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
SLES 15 SP3 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
Show 4 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
SLES 15 SP2 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
SLES for SAP 15 SP3 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
SLES for SAP 15 SP2 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
SUSE Manager Server 4.3 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
ReleasePackageFixed inAdvisory
openSUSE Leap 15.5 rubygem-bundler 1.16.1-150000.3.6.1 SUSE-SU-2024:3873-1
ReleasePackageFixed inAdvisory
Alpine v3.15 ruby-bundler 2.2.33-r0 —

Oracle Linux

ReleasePackageFixed inAdvisory
Oracle Linux 8 ruby +4 2.5.9-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-abrt +1 0.3.0-4.module+el8.10.0+90367+ae9e8511 ELSA-2025-7539
Oracle Linux 8 rubygem-bigdecimal 1.3.4-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-bson +1 4.3.0-2.module+el8.9.0+90042+a65659a6 ELSA-2025-7539
Oracle Linux 8 rubygem-bundler +1 1.16.1-5.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-did_you_mean 1.2.0-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-io-console 0.4.6-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-json 2.1.0-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-minitest 5.10.3-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-mongo +1 2.5.1-2.module+el8.9.0+90042+a65659a6 ELSA-2025-7539
Oracle Linux 8 rubygem-mysql2 +1 0.4.10-4.module+el8.9.0+90042+a65659a6 ELSA-2025-7539
Oracle Linux 8 rubygem-net-telnet 0.1.1-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-openssl 2.1.2-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-pg +1 1.0.0-3.module+el8.9.0+90042+a65659a6 ELSA-2025-7539
Oracle Linux 8 rubygem-power_assert 1.1.1-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-psych 3.0.2-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-rake 12.3.3-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-rdoc 6.0.1.1-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-test-unit 3.2.7-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygem-xmlrpc 0.3.0-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539
Oracle Linux 8 rubygems +1 2.7.6.3-114.module+el8.10.0+90580+29305b94 ELSA-2025-7539

Affected packages

EcosystemPackageAffectedFixedRecord
RubyGems bundler < 2.2.33 2.2.33 GHSA-fj7f-vq84-fh43

Advisories 7

References