Skip to content
Write-up Intermediate

Bundler is Still Vulnerable to Dependency Confusion Attacks (CVE-2020-36327)

Bundler fetched implicit private dependencies from any declared source, including public RubyGems, if a higher version existed there. An attacker could upload a malicious gem with the same name as a private dependency and a higher version, causing Bundler to install it.

zofrex.com

Published on zofrex.com

If you’re using Bundler to manage your dependencies, you probably know that you shouldn’t use multiple global sources, and should specify sources directly for private gems:

zofrex, on zofrex.com

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

Impact

An attacker could execute arbitrary code in the context of the application that uses the affected gem, potentially compromising the system.

What the attacker needed

Use Bundler with a private gem that has implicit private…; Attacker knows the name of the private dependency; Attacker can upload a gem to RubyGems with a higher version

The fix

The issue was fixed in Bundler 2.2.18, and mitigations such as virtual namespacing or explicitly declaring all dependencies are recommended.

How it was found

  1. Have a Gemfile with a private gem that depends on another private gem (implicit dependency).
  2. An attacker uploads a gem with the same name as the implicit dependency to RubyGems with a higher version number.
  3. Run bundle update.
  4. Bundler fetches the higher-version gem from RubyGems instead of the private repository.
  5. The malicious gem is installed and its code runs.

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 a tool that downloads and manages code libraries (gems) for Ruby projects. A dependency confusion attack happens when a private library name is also registered publicly with a higher version, so the tool downloads the public one instead of the private one. This can let an attacker run their own code inside your project.

Similar reports

Same bug class and techniques, clearest first.