TL;DR
- Ruby disclosed CVE-2026-132825, a critical heap buffer overflow in case conversion that enables remote code execution in Rails and Sinatra applications before authentication
- Affected versions are Ruby 3.3.13 and earlier, 3.4.0–3.4.12, and 4.0.0–4.0.9; fixes shipped in Ruby 3.3.14, 3.4.13, and 4.0.10
- Cloudflare WAF now blocks both ruby2shell and a related integer overflow (GHSA-87fm-7w84-j2px) for all customers by default
- Six self-hosted products bundled affected Ruby versions: GitLab 19.6.0, GitHub Enterprise 3.22.5, Mastodon 4.7.5, OpenProject 17.9.7, Discourse 2026.10.1, and Chatwoot 4.20.0
- Severity
- Critical
- CVE
- CVE-2026-132825
- Fixed versions
- Ruby 3.3.14, 3.4.13, 4.0.10
What Happened
On November 19, 2026, the Ruby team disclosed ruby2shell, a critical heap buffer overflow in Ruby's string case conversion logic. The flaw carries CVE-2026-132825 and an integer overflow variant (GHSA-87fm-7w84-j2px). The Ruby team confirmed it is aware of proofs of concept that achieve remote code execution in certain scenarios. Patches shipped in Ruby 3.3.14, 3.4.13, and 4.0.10. Additionally, six other memory safety flaws in Ruby's regular expression engine were fixed in the same releases.
The Technical Flaw
The vulnerability stems from how Ruby handles legacy single-byte character encodings like ISO-8859-1 and Windows-1252. Each character normally occupies one byte in these encodings, so converting case preserves string length. However, the German sharp s character (ß) breaks this assumption: its uppercase form is two characters, SS. When Ruby converts strings containing this character using methods like upcase, swapcase, downcase(:fold), or casecmp?, the code allocates space for one byte but writes two. A string with 21 sharp s characters overflows the output buffer by exactly one byte.
While a single-byte overflow may seem minor, it can corrupt adjacent heap objects or allocator metadata, enabling attackers to escalate the memory corruption into code execution. UTF-8 strings follow a different code path and are unaffected.
Why Rails and Sinatra Are Exposed by Default
HTML forms natively support only GET and POST requests. To simulate PUT, PATCH, or DELETE operations, many web frameworks accept a _method parameter that overrides the HTTP method. Rack, the middleware foundation for most Ruby frameworks, implements this via its MethodOverride middleware, which converts the _method value to uppercase. Rails includes this middleware automatically, and classic-style Sinatra applications enable it by default. An attacker can send a multipart POST request where the _method parameter declares a legacy character set and contains a sequence of sharp s characters. The framework upcases this value during routing, before any application code or authentication runs. Other frameworks and plain Rack applications are not exposed by default, though custom code that processes attacker-controlled strings in legacy encodings elsewhere could still be vulnerable.
Affected Systems and Products
Ruby versions 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9 are vulnerable. The flaw has existed since Ruby 2.4.0, but Ruby 3.2 and earlier have reached end of life and will not receive patches. Six widely deployed self-hosted products bundled vulnerable Ruby versions in their latest releases as of November 19: GitLab 19.6.0, GitHub Enterprise Server 3.22.5, Mastodon 4.7.5, OpenProject 17.9.7, Discourse 2026.10.1, and Chatwoot 4.20.0. Discourse updated its Docker base image to Ruby 4.0.10 on November 19, so rebuilding Docker installs automatically picks up the fix. Distribution packages may backport the fix without changing the Ruby version number, so administrators should check the full package version against vendor advisories.
Cloudflare WAF Protection and Limitations
Cloudflare WAF now blocks both ruby2shell and the related integer overflow for all customers. Two new rules are active by default in both the Cloudflare Free Managed Ruleset and the Cloudflare Managed Ruleset. On the Free plan, protection is automatic. On paid plans, the rules activate where the Cloudflare Managed Ruleset is deployed; administrators should verify its status in the dashboard.
However, the WAF is a temporary compensating control, not a replacement for patching. It cannot block exploit traffic that bypasses Cloudflare entirely—such as requests sent directly to origin IP addresses or traffic between internal services. Ruby code that processes strings from email, file imports, message queues, or background jobs can reach the vulnerable code without an HTTP request. The only complete fix is to upgrade Ruby. Cloudflare recommends combining WAF protection with machine learning-based detection: custom rules can block or challenge requests scoring high for remote code execution payloads using WAF attack score (cf.waf.score.rce <= 20 on Enterprise or cf.waf.score.class eq "attack" on Business plans).
Recommended Actions
Administrators should prioritize patching immediately. First, verify WAF coverage: Free plan users have automatic protection; paid plan users must confirm the Cloudflare Managed Ruleset is deployed and rules have not been overridden. Second, upgrade Ruby to 3.3.14, 3.4.13, or 4.0.10 on all systems and restart every Ruby process, including background workers. Rebuild container images and move applications running Ruby 3.2 or earlier to a supported branch. Third, update self-hosted products as vendors release patches and rebuild Discourse Docker installs immediately. Cloudflare has patched its own Ruby-dependent systems and found no evidence of compromise. The team will continue monitoring attack traffic and updating WAF rules as new exploitation techniques emerge.
Source
Cloudflare Bloghttps://blog.cloudflare.com/ruby2shell-waf-protection/AI-assisted, verified against the source. This post was drafted with AI from the primary source linked above and checked automatically against it. For anything you depend on, read the original.
- #ruby
- #cve-2026-132825
- #websecurity
- #rails
- #sinatra
