RubyGems

The bootstrap-sass RubyGems Supply Chain Attack

Updated 5 Oct 2026 · Incident date 26 Mar 2019

bootstrap-sass 3.2.0.3 on RubyGems added a file that lets a remote client run code inside a Rails app, published on 26 March 2019.

The gem has about 28 million downloads in total. The bad version was live for a short time.

What happened

An attacker published bootstrap-sass 3.2.0.3 with a hidden backdoor.

  • The attacker removed the clean 3.2.0.2 release first, so new installs of the 3.2.0.x line got the bad version.
  • The new file lib/active-controller/middleware.rb changes a Rails method.
  • The method reads the HTTP cookie ___cfduid and decodes the value with base64. The name has three underscores and copies the real Cloudflare cookie __cfduid.
  • It runs the result with eval, in production mode only.
  • Anyone who can send a request to the app can run commands on the server.

Derek Barnes reported the difference between the gem and the source on 26 March 2019. The bad version left RubyGems less than one hour later. Version 3.2.0.4 followed on 3 April 2019.

Affected versions

  • 3.2.0.3: backdoored, published 26 March 2019.
  • 3.2.0.2: the last clean release before the attack, from September 2014 per LWN.
  • 3.2.0.4: clean re-release of 3.2.0.2, published 3 April 2019.
  • 3.4.x: not affected.

Indicators of compromise

  • A gem folder named bootstrap-sass-3.2.0.3.
  • The file lib/active-controller/middleware.rb inside the gem.
  • Requests with a cookie named ___cfduid (three underscores) in web server or proxy logs.
  • SHA256 of the 3.2.0.3 gem, per Snyk: 366d6162fe36fc81dadc114558b43c6c8890c8bcc7e90e2949ae6344d0785dc0.

How to check

Look for version 3.2.0.3 in your lock file and installed gems. Then search your logs for the three-underscore cookie.

grep -n "bootstrap-sass" Gemfile.lock
gem list bootstrap-sass
grep -rF "___cfduid" /var/log/

What to do now

  1. Run bundle update bootstrap-sass to reach 3.2.0.4 or later. Commit the new Gemfile.lock and redeploy every production host that ran 3.2.0.3.
  2. Search logs from 26 March 2019 onward for the ___cfduid cookie. A match means someone sent code to the app.
  3. If a match exists, treat the server as compromised. Rotate the secrets that the app can read, such as database passwords, API keys and session secrets.
  4. Pin gem versions in the lock file and review each new gem version before you deploy it.

Frequently asked questions

How many installs did the bad version get?

LWN reports 1,477 downloads of 3.2.0.3. Snyk estimates about 1,670 repositories that use the gem directly.

Was the code in the GitHub repository?

No. It was only in the published gem. Derek Barnes found it by comparing the gem with the source.

Did the backdoor run in development?

No. According to the reports, the code runs only when the Rails app is in production mode.

Sources

  1. snyk.io/blog/malicious-remote-code-execution-backdoor-discovered-in-the-popular-bootstrap-sass-ruby-gem/
  2. lwn.net/Articles/785386/

Send this page to the person who looks after AI at your company.

Email it

More supply chain attacks

All 172 attacks in the library · What is a supply chain attack? · How to prevent supply chain attacks

Check the next update before you install it

Vigilance compares the version you trust with the new one. It names the one file that gained a power the old version did not have.

Start the free 14-day trialBrowse the attack library