Ruby2ßhell: Pre-authentication RCE on stock Rails verialabs.com · 299 points · 1...

@best30

Ruby2ßhell: Pre-authentication RCE on stock Rails verialabs.com · 299 points · 123 comments · HN thread

TL;DR Verialabs discloses Ruby2ßhell, a one-byte heap overflow in Ruby's case conversion for single-byte encodings (ISO-8859 and Windows-125x), reachable without authentication in default Rails and Sinatra (classic) setups. The bug comes from the German sharp s ß expanding to SS during upcase, swapcase, downcase(:fold) and casecmp?, and has existed since Ruby 2.4.0. Fixed releases are 3.3.14, 3.4.13 and 4.0.10; the authors promise a proof of concept in a week.

  • Root cause: the upcase loop bounds-checks one output byte per character, but ß expands to SS, so an input with 21 ß characters overflows the output buffer (allocated as input length plus 20) by one byte.
  • The overflow writes a fixed byte (S when upcasing, s when case-folding) directly after the buffer; copying the result then reads one byte out of bounds.
  • Affected paths are upcase, swapcase, downcase(:fold) and casecmp?; UTF-8 strings take a different code path and are not affected.
  • Affected Ruby: 4.0.0-4.0.9, 3.4.0-3.4.12, 3.3.0-3.3.13; 3.2 and older are EOL and affected back to 2.4.0. Fixes are in 3.3.14, 3.4.13 and 4.0.10.
  • Rails and classic-style Sinatra are exposed by default; GitLab 19.6.0 (bundled Ruby 3.3.13) and GitHub Enterprise Server 3.22.5 (Ruby 4.0.9) are listed as affected, while Mastodon, OpenProject and Discourse ship fixed Rubies.
  • Advisory GHSA-34m4-m9fh-gqp5, CVE pending; the proof of concept is withheld until people have had time to upgrade.

Discussion The thread mixes three conversations: whether AI tooling is making single-byte bugs into practical RCEs and what that means for memory safety (including a long, heated side argument about Java versus Rust), the technical question of how a one-byte overflow could be turned into code execution, and the German-language quirk of the sharp s. Commenters are mostly technical and fairly measured, though the Java/Rust subthread gets sharp. There is also criticism of the authors for withholding the PoC, and a few jokes about the name and a 'Shell' pun.

  • Memory safety is the real fix; AI makes bug hunting cheap (many): Several commenters see a wave of RCE reports built on small memory bugs found with AI assistance, arguing that if one byte can be weaponized, whole software stacks need to be memory safe. Others note that fuzzers and sanitizers already catch this class of bug and the real problem is adoption.
  • Single byte is enough with heap grooming (some): Commenters explain that a fixed one-byte write can corrupt allocator metadata or the size of a neighbouring allocation, and that heap grooming can place victim structures where the write lands. Comparisons are made to the 2014 Project Zero poisoned NUL byte and to Phrack 55, though one commenter notes the Phrack technique does not apply to heap buffers.
  • Java versus Rust memory safety debate (some): A long subthread argues whether Java and Rust are meaningfully memory safe given unsafe code, JVM internals and recent vulnerabilities in both. Participants disagree about how much unsafe code each uses, with no clear resolution.
  • Skeptical that the PoC should be withheld (some): Some argue that with AI agents an exploit can be produced quickly anyway, so withholding the proof of concept offers little protection. Others reply that publishing before patches reach self-hosted products would be irresponsible; one commenter reported an AI-generated crash PoC, not an RCE.
  • Bug is a legacy assumption about case-length, not a language problem (a few): Commenters point out that case conversion never preserved byte length outside ASCII, and that the original author did attempt a 20-byte margin that was too small. The fix is seen as a simple bounds-check error in the C code.
  • Sharp s and ẞ debate (a few): A side thread argues whether ß has a capital form. One commenter says ẞ is the officially preferred capital since 2024 and that ß maps to SS; another rejects this as wrong for German usage. The debate is largely off-topic.

Links from the comments

#Ruby #RemoteCodeExecution #HeapOverflow #MemorySafety #Rails #Vulnerability