Ruby2Shell: Ruby case-conversion bug hits Rails and Sinatra
CVE-2026-132825 / GHSA-34m4-m9fh-gqp5: a one-byte heap overflow in Ruby case conversion, reachable through legacy encodings. Affected versions, patches, and self-hosted impact.

Ruby published an advisory on November 18, 2026 covering seven vulnerabilities in its Regexp and String case-conversion layers. The next day MITRE assigned CVE-2026-132825 to the main bug. Veria Labs called the issue Ruby2Shell and framed it as “pre-auth RCE on stock Rails.” Ruby’s own advisory is more careful: PoCs prove that some of these flaws can trigger remote code execution in some scenarios. Keep those two statements separate.
This post sticks to verified sources: the Ruby advisory, the GHSA record, the MITRE CVE record, the fix commit, and Veria Labs’ technical write-up.
Quick summary
| Field | Value |
|---|---|
| Published | November 18, 2026, Ruby Security; CVE on November 19 |
| Main ID | GHSA-34m4-m9fh-gqp5 / CVE-2026-132825 |
| Class | CWE-193 off-by-one; CVE record lists CWE-122 heap buffer overflow |
| Bug | One-byte heap overflow |
| Trigger | Case conversion in legacy single-byte encodings |
| Affected | Ruby 3.3.13 and earlier, 3.4.0–3.4.12, 4.0.0–4.0.9 |
| Fixed | Ruby 3.3.14, 3.4.13, 4.0.10 |
| Status | Ruby is aware of PoCs; no public PoC; no KEV or reported exploitation |
1. The bug: code writes two bytes, checks room for one
The main issue, GHSA-34m4-m9fh-gqp5, sits in string case conversion. In single-byte encodings such as ISO-8859 and Windows-125x, upcasing ß produces SS: one input byte becomes two output bytes.
Before the fix, the case_map() loop only checked that one output byte was free:
- while (*pp < end && to < to_end) {
+ while (*pp < end && to_end - to > 1) {
According to Veria Labs, the output buffer is allocated as input length plus 20 bytes. Each ß adds one extra byte, so 21 ß characters overflow the buffer by one byte. The written byte is S (0x53) during upcasing or s (0x73) during case folding. The subsequent copy step then reads one byte out of bounds as well.
The fix updates the same loop in 14 encoding files: ISO-8859-1/2/3/4/9/10/13/14/15/16 and Windows-1250/1252/1254/1257. It also adds tests for 1–64 ß characters through upcase, downcase(:fold), swapcase, capitalize, and casecmp?.
UTF-8 follows a different code path and is not affected. The risk is limited to places where legacy-encoded input reaches case conversion.
2. Why web apps should care
Ruby’s advisory says PoCs can lead to RCE “in some scenarios.” Veria Labs lists the default exposure as follows:
| Framework | Veria Labs assessment |
|---|---|
| Rails | Exposed by default on an affected Ruby |
| Sinatra, classic style | Exposed by default on an affected Ruby |
| Other frameworks and plain Rack | Not exposed by default |
| Application code | Exposed if it case-converts legacy-encoded strings |
“Unauthenticated” matters here. If case conversion runs before an authentication check, the attacker does not need a session. That is not a universal property of every Rails app: the deciding factor is which input is converted, under which encoding, and where in the request path.
The dangerous pattern is external input pinned to a legacy encoding with force_encoding, then passed to upcase, downcase(:fold), swapcase, capitalize, or casecmp?. Headers, form fields, filenames, imported data, and legacy protocol messages are the first places to look.
3. The other six advisories
Ruby shipped seven fixes in the same release set:
| GHSA | Short description |
|---|---|
GHSA-34m4-m9fh-gqp5 |
One-byte heap overflow in case conversion — CVE-2026-132825 |
GHSA-7x2q-68qv-6p8x |
Double free in Regexp compilation |
GHSA-87fm-7w84-j2px |
Integer overflow in case conversion leading to heap overflow |
GHSA-wpqw-5qxg-m68r |
Out-of-bounds read in case-insensitive Regexp matching |
GHSA-3p8q-wmhx-vm2w |
Heap overflow in Regexp compilation |
GHSA-7whj-cfh7-xgm4 |
Heap overflow in Regexp#to_s; information disclosure or RCE |
GHSA-pvgc-g7gj-pv6h |
Out-of-bounds read in case-insensitive backreference matching |
“Ruby2Shell” names one bug, but the patch set closes seven. Applications that compile attacker-controlled regexes should pay extra attention to 7x2q, 3p8q, and 7whj.
4. Self-hosted software
As of November 19, 2026, Veria Labs lists these current product versions as bundling an affected Ruby:
| Software | Bundled Ruby | Status |
|---|---|---|
| GitLab 19.6.0 | 3.3.13 | Affected |
| GitHub Enterprise Server 3.22.5 | 4.0.9 | Affected |
| Mastodon 4.7.5 | 4.0.9 | Affected |
| OpenProject 17.9.7 | 4.0.9 | Affected |
| Discourse 2026.10.1 | 3.4.7 | Affected |
| Chatwoot 4.20.0 | 3.4.4 | Affected |
This does not mean the product itself contains the bug; the affected runtime is bundled inside it. Updating the system Ruby may therefore not help when a product ships its own runtime. In that case, wait for the vendor’s patched release or rebuild the deployment against a fixed Ruby.
5. What to do
-
Check the runtime version.
ruby -v -
Upgrade Ruby to 3.3.14, 3.4.13, or 4.0.10. Ruby 3.3 is in security maintenance; 3.2 and earlier are EOL and will not receive these fixes.
-
Track vendor releases for self-hosted software. Updating only the host
rubybinary is not enough when a product bundles its own runtime. -
Restart processes and rebuild containers. The old runtime stays in memory until restarted; the filesystem may be patched while the running process is not.
-
Control encoding at the trust boundary. Where possible, validate user input as UTF-8 or reject legacy-encoded input before case conversion. This reduces exposure; it is not a substitute for the patch.
-
Patch before a public PoC lands. Veria Labs says a PoC will follow in a week. There is no public exploit as of November 19, which is a window to patch, not a reason to wait.
6. Scoring and status notes
The Ruby advisory says CVE IDs had not been assigned when it was published. The GHSA page still says “No known CVE,” but MITRE has now published CVE-2026-132825. Likewise, GHSA marks the bug Critical, while the MITRE CVSS 3.1 record is 7.4 HIGH with AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H. That gap comes from scoring the local primitive separately from the ways a web application may reach it.
As of November 19, 2026, there is no CISA KEV entry or report of exploitation in the wild. Ruby explicitly says it is aware of PoCs, so “no public exploit” does not mean “no urgency.”