Critical Java and nginx flaws Java4Shell + nginx2rootScan my domain
RubyRailsRCECVEVulnerabilityGitLab

CVE-2026-132825 (Ruby2Shell): heap buffer overflow in Ruby string case conversion

Ruby2Shell (CVE-2026-132825): heap buffer overflow in Ruby, reachable without an account on Rails. Fixed in 3.3.14, 3.4.13 and 4.0.10. Affected products, checks.

by 17 min read
CVE-2026-132825 (Ruby2Shell): heap buffer overflow in Ruby string case conversion

Context

On 18 November 2026 the Ruby project released versions 4.0.10, 3.4.13 and 3.3.14. They fix seven memory-safety defects in the regular expression engine and in string case conversion.

One of them was given a name, Ruby2Shell, and the identifier CVE-2026-132825. Ruby writes one byte past a buffer when it changes the case of a string in certain single-byte encodings, such as ISO-8859-1 or Windows-1252. Its discoverers actually write "ruby2ßhell", with the letter that triggers the defect.

Ruby's advisory runs to a few lines. It rates the flaw critical and states that proofs of concept achieve code execution "in some scenarios", without saying which.

It took until the next day to find out. Veria Labs and researcher Moritz Sanft each published separately, and their two texts say the same thing: the flaw can be reached without an account on a Rails application in its default configuration, because the faulty conversion is performed by Rack, Rails' HTTP layer, before the application's code runs.

The CVE record, for its part, scores the flaw 7.4 with a local attack vector. A reader who stops at that score will file it among the flaws to handle within the month, and we think that would be a mistake for anything running on Rails.

We did not reproduce the flaw. This article relies on Ruby's announcement and advisory, on the fix commit, on the CVE record and on the publications from Veria Labs and Moritz Sanft.

Technical summary

ItemValue
IdentifiersCVE-2026-132825, "Ruby2Shell", advisory GHSA-34m4-m9fh-gqp5
ComponentCase conversion for ISO-8859 and Windows-125x encodings (enc/iso_8859_*.c and siblings)
ClassCWE-193, off-by-one error; one-byte out-of-bounds write on the heap
SeverityCritical for Ruby, with no score. CVE record (MITRE): CVSS 3.1 of 7.4
CVSS 3.1 vectorAV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H (MITRE)
Affected versionsRuby up to 3.3.13, 3.4.0 to 3.4.12, 4.0.0 to 4.0.9; code present since Ruby 2.4.0
FixesRuby 3.3.14, 3.4.13 and 4.0.10 (18 November 2026)
ConditionsCase change of an attacker-supplied string in an affected single-byte encoding
DiscoveryStephan Lipp (Ada Logics) and Anthropic for Ruby; Veria Labs and Moritz Sanft on their own
ExploitationNone reported as of 20 November; not in the KEV catalog (18 November edition)

The 7.4 score needs explaining, because it contradicts Ruby's rating. MITRE published the record on 19 November at 06

UTC, with a local vector and high complexity. Its description follows Ruby's advisory almost word for word, and that advisory says nothing about how a hostile string reaches the conversion. The record therefore describes the flaw of a program converting a string, without assuming that a remote attacker can supply it.

The publications from Veria Labs and Moritz Sanft, dated the same day, describe a path over the network, without an account, on a fresh Rails application. The record did not reflect them when we checked on 20 November.

We would treat the flaw as critical and remote on any exposed Rails or Sinatra application. The 7.4 remains defensible for a Ruby script that receives nothing from the network, and that is about the only case where we would use it. How we triage this kind of advisory is described in our article on vulnerability prioritization.

Affected systems

The interpreter

The flaw is in Ruby itself, and any application running on an affected version carries it. According to Veria Labs, the code at fault has existed since Ruby 2.4.0, released in late 2016.

Branches 3.2 and earlier are therefore affected, and the project will not fix them. Yet those are the ones the most widely installed distributions ship: Ruby 3.1 on Debian 12, Ruby 3.0 on Ubuntu 22.04, Ruby 3.2 on Ubuntu 24.04. For those servers the fix can only come from the distribution's maintainers, who will have to backport it themselves.

Rails and Sinatra applications

According to Veria Labs, the flaw is reachable in the default configuration of Rails and of classic-style Sinatra. Other frameworks and plain Rack applications are not exposed by default.

The path Moritz Sanft describes goes through Rack. While processing a form, Rack upcases the value of one field, and lets the client declare that field's encoding. A request can therefore have Rack convert a string in an affected encoding, before any application code. Moritz Sanft writes that an application created by rails new, with nothing else, is enough.

This is what makes the encoding question misleading. A team that only uses UTF-8 will think it is in the clear, when the encoding is chosen by whoever sends the request.

Code that changes case

An application not exposed by its framework can be exposed by its own code. The flaw is reached by four families of methods:

  • upcase and upcase!;
  • swapcase and swapcase!;
  • downcase(:fold) and downcase!(:fold);
  • casecmp?.

The string also has to be in one of the affected encodings: ISO-8859-1, 2, 3, 4, 9, 10, 13, 14, 15 and 16, or Windows-1250, 1252, 1254 and 1257. UTF-8 strings take a different code path and are not affected.

Importing old files, emails or a partner's data is the typical case where an application handles these encodings.

Products that bundle Ruby

Several self-hosted products ship their own interpreter. Updating the system Ruby changes nothing there, and the fix has to come from the vendor.

Veria Labs keeps a list of these products, which we reproduce as it stood on 20 November at 11

UTC.

ProductFixed versions
GitLab19.6.1, 19.5.8, 19.4.10
Mastodon4.7.6, 4.6.12, 4.5.22, 4.4.29
Chatwoot4.20.1
OpenProject17.9.8, 17.8.3
Discourse (base image)2.0.20261119-0203
GitHub Enterprise ServerNone, every version affected

We checked Mastodon's versions in its repository, where they are dated 19 November. The other rows are not cross-checked with each vendor, and a list kept by the author of the research should be verified before an update is scheduled on the strength of it.

How it works

This section draws on Ruby's advisory, the fix commit and the two publications. It does not give the shape of the request, which Moritz Sanft publishes.

A letter with no capital

Changing the case of a string in a single-byte encoding is in principle a simple operation: each input byte gives one output byte. Ruby sizes its output buffer on that basis.

The German ß breaks that rule. It has no capital in these encodings, and upcasing it gives "SS", which is two bytes. The conversion code knew this, since it did write both. It only checked for room for one.

With enough ß characters in the string, the second byte lands just past the end of the buffer.

The fix

The commit is titled "Fix a heap buffer overflow in case mapping of the sharp s". It changes fourteen files, one per affected encoding, and checks for room for two bytes instead of one.

Its author is Yusuke Endoh, of the Ruby team, on a report from Stephan Lipp. The commit is co-authored by an Anthropic AI model, as its header shows.

It is dated 28 October and was only published on 18 November. We come back to that delay in the timeline.

From one byte to code execution

An overflow of a single byte, whose value is imposed, is a weak primitive. The byte written is an "S" or an "s", and the attacker only chooses the size of the buffer.

Both teams nonetheless say they turned it into code execution. Moritz Sanft reports a first exploit against a test application on 26 October, then against a fresh Rails application on 5 November, with the jemalloc allocator and then with glibc's. Veria Labs says it was the first to demonstrate code execution.

None of that code is public. Veria Labs has announced its own for 25 November, or later if major vendors have not shipped a fix by then. We would take that date as the deadline: after the 25th a public exploit against Rails has to be expected, and exposed servers should be up to date before then.

Kill chain

From a form to a write past the buffer

  1. 1

    Form

    the attacker sends a form to a Rails application, without an account.

  2. 2

    Chosen encoding

    they declare an affected single-byte encoding for one field.

  3. 3

    Upcasing

    Rack converts that field's value while processing the request.

  4. 4

    Overflow

    the conversion writes one byte past the end of the output buffer.

  5. Heap corruption

    the research teams say they turn it into code execution in the Ruby process.

Sequence described by Veria Labs and Moritz Sanft. We did not reproduce it.

Available fixes

DistributionStatus recorded on 20 November 2026
Ruby (sources)4.0.10, 3.4.13, 3.3.14
ruby Docker images3.4.13 tags and equivalents published on 19 November at 02
UTC
Debian 13 (trixie)Vulnerable (ruby3.3 3.3.13-0+deb13u1)
Debian 12 (bookworm)Vulnerable (ruby3.1 3.1.2-7+deb12u1), branch end of life upstream
Debian forky, sidVulnerable (3.3.8-2.2)
Ubuntu 16.04 to 26.10Awaiting triage, no fixed package; priority "medium"

Neither Debian nor Ubuntu had a fixed package when we checked, and we could not read Red Hat's record. Debian 13 had nonetheless received Ruby 3.3.13 in October, for the regular expression engine flaws: that version, the most recent in the security repository, is affected by Ruby2Shell.

Servers that install Ruby through a version manager (rbenv, asdf, RVM) or an official Docker image can update right now. Those that depend on the distribution's package have to wait, and the section on interim measures matters most for them.

Checking a machine

The version that counts is that of the interpreter running the application, on web servers as well as on background job workers.

ruby -v
bundle exec ruby -v

The second command gives the version used in the application's context, which may differ from the system one. In a container:

docker exec <container> ruby -v

Products that bundle their Ruby keep it apart. For GitLab installed from the Omnibus package:

/opt/gitlab/embedded/bin/ruby -v

On a Rails application, the middleware list shows whether the one Moritz Sanft describes is loaded:

bin/rails middleware | grep -i MethodOverride

For the application's code, the search below gives the places where a string changes case. It returns many hits of no interest, and each has to be examined according to where the string comes from and its encoding.

grep -R -n -E '\.(upcase|swapcase|casecmp\?)|downcase!?\(:fold\)' app lib 2>/dev/null

From outside, the Ruby version cannot be read. The only way to settle the matter remotely would be to send the request that corrupts memory. We offer no remote test for this flaw.

Remediation

  1. Update Ruby to 4.0.10, 3.4.13 or 3.3.14.
  2. Restart application servers and workers. A process already running keeps the old interpreter in memory.
  3. Rebuild and redeploy container images.
  4. Update products that bundle Ruby to their vendor's fixed version.
  5. Migrate applications still on Ruby 3.2 or older to a maintained branch.

Updating Rails, Rack or gems does not replace the interpreter. It is the most likely mistake in a team used to fixing things with bundle update.

Until the update

Ruby's advisory gives no workaround. It recommends upgrading.

Moritz Sanft states that OpenAI worked with web application firewall vendors around the publication. If you use such a service, check that a rule for CVE-2026-132825 is active.

For want of anything better, the path described suggests measures that we have not tested and that no source validates. We give them for what they are.

At the front end, forms in which a part declares an encoding other than UTF-8 can be rejected. Few recent applications need to receive any.

In the application, the Rack::MethodOverride middleware can be removed when nothing uses it. That closes the published path, with no guarantee that it is the only one, and it does not protect code that itself changes the case of a string it received.

Looking for compromise

No indicator of compromise has been published.

A failed attempt most often crashes the process. Ruby then writes a recognizable crash report to the application's error output:

journalctl --since '2026-11-18' | grep -F '[BUG] Segmentation fault'
grep -R -F '[BUG]' log/ 2>/dev/null | tail -20

A series of crashes after 18 November, on a service that had been stable, should be set against the requests received at the same moment.

The requests to look for are form uploads in which a part declares an ISO-8859 or Windows-125x encoding. Access logs do not contain request bodies, and only a web application firewall or a network capture makes them visible.

This signal has its limits. A single crash has many other causes, and a successful exploitation does not necessarily leave one.

Timeline

Three teams found this flaw separately, in under a month: Ada Logics with Anthropic, Moritz Sanft with OpenAI, and Veria Labs. All three say they relied on AI models.

Moritz Sanft recounts that he started looking at Ruby on 23 October, after php2shell and node2shell, and that he had an exploit against a test application three days later.

The fix, for its part, was written on 28 October. It stayed out of the public repository for three weeks, when at least one other team already had an exploit and a third was searching on its own. We do not know the reasons for that delay, and Moritz Sanft only speaks of coordination that was "a bit bumpy at times" with the Ruby team. Seen from outside, it is a long time for a flaw that three teams find within a month.

Timeline

CVE-2026-132825 timeline

Origin

  1. December 2016

    Ruby 2.4.0

    according to Veria Labs, the case conversion code already has the defect.

Discovery

  1. 23 October 2026

    Regular expression fixes

    Ruby releases 4.0.9, 3.4.12 and 3.3.13. Moritz Sanft starts studying Ruby the same day.

  2. 26 October 2026

    First exploit

    Moritz Sanft obtains code execution on a test application and publishes its hash.

  3. 28 October 2026

    Fix commit

    Yusuke Endoh fixes the fourteen encodings, on a report from Stephan Lipp.

  4. 5 November 2026

    Second report

    OpenAI forwards Moritz Sanft's report to Ruby, with code execution on a fresh Rails application.

Disclosure

  1. 19 November 2026, 00

    Advisory and releases

    Ruby's announcement, advisory GHSA-34m4-m9fh-gqp5, Ruby 4.0.10, 3.4.13 and 3.3.14.

  2. 19 November 2026, 06

    CVE-2026-132825

    MITRE publishes the record, with a 7.4 score. Veria Labs and Moritz Sanft publish during the day, and Mastodon ships its fixed versions.

  3. 20 November 2026

    Status at this date

    Debian and Ubuntu without a fixed package, GitHub Enterprise Server without a fix, no attack reported.

Upcoming

  1. 25 November 2026

    Exploit code

    date announced by Veria Labs for the release of its own.

Dates taken from the ruby/ruby repository, ruby-lang.org, the CVE record and the publications from Veria Labs and Moritz Sanft. Times in UTC.

The six other flaws of 18 November

The same versions fix six other defects, which still had no CVE identifier on 20 November. They are tracked by their GHSA identifier.

Four concern the regular expression engine and require an application to compile a pattern supplied by the attacker: a double free (GHSA-7x2q-68qv-6p8x, critical), two buffer overflows (GHSA-3p8q-wmhx-vm2w, critical, and GHSA-7whj-cfh7-xgm4) and an out-of-bounds read (GHSA-wpqw-5qxg-m68r).

The fifth, GHSA-87fm-7w84-j2px, is a second case conversion flaw, through an integer overflow. Moritz Sanft reaches it by the same path as Ruby2Shell. According to him, Rack 3.2.2 and later limit field sizes and block that case.

The sixth, GHSA-pvgc-g7gj-pv6h, is an out-of-bounds read of moderate severity.

This is the second time in a month that Ruby has patched its regular expression engine. The 23 October fixes addressed the flaws found by GitLab, which we described in the article on CVE-2026-110264.

Knowing where Ruby runs

Ruby is less visible than PHP on an attack surface. It does not announce its version in a header, and it is often hidden inside a product: a GitLab forge, a Mastodon instance, a support or project management tool.

Those products are the ones installed once and rarely updated. They are also the most exposed, since they are made to be reached from the Internet.

That list is kept current continuously, by inventorying your external attack surface.

Frequently asked questions about Ruby2Shell (CVE-2026-132825)

What is Ruby2Shell?

A flaw in the Ruby interpreter, tracked as CVE-2026-132825. When Ruby changes the case of a string in certain single-byte encodings, it can write one byte past the output buffer. Researchers say they turned it into remote code execution on Rails applications.

Which Ruby versions are affected?

Ruby up to 3.3.13, from 3.4.0 to 3.4.12 and from 4.0.0 to 4.0.9. The fixed versions are 3.3.14, 3.4.13 and 4.0.10. Ruby 3.2 and earlier are affected and will receive no upstream fix.

Is updating Rails enough?

No. The flaw is in the Ruby interpreter, and not in Rails, Rack or a gem. A fixed version of Ruby has to be installed, and the application restarted.

My application only uses UTF-8. Am I affected?

Yes, if it runs on Rails or Sinatra. According to Moritz Sanft, the client can itself declare the encoding of a form field, and Rack converts that field before the application's code.

Is GitLab affected?

Yes. GitLab bundles its own Ruby. According to Veria Labs' list, the fixed versions are 19.6.1, 19.5.8 and 19.4.10.

Why does the CVE record give a 7.4 score?

Because MITRE used a local attack vector and high complexity, on the basis of Ruby's advisory. The publications describing a network path on Rails are not reflected in it. Ruby rates the flaw critical.

Is the flaw being exploited?

No attack has been reported as of 20 November 2026, and the flaw is not in CISA's KEV catalog. No complete exploit code is public. Veria Labs has announced the release of its own for 25 November.

Is there a workaround?

Ruby's advisory gives none. A web application firewall with a rule for this CVE reduces the risk while patching is under way. Updating Ruby remains the only complete measure.

Sources

Let’s discuss your external exposure

Request a personalized Flawfence demo and discover your real exposure level.