ruby2shell: Veria Labs Says a One-Byte Ruby Heap Overflow Is Reachable in Default Rails and Sinatra, and How to Check Your Fleet

Ruby 3.3.14, 3.4.13 and 4.0.10 fix seven memory-safety bugs, including CVE-2026-132825 in string case conversion. Which apps reach it, how to find stale Ruby runtimes and images, and an untested Ruby guard for legacy-encoded input.

On 18 November 2026 the Ruby team released Ruby 4.0.10, 3.4.13 and 3.3.14 to fix seven memory-safety vulnerabilities in the regular expression engine and in string case conversion. Ruby says it is “aware of PoCs that prove some of them can be used to trigger remote code execution” and “strongly recommend[s] upgrading.” One of them, a one-byte heap overflow, has been nicknamed ruby2shell and now has the identifier CVE-2026-132825. Facts below come from the Ruby advisory, the GitHub advisory GHSA-34m4-m9fh-gqp5, the CVE record, Cloudflare’s 20 November write-up, and Veria Labs’ own page (updated 21 November). The remote-reachability claims are Veria’s; Ruby’s advisory says only that RCE is possible in some scenarios.

What the bug is

Per Ruby’s GitHub advisory, when changing the case of a string in some single-byte encodings, such as ISO-8859-1 and Windows-1252, Ruby “could write one byte past the end of the output buffer.” Cloudflare, citing Veria Labs, explains the mechanism: the German sharp s uppercases to two characters (“SS”), and in 14 legacy encodings Ruby writes both bytes but checks room for only one. Per Veria, 21 sharp s characters are enough to overflow by one byte, and upcase, swapcase, downcase(:fold) and casecmp? reach it. UTF-8 strings take a different code path and are not affected.

The GitHub advisory lists severity critical and CWE-193; the CVE record (MITRE as CNA) lists CWE-122 and CVSS 3.1 7.4 with a Local attack vector. Since Veria (via Cloudflare) reports remote reachability and its page lists network access with no authentication in default Rails apps (next section), we treat the Local vector as a poor guide to real exposure. That reading is ours.

Why default Rails and Sinatra apps are reachable

Per Cloudflare, citing Veria Labs: browsers only send GET and POST from forms, so frameworks accept a _method parameter to simulate PUT, PATCH or DELETE. Rack’s MethodOverride middleware uppercases that value. Rails includes the middleware by default and classic-style Sinatra enables it. A multipart POST whose _method part declares a legacy charset and contains the trigger characters gets upcased during routing, before application code or authentication runs. Veria reports other frameworks and plain Rack apps are not exposed by default, but any code that changes the case of attacker-controlled strings in a legacy single-byte encoding may be.

Veria says it will publish its proof of concept on 25 November 2026, or later if major vendors have not shipped a fix by then. A third-party repository (evenomn/CVE-2026-132825) is already linked from the CVE record; its README describes local crash reproduction and heap corruption and says it did not build or verify a remote delivery path (we read the README only, not the code). We found no evidence as of 21 November 2026, in the Ruby advisory, GHSA, NVD, CISA KEV (catalog 2026.11.20), Cloudflare or Veria pages, of in-the-wild exploitation. NVD has not yet scored the CVE (status Received); the 7.4 is from MITRE as CNA, and “critical” is the label on the GitHub advisory.

The other six

The release fixes six more. GHSA-87fm-7w84-j2px is an integer overflow in the same case-conversion code. Five are in the regex engine (double free, heap overflows, out-of-bounds reads). Ruby says the regex bugs matter for “applications that compile attacker-controlled patterns”; Cloudflare says most of the seven need an attacker-supplied regular expression. Think search or filter features; one is described as disclosure or crash only. Ruby said CVE IDs were requested but not yet assigned for the others, so check the GHSA pages for current IDs.

Affected versions

Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. Ruby 3.2 and earlier are end of life and get no fix. Veria says the bug dates to Ruby 2.4.0 (via Cloudflare). Per Veria via Cloudflare (as of 19 November), the latest releases of GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot bundled an affected Ruby on 19 November; Discourse then moved its Docker base image to Ruby 4.0.10. Distribution packages may backport fixes without changing the version number.

Check your fleet

Find runtimes and images first. Untested sketch:

ruby -v
# Pinned versions in repos, checked per file type
grep -En '^(ruby-)?[0-9]+\.[0-9]+\.[0-9]+' .ruby-version 2>/dev/null
grep -En '^ruby ' .tool-versions 2>/dev/null
grep -En "^ruby ['\"]" Gemfile 2>/dev/null
grep -En '^FROM .*ruby' Dockerfile* 2>/dev/null

A runtime guard that fails a boot or CI check on a vulnerable interpreter (untested; it compares the version only, so it will wrongly flag distro builds with backported fixes and any series not in the table, such as a future 4.1):

# config/initializers/ruby_patch_gate.rb (untested)
FIXED = { [3, 3] => 14, [3, 4] => 13, [4, 0] => 10 }.freeze
major, minor, patch = RUBY_VERSION.split(".").map(&:to_i)
fixed_patch = FIXED[[major, minor]]
if fixed_patch.nil? || patch < fixed_patch
  warn "Ruby #{RUBY_VERSION} is below the 18 Nov 2026 security release"
  exit 1 if ENV["RUBY_PATCH_ENFORCE"] == "1"
end

Patch first, then harden

  1. Upgrade to 3.3.14, 3.4.13 or 4.0.10; restart every Ruby process including background workers; rebuild container images rather than patching in place.
  2. Update bundled products (GitLab, Discourse, Mastodon and the like) to releases that carry the fixed Ruby. Per Veria’s page (single source), fixed releases exist for GitLab, Mastodon, OpenProject, Chatwoot and Discourse, while GitHub Enterprise Server 3.22.5 and earlier have no fixed release; we did not open GitHub’s own advisory.
  3. Move anything on Ruby 3.2 or earlier to a supported series.

While waiting, two stopgaps of our own, neither verified against the exploit and neither a substitute for patching. First, reject non-UTF-8 input before changing its case (force_encoding reinterprets bytes without transcoding, so legacy high bytes fail the validity check):

# untested
def safe_upcase(input)
  s = input.dup.force_encoding(Encoding::UTF_8)
  raise ArgumentError, "invalid text" unless s.valid_encoding?
  s.upcase
end

This does not cover the framework path, where Rack does the upcase for you. Second, if no form in your app relies on _method, Rails lets you remove the middleware (config.middleware.delete Rack::MethodOverride, untested here), which would also break any button_to PATCH/DELETE forms.

Cloudflare says its WAF blocks ruby2shell on all plans, but cautions that it “is a compensating control, not a replacement for patching”: direct-to-origin traffic and non-HTTP inputs bypass it.

Timeline

  • 18 Nov 2026: Ruby news post dated 18 Nov announces Ruby 4.0.10, 3.4.13 and 3.3.14. The advisory history says originally published 2026-11-19 00:00 UTC, and the GitHub advisory is dated 19 Nov.
  • 19 Nov: CVE-2026-132825 reserved and published.
  • 20 Nov: Cloudflare WAF rules and write-up.

Credit: the Ruby advisory credits Stephan Lipp (Ada Logics) and Anthropic for GHSA-34m4-m9fh-gqp5; Veria says it found the bug independently.

Sources: Veria Labs (verialabs.com/ruby2shell); ruby-lang.org advisory “Multiple vulnerabilities in Regexp and String case conversion”; GitHub GHSA-34m4-m9fh-gqp5; CVE record CVE-2026-132825 (cveawg.mitre.org); Cloudflare blog “How Cloudflare WAF protects against ruby2shell”.