Security & privacy

Ruby heap overflow CVE-2026-132825 enables pre-auth RCE in Rails

A critical heap buffer overflow in Ruby string case conversion allows remote code execution in default Rails and Sinatra apps. Fixes are available in Ruby 3.3.14, 3.4.13, and 4.0.10.

Illustration of a security warning over documents with special characters and digital shields
Illustration generated for this article

On November 19, 2026, the Ruby team disclosed a critical vulnerability known as ruby2shell (CVE-2026-132825). This heap buffer overflow affects how Ruby handles string case conversion and is exploitable for remote code execution in specific scenarios. Patches have been released in Ruby versions 3.3.14, 3.4.13, and 4.0.10 to address the flaw.

What happened

The vulnerability stems from a miscalculation when Ruby converts strings to uppercase or lowercase in certain legacy single-byte encodings. While UTF-8 strings follow a safe code path, encodings like ISO-8859-1 and Windows-1252 trigger the bug. Specifically, the German sharp s character (ß) expands to two characters (SS) when uppercased, but the internal buffer allocation only accounts for one byte. This results in a one-byte heap buffer overflow.

Veria Labs reports that this flaw is reachable in default configurations of Ruby on Rails and classic-style Sinatra applications. The exposure occurs before any authentication checks because these frameworks use Rack middleware to handle HTTP method overrides. An attacker can send a multipart POST request with a _method parameter containing a sequence of sharp s characters in a legacy encoding. The framework upcases this value during routing, triggering the overflow. Self-hosted products bundling affected Ruby versions, including GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse, and Chatwoot, are also at risk.

Cloudflare has responded by adding blocking rules to its Web Application Firewall (WAF) for all customers, including those on the Free plan. These rules target both the heap overflow and a related integer overflow (GHSA-87fm-7w84-j2px) fixed in the same Ruby releases. Cloudflare emphasizes that while the WAF provides immediate protection against web-based exploits, it is a compensating control. The only complete remediation is upgrading the Ruby runtime.

How it works

Ruby strings carry an encoding label, and the language supports various legacy single-byte encodings alongside UTF-8. In single-byte encodings, each character occupies exactly one byte. Normally, changing the case of a string does not change its length. However, the sharp s character breaks this rule in 14 specific ISO-8859 and Windows-125x encodings. When Ruby processes upcase, swapcase, downcase(:fold), or casecmp? on a string containing this character, it writes two bytes for the uppercase SS but only allocates space for one.

A one-byte overflow might seem minor, but in heap memory management, it can corrupt adjacent objects or allocator metadata. Attackers can leverage this corruption to achieve remote code execution. Veria Labs notes that a string with 21 sharp s characters is sufficient to overflow the buffer by one byte. Since the exploit vector involves standard HTTP parameters processed by default middleware, no custom application code is required to trigger the vulnerability in affected frameworks.

Key details

  • Affected versions: Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. Ruby 3.2 and earlier are end-of-life and will not receive fixes.
  • Patched versions: Ruby 3.3.14, 3.4.13, and 4.0.10.
  • Vulnerable frameworks: Ruby on Rails and classic-style Sinatra in default configurations due to Rack MethodOverride middleware.
  • At-risk products: 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 bundle affected Ruby versions.
  • Exploit vector: Multipart POST requests with _method parameter containing legacy-encoded sharp s characters.
  • Additional flaws: The same Ruby releases fix six other memory safety issues, including an integer overflow in string case conversion and five regular expression engine vulnerabilities.

Why it matters

For software engineers and technical leads, this vulnerability represents a high-severity risk because it bypasses authentication. Default configurations of popular web frameworks expose the flaw immediately upon deployment. Since proofs of concept for remote code execution already exist, automated scanning and exploitation attempts are expected to surge. The wide reach of Ruby in self-hosted enterprise tools means that infrastructure teams must prioritize patching not just their custom applications, but also third-party services like GitLab and Mastodon.

The reliance on legacy encodings highlights a persistent challenge in modern web development. While UTF-8 is the standard, support for older encodings remains in many libraries for backward compatibility. This incident underscores the importance of inventorying runtime dependencies and understanding how middleware processes input data. Even if your application does not explicitly handle legacy encodings, underlying frameworks might, creating hidden attack surfaces.

What you can do

  • Upgrade Ruby immediately: Move to version 3.3.14, 3.4.13, or 4.0.10. Restart all Ruby processes, including background workers, and rebuild container images.
  • Update bundled software: Apply patches for self-hosted products like GitLab, GitHub Enterprise Server, and Mastodon as soon as vendors release them. Rebuild Discourse Docker installs to pick up the new base image.
  • Verify WAF protection: Ensure Cloudflare Managed Ruleset is active on paid plans. Free plan users are automatically protected by the Free Managed Ruleset.
  • Restrict origin access: Configure your origin server to accept traffic only from Cloudflare using Cloudflare Tunnel or Authenticated Origin Pulls to prevent direct bypass of the WAF.
  • Inventory runtimes: Use automated tools or AI agents to identify all Ruby instances in your infrastructure, including those in legacy or end-of-life versions.
  • Monitor for anomalies: Implement additional logging and monitoring for unusual process behavior or unexpected network connections that may indicate post-exploitation activity.
  • #ruby
  • #security
  • #vulnerability
  • #web-application-firewall
  • #rails

Tools from the Bytechap store

Keep reading

All stories