Ruby ruby2shell flaw prompts urgent patching and WAF checks

src-9268917b

A critical heap buffer overflow in Ruby’s string case-conversion code can provide a path to remote code execution, including before authentication in default configurations of Ruby on Rails and classic-style Sinatra. Disclosed by the Ruby team on November 19, 2026, ruby2shell is tracked as CVE-2026-132825. The team says it is aware of proofs of concept capable of achieving code execution in some scenarios.

Ruby fixed the flaw in versions 3.3.14, 3.4.13 and 4.0.10. Those releases also address six other memory-safety issues, including a related integer overflow identified as GHSA-87fm-7w84-j2px. Administrators should treat web application firewall rules as an interim layer, not a substitute for upgrading affected Ruby runtimes.

How string case conversion can overflow

Ruby strings carry an encoding, and the language supports legacy single-byte encodings as well as UTF-8. In a single-byte encoding, case conversion generally produces output of the same length. The German sharp s character, ß, is an exception: its uppercase form is “SS.” In 14 ISO-8859 and Windows-125x encodings, the vulnerable code writes two bytes for that conversion but checks space for only one.

Veria Labs reports that a string containing 21 sharp s characters can overflow the output buffer by one byte. The affected methods are upcase, swapcase, downcase(:fold) and casecmp?. UTF-8 strings use a different code path and are not affected by this flaw.

A one-byte overwrite can still corrupt adjacent heap data or allocator metadata, potentially enabling further exploitation. Ruby’s statement that it knows of proofs of concept underscores the risk, although the source material does not establish that the vulnerability is being exploited in the wild.

Default framework behavior creates exposure

The issue can be reached in default configurations of Rails and classic-style Sinatra through Rack’s MethodOverride middleware. Web forms commonly use a POST request with a _method parameter to represent methods such as PUT, PATCH or DELETE. Rack converts that parameter to uppercase while processing the request.

According to Veria Labs, an attacker can provide the parameter in a multipart request using a legacy character set, causing the vulnerable conversion during request routing—before application code or authentication checks. Other frameworks and plain Rack applications are not reported to be exposed by default, but any application code that case-converts attacker-controlled strings in a legacy encoding may still be at risk.

Affected Ruby versions include 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. Veria Labs says the bug has existed since Ruby 2.4.0. Ruby 3.2 and earlier are end-of-life and will not receive the fix, so organizations using those releases should move to a supported Ruby series.

Self-hosted software can include its own Ruby runtime. As of the disclosure date, Veria Labs listed 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 as shipping with an affected Ruby. Discourse moved its Docker base image to Ruby 4.0.10 on November 19; rebuilding a Docker installation picks up that fix. Distribution maintainers may backport patches without changing the upstream Ruby version number, so teams should check their distribution’s advisory and full package version.

WAF rules reduce exposure, but do not close every path

Cloudflare says it added blocking rules for CVE-2026-132825 and GHSA-87fm-7w84-j2px to both its Free Managed Ruleset and its Managed Ruleset. The rules are on by default. The Free Managed Ruleset runs automatically for Free-plan customers; paid-plan customers should confirm that the Managed Ruleset is deployed and that the relevant rules have not been overridden.

These protections apply when malicious requests pass through Cloudflare. They cannot cover traffic that bypasses the service, direct requests to an origin that accepts them, or internal service-to-service traffic. Nor can an HTTP WAF inspect every route into vulnerable code: strings may also arrive through email, file imports, message queues or background jobs. Restricting origin access to Cloudflare, including through Cloudflare Tunnel or Authenticated Origin Pulls, can help reduce bypass risk.

Prioritize upgrades and runtime inventory

  • Upgrade to Ruby 3.3.14, 3.4.13 or 4.0.10, then restart all Ruby processes, including background workers.
  • Rebuild container images and update self-hosted products as their vendors issue fixed releases. Move systems on Ruby 3.2 or earlier to a supported series.
  • Verify WAF ruleset deployment, but do not rely on perimeter filtering as the remediation.
  • Inventory bundled and standalone Ruby runtimes, including code paths that process attacker-controlled legacy-encoded strings.

The related GHSA integer overflow is in the same string case-conversion area. The other five memory-safety fixes in the Ruby releases affect the regular-expression engine; several can lead to code execution, and most require an application to compile or match a regular-expression pattern supplied by an attacker. Patching the Ruby runtime therefore addresses a broader set of risks than relying on a single WAF signature.