HN
Today

Ruby2ßhell: Pre-authentication RCE on stock Rails

A newly disclosed pre-authentication Remote Code Execution (RCE) vulnerability, "Ruby2Shell," impacts widely used Ruby applications like Rails, GitLab, and Mastodon. It stems from a peculiar heap overflow tied to the ß character's upcasing in specific Ruby encodings, affecting versions 2.4.0 onwards. The vulnerability's technical depth, clever naming, and serious implications for countless deployments have captured the HN community's attention.

31
Score
6
Comments
#1
Highest Rank
13h
on Front Page
First Seen
Nov 19, 8:00 AM
Last Seen
Nov 19, 8:00 PM
Rank Over Time
211135771014121415

The Lowdown

The "Ruby2Shell" vulnerability (GHSA-34m4-m9fh-gqp5) reveals a critical pre-authentication Remote Code Execution (RCE) flaw impacting various Ruby versions and popular frameworks like Rails, as well as self-hosted applications such as GitLab, GitHub Enterprise Server, and Mastodon. This security loophole highlights the often-overlooked complexities of character encoding and its potential for severe exploits.

  • Vulnerability Type: Pre-authentication Remote Code Execution (RCE).
  • Root Cause: A one-byte heap overflow occurs during string upcasing, specifically when the German ß (Eszett) character is converted to SS in certain single-byte legacy encodings (like ISO-8859 and Windows-125x). The upcasing loop fails to properly bounds-check the output buffer, which is sized based on input length plus 20 bytes.
  • Affected Versions: All Ruby versions from 2.4.0 up to patched releases (e.g., 3.3.14, 3.4.13, 4.0.10).
  • Affected Frameworks/Software: Rails and Sinatra (classic style) are affected in their default configurations. Popular self-hosted software bundling affected Ruby versions includes GitLab (19.6.0), GitHub Enterprise Server (3.22.5), Mastodon (4.0.9), OpenProject (17.9.7), Discourse (3.4.7), and Chatwoot (4.20.0). UTF-8 strings are not affected.
  • Primitive: The overflow writes a single byte (S or s) immediately after the allocated buffer, controlled by the attacker. Copying the result then reads one byte out of bounds.
  • Fix: Immediate upgrade to fixed Ruby versions (3.3.14, 3.4.13, 4.0.10) or vendor-provided patched releases for self-hosted software.
  • Proof of Concept (PoC): A PoC is promised to be released in one week, allowing time for upgrades.

This vulnerability underscores the pervasive nature of low-level programming errors, even in mature languages, and the critical importance of timely patching, especially for infrastructure components dealing with diverse character inputs.

The Gossip

Vulnerability Vexation

Users discuss whether "Ruby2Shell" is a completely new vulnerability or if it's part of a broader set of Ruby advisories being discussed concurrently on Hacker News. It is clarified that it is one of several vulnerabilities, but its distinct nature and impact warrant its own detailed disclosure.

Naming Novelty

The Hacker News community expresses appreciation for the clever and descriptive name "Ruby2Shell." Some suggest alternative names like "Scheiße2Shell" and share insights into how the chosen name directly reflects the vulnerability's mechanism, hinting at previous community discussions about naming.

Encoding Error Elucidation

Commenters delve into the technical origins of the bug, hypothesizing that it likely stemmed from an assumption during development that case conversion wouldn't alter string length, particularly before the `ß` (Eszett) character's conversion to `SS` was properly handled and tested. This highlights the subtle complexities of character encoding.