Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Shopify Engineering 5 min read Case study mediumAdept

Making Open Source Safer for Everyone with Shopify’s Bug Bounty Program

A Shopify bug bounty report showed that a leaked Rails development secret could be escalated to remote code execution because ActiveSupport's MessageEncryptor deserialized data with Marshal by default. Shopify patched its app to use JSON serialization, then contributed Rails changes making JSON the default serializer for MessageEncryptor and MessageVerifier starting in 7.1, with an upgrade path for existing apps. It also shares a patch that hooks Marshal.load and Marshal.dump in development and CI to flag unexpected calls from gems, tracking and deprecating Marshal use across an application.

Assumes: Ruby on Rails basicsinsecure deserialization

Related posts

  • The Case Against Monkey Patching, From a Rails Core Team Member

    Shopify Engineering mediumAdept

    Monkey patching Rails and other gems is brittle and should be avoided. Patches break silently on upgrades because private APIs carry no deprecation warnings, they can leave apps exposed after security releases, they pile up as tech debt, and they change behavior globally. Ruby refinements are not a safe alternative: at Shopify they added 13 seconds to monolith boot time by busting method caches and are now banned. Before patching, try upgrading, recheck usage, or fix the problem upstream. If a patch is unavoidable, keep it small and version-guarded in lib/patches, call super, document and test it, and plan its removal.

  • Caching Without Marshal Part 2: The Path to MessagePack

    Shopify Engineering mediumAdept

    Shopify replaced Ruby's Marshal with MessagePack as the Rails cache format for its core monolith so that code changes would stop breaking cached payloads on deploy. MessagePack only encodes types it knows about. Ruby types are added through registered extension types such as Date, Time, BigDecimal and a custom ActiveRecordCoder, which serializes records with their loaded associations and uses an instance tracker to handle circular references. The migration ran both formats side by side for about six months: payloads were prefixed with a version byte, the client fell back to Marshal when MessagePack raised NoMethodError, and each failure was logged to find missing extension types. Record payloads shrank up to 13x, total memcached usage fell by more than 25%, and decode errors from renamed classes are now treated as cache misses.

  • Ruby2Shell (CVE-2026-132825): find vulnerable Ruby across your repos

    Sourcegraph mediumAdept

    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. Fixed releases are 3.3.14, 3.4.13 and 4.0.10, and the hard part is finding which interpreter actually runs, because Dockerfiles, .ruby-version, Gemfile and Gemfile.lock can disagree and vendor products may bundle their own Ruby. Sourcegraph gives regex Code Search queries for affected version pins, a Deep Search prompt to reconcile pins per repo, and an Agentic Batch Changes prompt to bump exact pins within each series. Floating tags, unresolved build args and Ruby 3.2 or earlier are flagged for rebuild, review or migration rather than edited automatically.

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

    Shopify Engineering mediumAdept

    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.

  • How GitHub converts previously encrypted and unencrypted columns to ActiveRecord encrypted columns

    GitHub Engineering mediumAdept

    GitHub migrated plaintext columns and columns encrypted with a deprecated internal library to ActiveRecord::Encryption. It used per-model previous encryptors instead of the global support_unencrypted_data option, and a custom ActiveModel type gated by an inverted, long-lived feature flag that acts as an on/off switch for each column. A changed_in_place? bug compared decrypted plaintext to stored ciphertext, which raised false 2FA recovery-code alerts in customer security logs; delegating the check to EncryptedAttributeType fixed it. A simplified recipe using a previous encryptor plus the MaintenanceTasks gem backfills existing records, and the same flow handles key rotation by adding a new key and re-running the task.

The quest for software engineering knowledge.

Look:
Layout: