Ruby2Shell: How to Find Every Ruby Your Servers Actually Run
On November 18, 2026, the Ruby team released Ruby 4.0.10, 3.4.13 and 3.3.14 to fix seven memory safety bugs. One of them now has a name: Ruby2Shell, tracked as CVE-2026-132825. Veria Labs, one of the teams that found it,
On November 18, 2026, the Ruby team released Ruby 4.0.10, 3.4.13 and 3.3.14 to fix seven memory safety bugs. One of them now has a name: Ruby2Shell, tracked as CVE-2026-132825. Veria Labs, one of the teams that found it, says it reaches remote code execution on a stock Rails app before any login. They plan to publish a proof of concept on November 25, 2026, or later if major vendors have not shipped a fix by then.
The obvious fix is "upgrade Ruby." The catch is that many servers run more than one Ruby. There is the one your package manager installed and the ones your version manager added. There are the ones inside your containers. And there are the ones that products like GitLab ship in their own install folders. apt upgrade only touches the first.
This guide walks through how to find all of them, decide which ones are affected, and what to do while you wait for vendors. It is based on the Ruby advisory, the researchers' write-ups, Cloudflare's analysis, and vendor release notes, all linked inline. The inventory script near the end was checked against stand-in binaries that print fixed and vulnerable version strings, not against a live fleet.
The bug in plain words
Ruby strings carry an encoding. Besides UTF-8, Ruby still supports old single-byte encodings such as ISO-8859-1 (Latin-1) and Windows-1252, where one character is one byte.
The German letter Γ has a problem in those encodings. They have no capital Γ, so the uppercase form is two letters: SS. According to Veria Labs, Ruby's case-conversion loop writes those two bytes but only checks that there is room for one. The output buffer is the input length plus 20 bytes, so an input with 21 Γ characters writes one byte past the end of the buffer.
One byte sounds small. Cloudflare's write-up explains why it is not: a single byte written past a heap buffer (a block of memory the program asked for at runtime) can corrupt the object next to it or the memory allocator's own bookkeeping. That is often enough for an attacker to take control.
Some details from the advisories:
- The bug is reached by
upcase,swapcase,downcase(:fold)andcasecmp?. - It affects 14 ISO-8859 and Windows-125x encodings. UTF-8 strings take a different code path and are not affected.
- The same loop has been in Ruby since version 2.4.0.
Why stock Rails is exposed before login
HTML forms can only send GET and POST. To fake PUT, PATCH or DELETE, Rack (the interface most Ruby web frameworks sit on) has a middleware called MethodOverride. It reads a _method field from the POST body and calls .upcase on it.
Rails includes this middleware by default, and classic-style Sinatra apps turn it on. A blog post by Moritz Sanft, one of the other people who found the bug, shows the last piece: Rack lets the client choose the encoding of each multipart field through a charset value. So an attacker can send a multipart POST with a _method field marked as ISO-8859-1 and filled with Γ characters. The upcase happens while the request is still being routed, before any application code or authentication check runs.
A commenter in the Hacker News thread summed it up: you can freely specify the encoding, for example charset=Windows-1252, because Rails respects it.
Veria Labs reports that other frameworks and plain Rack apps are not exposed by default. But any code that changes the case of a string received in a legacy encoding can still hit the bug, wherever the string comes from.
Which versions are affected
From the Ruby advisory and Veria Labs:
- Ruby 4.0: 4.0.0 to 4.0.9 affected, fixed in 4.0.10
- Ruby 3.4: 3.4.0 to 3.4.12 affected, fixed in 3.4.13
- Ruby 3.3: 3.3.0 to 3.3.13 affected, fixed in 3.3.14
- Ruby 3.2 and older (back to 2.4.0): affected, end of life, no upstream fix
The same releases fix six other bugs, five of them in Ruby's regular expression engine. Upgrading to a fixed version covers all seven. Ruby 3.3 is in its security maintenance phase, and Ruby 3.2 and earlier will not receive these fixes.
Step 1: The system Ruby and your distro packages
Start with what the operating system installed:
which -a ruby
ruby -v
which -a lists every ruby on your PATH, including the ones hidden behind the first match. Then check the package itself:
# Debian and Ubuntu
dpkg -l | grep -E '^ii +(ruby|libruby)'
# RHEL, Fedora, Rocky, Alma
rpm -qa | grep -i ruby
Here is the trap with distro packages: they often backport fixes without changing the upstream version number. Cloudflare's advisory warns about this directly. So ruby -v can print an old version on a patched system, and the package version is what you compare.
Debian shows both sides of this. On November 23, its security tracker listed a fixed ruby3.1 package for bookworm (via DLA-4926-1), even though upstream Ruby 3.1 is end of life. It also listed ruby3.3 version 3.3.14-0+deb13u1 as the fix for trixie (DSA-6644-1), while the package in unstable was still unfixed. Ubuntu keeps its own CVE page, which listed several of its Ruby packages as "Needs evaluation" when this was written. Check your distro's page. The version string alone can mislead you.
Step 2: Version managers and stray installs
Developers and deploy scripts often install Ruby outside the package manager. Common places:
-
rbenv:
rbenv versions, files under~/.rbenv/versions/ -
RVM:
rvm list, files under~/.rvm/rubies/or/usr/local/rvm/rubies/ -
asdf or mise:
asdf list rubyormise ls ruby -
chruby / ruby-install:
/opt/rubies/and~/.rubies/
Each of these needs its own upgrade, and each app should then point at the new version. Look for pins in your repos too:
grep -rnE '^FROM .*ruby:' --include='Dockerfile*' .
find . -name .ruby-version -o -name .tool-versions | xargs grep -H ruby
grep -n '^ruby ' Gemfile
A .ruby-version file that says 3.3.13 will keep pulling the vulnerable version back in, even after you install 3.3.14.
Step 3: Containers and images
A container ships its own Ruby, so the host's Ruby does not matter for it. For each running container:
docker ps --format '{{.Names}}'
docker exec <container> ruby -e 'print RUBY_VERSION'
For images that are built but not running:
docker run --rm --entrypoint ruby <image> -e 'print RUBY_VERSION'
Fixing a container means rebuilding the image on a fixed base (for example the official ruby image at 3.3.14, 3.4.13 or 4.0.10) and redeploying. Restarting the old container does nothing. Cloudflare's checklist also says to restart every Ruby process, including background workers. A Sidekiq worker that kept running on the old binary is still on the old binary.
Step 4: Products that bundle their own Ruby
This is the group the title is about. Some self-hosted products ship a private copy of Ruby in their own install folder. Your system Ruby can be fully patched while these keep running the old one. Only the vendor can ship the fix.
Veria Labs keeps a table of these products. At the time of disclosure, Aikido listed the bundled Ruby in each one's latest release: GitLab 19.6.0 shipped 3.3.13, GitHub Enterprise Server 3.22.5 shipped 4.0.9, and Chatwoot 4.20.0 shipped 3.4.4. Here is where each stood on November 23:
- GitLab: fixed in 19.6.1, 19.5.8 and 19.4.10, released November 20. The GitLab patch notes say official Linux packages and container images include the patched Ruby. Self-compiled installs must rebuild their own Ruby at 3.3.14 or 3.4.13 or later.
- GitHub Enterprise Server: the 3.22 release notes list 3.22.6, dated November 22, with a critical fix: "GitHub has updated Ruby to fix several announced vulnerabilities. Where an update was not immediately possible, mitigations were introduced at the application level." Note that Veria's table, last updated November 21, still showed GHES with no fix. If you run an older 3.x line, check the release notes for that line.
- Mastodon: fixed in 4.7.6, 4.6.12, 4.5.22 and 4.4.29, all released November 19.
- OpenProject: fixed in 17.9.8 and 17.8.3, both released November 19.
- Chatwoot: fixed in 4.20.1, whose changelog starts with "Upgraded to Ruby 3.4.13".
-
Discourse: the Docker base image moved to Ruby 4.0.10 on November 19. Per Veria, base images before
2.0.20261119-0203are affected. A rebuild picks up the fix:cd /var/discourse && ./launcher rebuild app, the standard command from the discourse_docker project.
For GitLab Omnibus installs, you can see the bundled Ruby directly. A post on Hacker News on disclosure day used exactly these commands to show that 19.6.0 still ran Ruby 3.3.13:
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
/opt/gitlab/embedded/bin/ruby --version
GitLab's own sudo gitlab-rake gitlab:env:info also prints a "Ruby Version" line, as shown in the GitLab maintenance docs.
Other products you run may bundle Ruby too. The list above is just the one the researchers checked. If a product has an embedded/ or vendor/ folder with its own bin/ruby, treat it the same way.
Step 5: One script to list them all
This script walks the filesystem for every executable named ruby, asks each one for its version, and does the same inside running containers. It flags each result against the fixed versions.
#!/usr/bin/env bash
# List every Ruby on this host and in running containers,
# and flag versions affected by Ruby2Shell (CVE-2026-132825).
verdict() {
local major minor patch
IFS=. read -r major minor patch <<< "$1"
case "$major.$minor" in
4.0) [ "$patch" -ge 10 ] && echo "fixed" || echo "VULNERABLE" ;;
3.4) [ "$patch" -ge 13 ] && echo "fixed" || echo "VULNERABLE" ;;
3.3) [ "$patch" -ge 14 ] && echo "fixed" || echo "VULNERABLE" ;;
*) echo "no upstream fix: check distro or vendor advisory" ;;
esac
}
echo "== Ruby binaries on disk =="
find / \( -path /proc -o -path /sys -o -path /var/lib/docker \) -prune \
-o -type f -name ruby -perm -u+x -print 2>/dev/null |
while read -r bin; do
v=$("$bin" -e 'print RUBY_VERSION' </dev/null 2>/dev/null) || continue
echo "$bin $v $(verdict "$v")"
done
if command -v docker >/dev/null 2>&1; then
echo "== Running containers =="
docker ps --format '{{.Names}}' | while read -r c; do
for r in ruby /opt/gitlab/embedded/bin/ruby; do
v=$(docker exec "$c" "$r" -e 'print RUBY_VERSION' </dev/null 2>/dev/null) || continue
echo "container $c ($r) $v $(verdict "$v")"
break
done
done
fi
Run it as root so find can see every folder. With stand-in binaries, the output looks like this (paths shortened):
== Ruby binaries on disk ==
/opt/app/3.3.13/bin/ruby 3.3.13 VULNERABLE
/opt/app/3.4.13/bin/ruby 3.4.13 fixed
/opt/app/3.1.2/bin/ruby 3.1.2 no upstream fix: check distro or vendor advisory
Read the output with two limits in mind:
- It reads version strings. A distro package with a backported fix may print an old version, and the script will flag it. For distro builds, the package version from Step 1 decides.
- It does not check bundled products for vendor patches. GHES, for example, says some fixes were "mitigations at the application level." For bundled products, the vendor's release notes decide.
Do not use the public crash reproducer (21 Γ characters passed to upcase) as a test. A one-byte write past a buffer does not reliably crash a process, so a clean run tells you nothing about whether you are safe.
What to do when you cannot patch yet
If a vendor has not shipped a fix, or your upgrade window is days away, there are two stopgaps.
Put a WAF in front. In a November 20 post, Cloudflare said it had added two managed rules: one for Ruby2Shell and one for GHSA-87fm-7w84-j2px, a related integer overflow in the same string code. Per Cloudflare, both are in the Free Managed Ruleset and the Cloudflare Managed Ruleset with Block as the default action. On paid plans, Cloudflare recommends checking that the Managed Ruleset is actually deployed on each zone. The Zero Wire briefing links straight to the rules.
Cloudflare is clear that a WAF is a "compensating control, not a replacement for patching." It cannot see requests sent straight to your origin IP, traffic between internal services, or Ruby code that changes the case of strings from email, file imports, message queues or background jobs.
Take the server off the public internet. Aikido's advice for self-hosted products is to make the server private, for example behind a VPN or an IP allowlist, until the vendor's fix lands. Ruby itself lists no workaround.
A side effect: one patch moved another project's schedule
Coordinated disclosure means many projects line up their release dates. Ruby2Shell shows what happens when one date moves.
GitLab had reported a separate bug to the GnuPG team: a double free (memory released twice) in GPGME, a library many mail clients and Samba use to talk to GnuPG. The disclosure date was set for November 25. According to the GnuPG announcement, "due to the new Ruby2Shell bug GitLab had to update earlier and thus we also disclosed the GPGME bug on 2026-11-20." That bug is CVE-2026-129975, fixed in GPGME 2.3.1. If your servers run anything that links GPGME, it belongs on the same patch list.
The checklist
- Run
which -a rubyand the inventory script on every host, as root. - Compare distro packages against your distro's CVE page, not the version string.
- Upgrade Ruby to 4.0.10, 3.4.13 or 3.3.14. Move anything on 3.2 or older to a supported series.
- Update
.ruby-version,.tool-versions,Gemfileand Dockerfile pins, then rebuild and redeploy images. - Restart every Ruby process, including background workers.
- Upgrade bundled products to the vendor's fixed release: GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Chatwoot, Discourse.
- Until then, keep a WAF rule in front and make self-hosted products private.
The proof of concept is due November 25. Which Ruby on your servers would you have missed with apt upgrade alone?
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.