Ruby2Shell: The One-Byte Overflow That Put Ruby RCE Before Authentication
CVE-2026-132825 (Ruby2Shell) is a critical heap buffer overflow in Ruby's string case conversion, reachable pre-auth on default Rails and Sinatra. What it is, who is exposed, and how to fix it.
· Updated 2026-11-24
- Security
- Ruby
- CVE-2026-132825
- Rails
- DevOps
Ruby2Shell: The One-Byte Overflow That Put Ruby RCE Before Authentication
On November 18-19, 2026 the Ruby core team released Ruby 4.0.10, 3.4.13 and 3.3.14 to fix seven vulnerabilities in the regular expression engine and in string case conversion. Proof-of-concept code demonstrating remote code execution exists for five of them. The headline flaw, dubbed Ruby2Shell and tracked as CVE-2026-132825 (GHSA-34m4-m9fh-gqp5), is a one-byte heap buffer overflow in how Ruby changes the case of strings - and according to Veria Labs, default Rails and classic-style Sinatra applications expose it to unauthenticated attackers before any application code or authentication check runs.
What actually happens
Ruby strings carry an encoding, and Ruby still supports many legacy single-byte encodings such as ISO-8859-1 (Latin-1) and Windows-1252 alongside UTF-8. In a single-byte encoding, changing the case of a character normally produces output of the same length - with one famous exception: the German sharp s (ß). Its uppercase form is two characters, SS.
In the affected code, Ruby checks that there is room for one byte but writes two. As the German sharp s shows, ß upcases to SS; in affected single-byte encodings Ruby verifies space for one byte but writes two, corrupting adjacent heap memory. Cloudflare reports that a string containing 21 sharp s characters overflows the output buffer by exactly one byte.
The vulnerable methods are upcase, swapcase, downcase(:fold) and casecmp? (and their Symbol counterparts) applied to strings in 14 legacy single-byte encodings (ISO-8859-1/-2/-3/-4/-9/-10/-13/-14/-15/-15-16 and Windows-1250/-1252/-1254/-1257). UTF-8 strings take a different code path and are not affected.
A single stray byte sounds harmless. In memory-corruption terms it is not: one controlled byte written past the end of a heap buffer can corrupt an adjacent object or allocator metadata. The Ruby advisory states the core team is aware of PoCs that turn this into code execution in some scenarios.
Why default Rails and Sinatra are exposed
HTML forms cannot send PUT or PATCH, so frameworks emulate them: Rack's MethodOverride middleware converts the _method parameter of a POST request to uppercase to resolve the route. Rails includes this middleware by default, and classic-style Sinatra enables it.
An attacker can send a multipart POST request whose _method part declares a legacy charset (e.g. charset=ISO-8859-1) and contains a run of sharp s characters - reportedly 21 of them is enough to reach the overflow. The framework upcases that value while it is still routing the request, before any controller code, before any authentication. That is what makes Ruby2Shell a pre-authentication primitive in stock configurations rather than something an application has to opt into by mistake.
Plain Rack applications and other frameworks are not exposed by default, per Veria Labs - but any application code that case-converts attacker-controlled text in a legacy single-byte encoding creates the same condition.
Severity: a 7.4 and a 9.8, and why both are defensible
The NVD entry for CVE-2026-132825 carries a preliminary CVSS 3.1 base score of 7.4 (High), while Red Hat's security bulletin (RHSB-2026-021) rates the same flaw Critical at 9.8 (AV:N/AC:L/PR:N/UI:N). The gap is a disagreement about exploitability, not about the bug:
- Network-reachable, no credentials, low complexity - the case conversion happens in framework plumbing, which pushes the score up.
- The realistic ceiling is lower - WatchTowr's Yordan Ganchev notes that reliable exploitation requires a favorable non-glibc memory allocator, specific runtime configuration and application logic, defeating ASLR, and surviving the noise of every other attacker hammering the same host. In practice, most exploitation attempts on patched-software-era targets are most likely to land as denial of service.
Neither number changes the recommendation: patch.
Who is affected
- Ruby itself: 3.3.0 through 3.3.13, 3.4.0 through 3.4.12, 4.0.0 through 4.0.9. Veria Labs reports the bug has been present since Ruby 2.4.0. Ruby 3.2 and earlier are end-of-life and will not receive fixes.
- Frameworks: Rails and classic-style Sinatra in default configuration.
- Bundled products: at disclosure, GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot all shipped an affected Ruby in their latest release. Vendors have since moved - Discourse, for example, switched its Docker base image to Ruby 4.0.10 on November 19, so rebuilding/redeploying the container picks up the fix.
Note that Ruby is typically installed at the OS or image level rather than as a gem dependency, so bundle audit style dependency scanning will not find this. Check the interpreter version itself (ruby -v, rpm -q ruby, your base image tag), and remember distribution packages may carry backported fixes under the same version number.
What to do
- Upgrade the interpreter - the only complete fix: Ruby 4.0.10, 3.4.13 or 3.3.14 (or your distribution's patched package). If Ruby is bundled inside a platform product, follow that vendor's advisory and redeploy.
- Reduce exposure while you patch. Put internet-facing self-hosted Ruby apps (GitLab, Mastodon, Discourse, internal Rails apps) behind a VPN, an authenticating reverse proxy, or strict IP allowlists. Cloudflare has shipped WAF rules covering Ruby2Shell and the related integer overflow (GHSA-87fm-7w84-j2px) for all customers, including the Free plan; equivalent rules can be written on Nginx or any WAF - reject requests declaring
charset=ISO-8859-*orcharset=Windows-125*, or reject raw0xDFbytes that are not part of a valid UTF-8 sequence. Test in log-only mode first so legitimate legacy integrations and binary uploads are not disrupted. Treat WAF rules as a compensating control, not a fix: exploits can reach the bug through paths the proxy never sees. - Audit your own case conversions. Search application code for
upcase,downcasewith:fold,swapcase,casecmp?and theirSymbolequivalents applied to external input - especially in header parsing, middleware and routing logic - and transcode or validate input as UTF-8 before it reaches that code.
The other six
The same release set also fixes six regex- and case-conversion-related flaws, five with PoCs demonstrating RCE: a double free in regexp compilation (GHSA-7x2q-68qv-6p8x), an integer overflow leading to a heap overflow when a case-converted result exceeds 4 GiB (GHSA-87fm-7w84-j2px), an out-of-bounds read in case-insensitive matching (GHSA-wpqw-5qxg-m68r), a heap overflow in regexp compilation (GHSA-3p8q-wmhx-vm2w), a heap overflow in Regexp#to_s (GHSA-7whj-cfh7-xgm4), and an out-of-bounds read in case-insensitive backreference matching (GHSA-pvgc-g7gj-pv6h). CVE identifiers for these were still pending at the time of writing, which is why advisories reference GHSA IDs. The action is the same: the upgrade fixes all seven in one shot.
Takeaways
- A one-byte off-by-one (CWE-193/CWE-787) in a string primitive in a language runtime is a supply-chain-scale problem: every app on the runtime inherits it, and gem-level tooling will not see it.
- Framework convenience features - here,
_methodoverride - can turn a narrow memory bug into a pre-auth attack surface. Middleware that transforms untrusted input before authentication deserves the same scrutiny as controllers. - Encoding support is legacy surface area. The bug lived quietly behind UTF-8's dominance since Ruby 2.4.0 and only surfaces when someone deliberately sends a legacy charset.
- Veria Labs stated it would publish its full PoC around November 25, 2026 (later if vendors lag). Expect exposure and attack traffic to climb fast after that - if any Ruby service in your estate is still unpatched, the window to act is now, not after the release.
Disclosure timeline: Ruby security advisory published November 18-19, 2026; Cloudflare WAF rules and Red Hat bulletin November 20, 2026.
Sources
- Ruby official advisory: multiple vulnerabilities in Regexp and String case conversion
- GHSA-34m4-m9fh-gqp5: Heap buffer overflow in case conversion of strings
- Red Hat RHSB-2026-021: One-byte heap overflow - ruby2shell (CVE-2026-132825)
- Cloudflare: How Cloudflare WAF protects against ruby2shell
- SecurityWeek: Ruby Patches Ruby2Shell Vulnerability That Could Lead to RCE