CloudflareDenzil CorreaProblem & solution
How Cloudflare WAF protects against ruby2shell (CVE-2026-132825)
Summary
Ruby2shell (CVE-2026-132825) is a critical heap buffer overflow in Ruby’s string case conversion when handling legacy single-byte encodings such as ISO-8859-1. The overflow occurs when upcasing the German sharp s (ß), which expands to two characters but Ruby allocates space for only one; Veria Labs reports that 21 sharp s characters overflow the buffer by one byte. The bug is reachable in default Rails and classic Sinatra applications before authentication because Rack’s MethodOverride middleware upcases the _method parameter from a POST request. Cloudflare WAF blocks ruby2shell for all customers, including Free plans, with two new managed rules covering the overflow and a related integer overflow (GHSA-87fm-7w84-j2px) in the same code. The WAF is a compensating control; the only complete fix is upgrading Ruby to 3.3.14, 3.4.13, or 4.0.10, and Cloudflare recommends using WAF attack score for defense in depth; the same releases also fix six other memory safety flaws.
Context
Ruby2shell (CVE-2026-132825) is a critical heap buffer overflow in Ruby’s string case conversion when handling legacy single-byte encodings such as ISO-8859-1. The bug is reachable in default Rails and classic Sinatra applications before authentication because Rack’s MethodOverride middleware upcases the _method parameter from a POST request. Cloudflare WAF provides immediate protection with managed rules while users patch Ruby.
Approach / What changed
Cloudflare added two managed rules to the Cloudflare Free Managed Ruleset and Cloudflare Managed Ruleset with Block as the default action, covering the heap overflow (CVE-2026-132825) and a related integer overflow (GHSA-87fm-7w84-j2px). They also recommend using WAF attack score (cf.waf.score.rce) for defense in depth against post-exploitation payloads.
Takeaways
Ruby2shell is a heap buffer overflow in Ruby’s string case conversion when using legacy single-byte encodings, triggered by upcasing the German sharp s (ß) which expands to two bytes but allocates one.
Default Rails and classic Sinatra applications are exposed pre-authentication because Rack’s MethodOverride middleware upcases the _method parameter from POST requests.
Cloudflare WAF blocks ruby2shell for all customers with managed rules, but patching Ruby to 3.3.14, 3.4.13, or 4.0.10 is the only complete fix.
FAQ
How does ruby2shell work?
Ruby2shell is a heap buffer overflow in Ruby's string case conversion when handling legacy single-byte encodings. Upcasing the German sharp s (ß) writes two bytes but allocates space for only one; a string with 21 sharp s characters overflows the buffer by one byte, which can be exploited for code execution.
Which applications are affected by default?
Default Rails and classic Sinatra applications are exposed because Rack's MethodOverride middleware upcases the _method parameter from a POST request before authentication. An attacker can send a multipart POST with a legacy character set and sharp s characters to trigger the overflow.
How does Cloudflare WAF protect against ruby2shell?
Cloudflare added two managed rules to the Cloudflare Free Managed Ruleset and Cloudflare Managed Ruleset with Block as the default action, covering the heap overflow and a related integer overflow. The rules are active for all customers, including Free plans, and block exploit attempts in HTTP requests.
Source and freshness
- Source
- blog.cloudflare.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.