---
title: "How We Fixed the Dependency Confusion Vulnerability in Over 600 Ruby Applications"
description: "Shopify closed a dependency confusion hole across roughly 600 Ruby applications by migrating each `Gemfile.lock` to Bundler's newer format, which pins every gem to an explicit source."
url: "https://swe.quest/articles/how-we-fixed-the-dependency-confusion-vulnerability-in-over-600-ruby-14f9a0a0836510b2"
canonical: "https://shopify.engineering/fixing-dependency-confusion-ruby-applications"
source: "Shopify Engineering"
published: "2022-01-27"
difficulty: "medium"
kind: "Case study"
reading_minutes: 9
tags: ["supply-chain-security","ruby","refactoring","ci-cd"]
---

# How We Fixed the Dependency Confusion Vulnerability in Over 600 Ruby Applications

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2022-01-27, 9 min read, Case study. Original: [https://shopify.engineering/fixing-dependency-confusion-ruby-applications](https://shopify.engineering/fixing-dependency-confusion-ruby-applications)

## Summary

Shopify closed a dependency confusion hole across roughly 600 Ruby applications by migrating each \`Gemfile.lock\` to Bundler's newer format, which pins every gem to an explicit source. A custom Bundler plugin did the upgrade without changing dependency versions: it allowed only patch updates during regeneration, then restored the original versions. A CLI running on top of CI gave each repository its own environment, ran the migrations in parallel and opened pull requests automatically. Shopify also failed CI on outdated Bundler versions and worked with the Bundler maintainers on changes that shipped in 2.2.21 and 2.2.22, the latter preventing lockfiles from regressing to the old format.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Supply chain security](https://swe.quest/tags/supply-chain-security.md) (Security)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)

## Prerequisites

- Ruby Bundler and Gemfile.lock ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))
- package dependency resolution
- CI pipelines ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))

## Keywords

Bundler, Gemfile.lock, dependency confusion, Heroku Ruby buildpack, Shopify

## Related posts

- [The Case Against Monkey Patching, From a Rails Core Team Member](https://swe.quest/articles/the-case-against-monkey-patching-from-a-rails-core-team-member-b0bd43ce3a761b2b.md): Shopify Engineering · 2023-02-21 · Medium · 14 min read · Ruby, Refactoring & migrations, Open source
  Monkey patching Rails and other gems is brittle and should be avoided.
- [Dependency prefixes are a supply chain risk: let's fix them](https://swe.quest/articles/dependency-prefixes-are-a-supply-chain-risk-let-s-fix-them-9228bb37d2c90199.md): Sourcegraph · 2026-05-22 · Medium · 5 min read · Supply chain security, JavaScript, Build systems, Refactoring & migrations
  SemVer range prefixes like ^, ~ and wildcards in package.json act as a trust policy that lets compromised or hijacked packages flow into CI and production on the next install.
- [Remove Circular Dependencies by Using Dependency Injection and the Repository Pattern in Ruby](https://swe.quest/articles/remove-circular-dependencies-by-using-dependency-injection-and-the-repository-605bdeddd937fd64.md): Shopify Engineering · 2021-03-19 · Medium · 8 min read · Ruby, Refactoring & migrations, Type systems, Testing
  Shopify broke a circular dependency between an internal pricing gem and its two consumers (the Shopify Core Rails monolith and the Storefront Renderer) by applying the Repository pattern with constructor-based dependency injection.
- [Building GitHub with Ruby and Rails](https://swe.quest/articles/building-github-with-ruby-and-rails-99851966c067c871.md): GitHub Engineering · 2023-04-06 · Medium · 5 min read · Ruby, Refactoring & migrations, CI/CD, Deployment, Open source
  GitHub's ~2M-line Rails monolith upgrades to the latest Rails main-branch commit every week via a scheduled GitHub Actions workflow that opens an automated PR, runs all builds, and ships the next day.
- [Ruby2Shell (CVE-2026-132825): find vulnerable Ruby across your repos](https://swe.quest/articles/ruby2shell-cve-2026-132825-find-vulnerable-ruby-across-your-repos-943808a4d97a4f48.md): Sourcegraph · 2026-11-20 · Medium · 5 min read · Ruby, Vulnerability research, Supply chain security, Developer tools
  Ruby2Shell (CVE-2026-132825) is a critical heap overflow in Ruby's string case conversion that researchers say default Rails and classic Sinatra apps expose without authentication, with remote code execution proofs of concept known.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
