Skip to content

Ruby2Shell CVE-2026-132825: How to Patch Ruby and GitLab

By Bikram Bhujel

Ruby2Shell is the kind of bug that sounds silly until you read the details. Upcase a string with enough German ß characters in an old single-byte encoding and Ruby writes one byte past the end of a heap buffer. Veria Labs, who named it, say that's enough for unauthenticated remote code execution against Rails and classic Sinatra apps in their default setup.

If you run a Rails app, or a self-hosted product built on Ruby like GitLab, Mastodon or Discourse, this one needs your attention this week. Here's how to check which Ruby your apps really run (it's often not the one on your PATH), how to update it, and what self-managed GitLab admins need to do, including the nginx issue the GitLab patch doesn't fix.

Terminal checking the embedded Ruby version on a self-managed GitLab server after patching Ruby2Shell CVE-2026-132825

Quick answer

Ruby2Shell (CVE-2026-132825, GHSA-34m4-m9fh-gqp5) is a one-byte heap overflow in Ruby's string case conversion, present since Ruby 2.4.0. It's fixed in Ruby 4.0.10, 3.4.13 and 3.3.14 (18 November 2026); Ruby 3.2 and older get no fix. Updating Rails or gems does nothing, because the bug is in the interpreter. Upgrade Ruby and restart every Ruby process. Self-managed GitLab needs 19.6.1, 19.5.8 or 19.4.10, which bundle the fixed Ruby, but GitLab's bundled nginx is still exposed to nginx2root, so disable HTTP/2 there until GitLab ships a fix.

What Ruby2Shell is

Some legacy encodings, ISO-8859-1 and Windows-1252 among them, have a lowercase ß but no uppercase form. When Ruby upcases it, it writes two letters, SS. According to Equixly's breakdown of the advisory, Ruby sizes the output buffer at the input length plus 20 bytes and checks for one byte of room before each step, then writes two bytes for every ß. Twenty-one ß characters are enough to write one byte past the end.

One byte doesn't sound like much. Veria Labs report it's enough for remote code execution without login against Rails and classic-style Sinatra in their default configuration. The Ruby team's own advisory says they're aware of proofs of concept that reach RCE "in some scenarios". The affected methods are upcase, swapcase, downcase(:fold) and casecmp?.

DetailValue
IDsCVE-2026-132825, GHSA-34m4-m9fh-gqp5
AffectedRuby 2.4.0 up to 4.0.9, 3.4.12 and 3.3.13
FixedRuby 4.0.10, 3.4.13, 3.3.14 (18 November 2026)
No fixRuby 3.2 and older (end of life)
Not affectedUTF-8 strings (separate code path); plain Rack apps unless they upcase legacy-encoded input
SeverityCritical per the Ruby team; MITRE CVSS 7.4

The same Ruby releases fix six other flaws in the regular expression engine and case conversion, which is another reason not to sit on this. The Ruby team announced them together on the Ruby news page.

Step 1: Find the Ruby your apps actually run

This is where people get caught. ruby -v in your shell tells you about one Ruby. Your app may be running a different one entirely: rbenv, asdf, a Docker base image, or a copy bundled inside a product.

# the Ruby on your PATH
ruby -v

# rbenv / asdf installs
rbenv versions 2>/dev/null; asdf list ruby 2>/dev/null

# what each running Ruby process is actually using
ps -eo pid,args | grep -E '[r]uby|[p]uma|[u]nicorn|[s]idekiq'
sudo ls -l /proc/<pid>/exe

# inside containers
for c in $(docker ps -q); do
  v=$(docker exec "$c" sh -c 'ruby -v 2>/dev/null')
  [ -n "$v" ] && echo "$(docker inspect -f '{{.Name}}' "$c"): $v"
done

Veria Labs list the latest releases of GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot as affected because they ship their own Ruby. Each needs its vendor's update, not yours.

Step 2: Upgrade Ruby for your own apps

Stay on your minor version and move to the fixed patch release. That's the smallest change and the least likely to break gems.

# rbenv
rbenv install 3.4.13
rbenv local 3.4.13        # in the app directory
bundle install

# asdf
asdf install ruby 3.4.13 && asdf set ruby 3.4.13

# Docker: bump the base image in your Dockerfile
FROM ruby:3.4.13-slim

Then restart every Ruby process: Puma or Unicorn, Sidekiq workers, cron jobs that run rake tasks. A running process keeps the old interpreter until it restarts. Distribution packages (Debian, Ubuntu, RHEL) will backport the fix into their own Ruby; check their trackers for CVE-2026-132825 if you use the system Ruby.

If you're still on Ruby 3.2 or older, there's no patch coming. Move the app to a supported branch, or at least put it behind something that stops untrusted legacy-encoded input reaching it, and plan the upgrade.

Step 3: Patch self-managed GitLab

GitLab shipped a critical patch release on 20 November: 19.6.1, 19.5.8 and 19.4.10. According to the GitLab patch release notes, these bump the bundled Ruby to 3.3.14 and 3.4.13 and also include the other fixes from the Ruby advisory. GitLab.com and GitLab Dedicated are already patched, so this is only for self-managed instances. Every version before those three is affected.

# check what you're on
sudo gitlab-rake gitlab:env:info | grep -i -E 'gitlab information|version'
/opt/gitlab/embedded/bin/ruby -v

# back up first
sudo gitlab-backup create

# Debian / Ubuntu Omnibus
sudo apt update && sudo apt install gitlab-ee=19.6.1-ee.0   # or gitlab-ce=19.6.1-ce.0

# Docker
docker pull gitlab/gitlab-ce:19.6.1-ce.0

GitLab says these patch releases have no new migrations and multi-node setups shouldn't need downtime, but single-node Omnibus will still stop, migrate and start again. Pick a quiet half hour. If you compile GitLab from source, you must rebuild the Ruby that runs GitLab with 3.3.14 or 3.4.13 yourself; the package update won't do it for you.

The catch: GitLab's nginx is still exposed

This caught a lot of admins out. GitLab bundles its own nginx under /opt/gitlab/embedded, and per heise, GitLab 19.6 ships nginx 1.31.7, which is still vulnerable to the nginx2root bugs fixed in nginx 1.31.9. Your distribution's nginx update doesn't touch it. Until GitLab ships a fixed nginx, the workaround is to switch off HTTP/2:

# /etc/gitlab/gitlab.rb
nginx['http2_enabled'] = false

sudo gitlab-ctl reconfigure
sudo /opt/gitlab/embedded/sbin/nginx -v

That covers the two HTTP/2 bugs, not all five. Someone on Hacker News asked whether turning HTTP/2 off breaks Git over HTTPS or the container registry; HTTP/1.1 is a normal fallback for both, but test a clone and a docker push after you change it. I wrote the full nginx side up on Monday in the nginx2root patching guide.

How to roll back

For your own apps, rolling back means pointing rbenv/asdf or your Dockerfile at the previous Ruby and restarting. Only do that to get past a broken gem for a few hours, since the old Ruby is the vulnerable one. For GitLab, restore from the backup you took and reinstall the previous package version. GitLab only supports restoring a backup onto the exact version that created it, so note your version number before upgrading. To undo the HTTP/2 change, remove the line from gitlab.rb and run gitlab-ctl reconfigure again.

A few things I learned

  • The interpreter is the patch. bundle update feels productive and fixes nothing here.
  • Your shell's Ruby isn't your app's Ruby. Check the running processes and the containers.
  • Bundled runtimes need vendor updates. GitLab, Mastodon and Discourse carry their own Ruby, and GitLab carries its own nginx too.
  • End-of-life Ruby is now a real risk. 3.2 and older won't be fixed.

This lands in the same week as the GPGME CVE-2026-129975 fix, which GitLab also helped bring to light. For more on how I run my own services, see Homelab Intelligence. If you need a GitLab or Rails server patched and checked, that's part of my DevOps and server services.

Frequently asked questions

What is Ruby2Shell?

Ruby2Shell, tracked as CVE-2026-132825 and GHSA-34m4-m9fh-gqp5, is a one-byte heap buffer overflow in Ruby's string case conversion for legacy single-byte encodings such as ISO-8859-1. Upcasing a string with 21 or more ß characters triggers it. Veria Labs report unauthenticated remote code execution against Rails and classic Sinatra apps.

Which Ruby versions fix Ruby2Shell?

Ruby 4.0.10, 3.4.13 and 3.3.14, released on 18 November 2026, fix it. Every release from Ruby 2.4.0 up to those versions is affected. Ruby 3.2 and older are end of life and will not get a fix, so apps on those versions need to move to a supported branch.

Does updating Rails fix Ruby2Shell?

No. The bug is in the Ruby interpreter itself, so updating Rails or any gem does nothing. You need to upgrade the Ruby runtime to 4.0.10, 3.4.13 or 3.3.14 and restart every Ruby process, including Puma, Unicorn and Sidekiq workers, so they load the fixed interpreter.

Which GitLab version fixes CVE-2026-132825?

GitLab 19.6.1, 19.5.8 and 19.4.10, released on 20 November 2026, bundle the fixed Ruby. All earlier self-managed versions are affected. GitLab.com and GitLab Dedicated are already patched. Self-compiled installs must rebuild their Ruby with 3.3.14 or 3.4.13 themselves.

Is GitLab 19.6.1 safe from nginx2root?

Not fully. GitLab 19.6.1 fixes the Ruby bug, but its bundled nginx is still a version affected by the nginx2root vulnerabilities. Until GitLab ships a fixed nginx, set nginx['http2_enabled'] = false in gitlab.rb and run gitlab-ctl reconfigure. This blocks the two HTTP/2 bugs.

Comments

Questions and corrections are welcome. I read every comment before it appears, and remove spam and promotional links.