Bundler's Multiple Source Security Vulnerability
Bundler resolves gems from the wrong source when a Gemfile declares more than one source, so a secondary source can silently supply gems that were meant to come from the primary one. An attacker who controls that secondary source could therefore inject arbitrary code into the application through a gem the developer believed came from elsewhere.
collectiveidea.com
Published on collectiveidea.com
Bundler has a major security vulnerability that affects all stable versions. The vulnerability allows an attacker to inject arbitrary code into your application via any secondary gem source declared in your gemfile, whether or not that source is scoped to specific gems.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely Bundler's dependency resolver does not reliably honour per-gem source restrictions, so once a secondary source is present it can satisfy gems that were not scoped to it.
Impact
All gems, including ones not scoped to the secondary source, could be installed from an unexpected location, letting an attacker who controls that source run arbitrary code in the application.
What the attacker needed
Gemfile declares a secondary gem source; Attacker controls that secondary source
The fix
The author says the issue appears patched in Bundler 2 development but will not be backported to Bundler 1; users should wrap every gem declaration in its own source block or use a single source.
How it was found
- Declare a primary and a secondary gem source in the Gemfile.
- Restrict one gem to the secondary source using the per-gem source option.
- Run bundle install from a clean state.
- Observe the gem server logs to see which server served each gem.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Bundler is the tool Ruby projects use to download the libraries (gems) a project depends on. A Gemfile lists where those gems should come from, and if it lists two places, Bundler can pick the wrong one without telling you. That means someone running the second place could hand you a tampered copy of a library you thought came from somewhere trusted.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.