Blog ·

Security PSA: Ruby2Shell, a Remote Code Execution Flaw in Ruby Affecting Rails Applications

Ruby2Shell is a heap overflow in Ruby that can allow remote code execution in Rails apps. Who's affected, how to fix it, and what we've done for clients.

Security PSA: Ruby2Shell heap overflow in Ruby, with the fixed Ruby versions

On 18 November 2026 the Ruby core team released security updates for every supported version of Ruby. The most serious fix is for a flaw the researchers who found it have named Ruby2Shell. It sits in the Ruby language itself, not in Rails or any gem, and it can be reached in a default Ruby on Rails application. If you run anything built on Ruby, please read on.

The short version

Ruby2Shell (GHSA-34m4-m9fh-gqp5)
WhatA one-byte heap buffer overflow in Ruby's string case conversion that may allow remote code execution
Who's affectedApplications running Ruby 3.3.13 and earlier, 3.4.0 to 3.4.12, or 4.0.0 to 4.0.9, including Rails and classic-style Sinatra apps
Fixed inRuby 4.0.10, 3.4.13 and 3.3.14
Not fixedRuby 3.2 and earlier are end of life and won't receive a fix
Digitize Rails clients with a support contractAlready updated. No action needed

What Ruby2Shell is

Ruby can change the case of text, for example turning "strasse" into "STRASSE". The German letter ß has no single capital letter in most older, single-byte text encodings, so Ruby converts it to two letters, "SS". The bug is that the code doing this conversion only checked there was room for one more byte. With enough ß characters in a string, Ruby writes one byte past the end of the memory it set aside.

One byte doesn't sound like much, but memory corruption bugs like this are a well-known route to taking over a program. The Ruby team says it is aware of proofs of concept that use this flaw to run code in some scenarios. The researchers at Veria Labs, who named the bug, report that it is reachable without logging in on a default Ruby on Rails application, and have said they will publish a proof of concept about a week after disclosure, once people have had time to upgrade. Once that's public, we'd expect attackers to start scanning for vulnerable sites quickly.

A few points worth knowing:

  • It's in Ruby, not Rails. Updating Rails or your gems does nothing for this flaw. The Ruby interpreter itself has to be upgraded.
  • It's old. The vulnerable code has been in Ruby since version 2.4.0, so long-running applications that haven't had a Ruby upgrade in years are affected.
  • It's not just your own apps. Self-hosted software built on Ruby is affected too, such as GitLab, GitHub Enterprise Server, Chatwoot, Mastodon, Discourse and OpenProject. Several have already published fixed releases.

The same Ruby releases also fix six other memory safety bugs in Ruby's regular expression engine and string handling, so upgrading is worthwhile even if you're confident your application never touches the vulnerable code path.

If your Rails application is with us under a support contract

This has already been handled. Every Ruby on Rails application we look after under a support contract has been upgraded to a patched Ruby release, rebuilt and redeployed. You don't need to do anything.

If you have a Rails application that isn't under a support contract with us, or one that's still on Ruby 3.2 or older, get in touch and we'll check it for you. Applications on end-of-life Ruby versions can't simply be patched, so they need a Ruby upgrade, and that's work we do regularly as part of our Ruby on Rails development and support.

What you should do

  1. Find out which Ruby you're running. Run ruby -v on the server, or check the .ruby-version file, the ruby line in your Gemfile, or the FROM ruby:... line in your Dockerfile.
  2. Upgrade to a fixed release: Ruby 4.0.10, 3.4.13 or 3.3.14. Update .ruby-version and your Gemfile to match, run bundle install, and run your test suite.
  3. Restart everything that runs Ruby. The old version stays in memory until each process restarts. That means your web server (Puma, Unicorn or Passenger), background workers such as Sidekiq, and any scheduled jobs.
  4. Rebuild your containers. If your application runs in Docker, pull the updated official ruby base image and rebuild. An image built last week is still running the old Ruby, however many times you restart it.
  5. Plan an upgrade if you're on Ruby 3.2 or older. There's no patch for these versions and the Ruby team lists no workaround. Ruby 3.3 also reaches the end of its official support at the end of March 2027, so if you're upgrading from 3.2 now, it's worth going straight to 3.4 or 4.0.
  6. Update self-hosted Ruby software like GitLab or Discourse to the vendor's latest release, which bundles a fixed Ruby.

If you install Ruby from your Linux distribution's packages rather than a version manager or Docker image, apply its security updates as they're published, and check the distribution's security tracker to confirm your package includes the fix.

Keeping a Rails application's Ruby and Rails versions current makes a fix like this a routine update rather than a project. We've written more about why updating and maintaining Ruby on Rails applications matters.

Need a hand?

If you're not sure whether your application is affected, or you'd like us to upgrade it, get in touch or call us on (08) 7081 1100. And if you'd rather security releases like this one were simply taken care of, ask us about ongoing Ruby on Rails support and managed hosting.

References

Related articles

Observability for Ruby on Rails with OpenTelemetry

A quick guide to adding OpenTelemetry to a Ruby on Rails app: install the gems, create an initialiser and launch Jaeger to find performance bottlenecks.

Read More

Essential Business Software: CRM, Manpower and Inventory

Why growing businesses need a CRM, a manpower management system and inventory software, and how custom solutions help manage customers, staff and stock.

Read More

Why Do People Use Microsoft Azure? Key Benefits Explained

Why businesses choose Microsoft Azure: global infrastructure, Microsoft ecosystem integration, machine learning, identity management and easy deployment.

Read More