Ruby2Shell: Pre-Auth RCE on Stock Rails

November 19, 2026, 12:00 CET

Veria Labs disclosed a critical vulnerability in Ruby's string case conversion that reaches remote code execution on stock Rails and Sinatra deployments without authentication. The bug, tracked as GHSA-34m4-m9fh-gqp5, stems from a one-byte heap overflow in how Ruby handles the German sharp s (ess-zett) in legacy single-byte encodings.

The Bug

Most of Ruby's single-byte encodings have no capital form for the character. When upcase converts it, the result is two bytes (SS), but the internal loop only bounds-checks for one. The output buffer is allocated as input length plus 20 bytes, so a string containing 21 instances of the character overflows by exactly one byte [1].

The same flawed loop exists in several ISO-8859 and Windows-125x encodings and has been present since Ruby 2.4.0. It is reachable through upcase, swapcase, downcase(:fold), and casecmp?. UTF-8 strings take a different code path and are not affected [1].

What Is Exposed

Rails and classic-style Sinatra are affected in their default configuration. Other Rack-based frameworks are not exposed by default, but application code that upcases strings received in a legacy encoding may also be vulnerable [1].

Several widely deployed self-hosted products bundle affected Ruby versions:

Fix

Upgrade Ruby to 3.3.14, 3.4.13, or 4.0.10. The fix was committed upstream as ruby/ruby@d582f8f. For self-hosted software, install the vendor's fixed release once available [1].

Veria Labs says a proof of concept will be published in one week to allow time for upgrades [1].

[1] Veria Labs, Ruby2Shell (GHSA-34m4-m9fh-gqp5) ยท Ruby-lang security advisory