Ruby2Shell – String Case Conversion Heap Buffer Overflow

Ruby2Shell is a critical heap buffer overflow in how the Ruby interpreter converts the case of strings in certain single-byte encodings. It may allow remote code execution. The fix is to upgrade Ruby to 4.0.10, 3.4.13 or 3.3.14.

Vulnerability

Ruby2Shell is a one-byte heap buffer overflow in the way Ruby converts the case of strings held in certain single-byte encodings.

It affects the Ruby interpreter itself, so any application running a vulnerable Ruby version is potentially exposed. That includes Ruby on Rails applications, classic-style Sinatra applications and products that bundle Ruby, such as GitLab.

Several single-byte encodings, including ISO-8859-1 and Windows-1252, have no capital form of the German letter ß. Converting it to uppercase produces two characters (“SS”) from one input byte. But the conversion loop only checks that there’s room for one more byte in the output buffer.

A crafted string containing enough ß characters therefore writes one byte past the end of the heap buffer. The byte written is “S” when uppercasing and “s” when case folding. An attacker influences the buffer size through the length of the input.

The flaw is reached through the upcase, swapcase, downcase(:fold) and casecmp? string methods. UTF-8 strings use a different code path and aren’t affected.

CVE and severity

The Ruby project rates the flaw critical and states that changing the case of a crafted string may allow remote code execution.

As of November 19, 2026, no CVE identifier had been assigned and no CVSS score had been published.

Impact

The Ruby project states that the overflow can lead to remote code execution in some scenarios.

Exploitation requires an attacker to get a string in an affected encoding into one of the vulnerable methods. In Rails and classic Sinatra deployments, this is reported to be possible over the network without authentication or user interaction. That’s why the issue is rated critical.

The exact conditions for reliable code execution haven’t been published. The impact on any given application depends on how it handles legacy-encoded input and on the memory layout of the process. It also depends on any other controls in place ahead of the vulnerable application.

Exploit status

The Ruby maintainers state that proof-of-concept exploits exist showing remote code execution in some scenarios. These haven’t been made public. A public release has been announced for roughly one week after disclosure.

Because a public proof of concept is expected shortly, treat patching as urgent.

Affected component and versions

The flaw affects the Ruby interpreter in these branches:

  • Ruby 4.0: 4.0.0 to 4.0.9 affected, fixed in 4.0.10.
  • Ruby 3.4: 3.4.0 to 3.4.12 affected, fixed in 3.4.13.
  • Ruby 3.3: 3.3.13 and earlier affected, fixed in 3.3.14.
  • Ruby 3.2 and older: end of life, and no fix will be issued.

The Ruby project’s advisory lists 3.3.13 and earlier as affected. Public analysis indicates the flaw has existed since Ruby 2.4.0, so treat any Ruby 3.2 or older runtime in that range as vulnerable, and as unfixable without moving to a supported branch.

Rails applications and Sinatra applications using the classic style are reported to be exposed in their default configuration. Other frameworks and plain Rack applications aren’t reported as exposed by default. However, application code that changes the case of legacy-encoded strings can be vulnerable in any framework.

Self-hosted products that ship their own Ruby runtime are affected until their vendor ships a build using a fixed Ruby release. Check the bundled Ruby version of each product against its vendor’s release notes.

As of November 19, 2026, the latest releases of these self-hosted products bundle a Ruby version in the affected range:

  • GitLab 19.6.0, bundling Ruby 3.3.13.
  • GitHub Enterprise Server 3.22.5, bundling Ruby 4.0.9.
  • Mastodon 4.7.5, bundling Ruby 4.0.9.
  • OpenProject 17.9.7, bundling Ruby 4.0.9.
  • Discourse 2026.10.1, bundling Ruby 3.4.7.
  • Chatwoot 4.20.0, bundling Ruby 3.4.4.

Other software that bundles or depends on a vulnerable Ruby runtime may also be affected. Check asset inventories in full to identify any Ruby-based products in use.

Fix and mitigation

The only fix is to upgrade Ruby to a patched release: 4.0.10, 3.4.13 or 3.3.14. The Ruby project lists no workaround.

Until patching is complete, these temporary measures may reduce exposure, although none of them fix the vulnerability:

  • Restrict internet access to non-essential Ruby applications using a VPN, allowlist or trusted network ranges.
  • Take non-essential Ruby applications offline until they can be upgraded.
  • Increase monitoring of exposed Rails and Sinatra applications for crashes, unexpected process restarts and anomalous requests.
  • Review application code that changes the case of strings in ISO-8859 or Windows-125x encodings, to understand where custom code may be exposed.

Re-evaluate these controls, and remove or adjust them, once every affected runtime has been upgraded and restarted.

References