The Spectrum Dispatch News

technology

Ruby2ßhell: Critical pre-auth RCE flaw in Rails and Sinatra

A one-byte heap overflow in Ruby's string case conversion allows unauthenticated remote code execution on affected Rails and Sinatra deployments.

Ruby2ßhell: Critical pre-auth RCE flaw in Rails and Sinatra

A critical vulnerability tracked as ruby2ßhell (GHSA-34m4-m9fh-gqp5) affects multiple Ruby versions and has been identified in popular web frameworks and self-hosted software.

Ruby2ßhell: Critical pre-auth RCE flaw in Rails and Sinatra

According to Veria Labs, the vulnerability stems from a one-byte heap overflow in Ruby’s string case conversion logic. The bug occurs when Ruby’s upcase, swapcase, downcase(:fold), and casecmp? functions process the German character ß (capital sharp S) in single-byte encodings. When ß is upcased, it should produce two bytes (SS), but the bounds-checking loop only validates one byte, causing the output to overflow an allocated buffer.

The vulnerability is reachable without authentication in the default configuration of Ruby on Rails and Sinatra (classic style). Other frameworks and plain Rack applications are not exposed by default, though application code that upcases strings in legacy encodings may also be vulnerable. UTF-8 strings are unaffected due to a different code path.

According to the advisory, the output buffer is allocated with the input length plus 20 bytes. An attacker can craft an input with 21 ß characters to overflow the buffer by one byte. The overflow writes the byte S (0x53) or s (0x73) directly after the output buffer, with the attacker controlling buffer size through input length.

Ruby users should upgrade to fixed releases: 3.3.14, 3.4.13, or 4.0.10. Ruby 3.2 and older versions are end-of-life and will not receive patches. The vulnerability affects all versions from 2.4.0 through the specified ranges in each series.

Several popular applications bundling affected Ruby versions require updates, including GitLab 19.6.0 (Ruby 3.3.13) and GitHub Enterprise Server 3.22.5 (Ruby 4.0.9). Mastodon 4.7.6, OpenProject 17.9.8, and Discourse 2.0.20261119-0203 ship with fixed Ruby versions. Chatwoot 4.20.0 remains affected with Ruby 3.4.4.

Veria Labs stated it will publish a proof of concept after allowing time for upgrades.

Key facts

  • One-byte heap overflow in Ruby’s string case conversion affects Rails and Sinatra
  • Vulnerability is unauthenticated and network-accessible in default configurations
  • Fixed Ruby versions: 3.3.14, 3.4.13, 4.0.10
  • Affects Ruby 2.4.0 through 4.0.9 (depending on series)
  • GitLab 19.6.0 and GitHub Enterprise Server 3.22.5 are known affected deployments

Sources

← All posts