← Thu, Nov 19 digest

Ruby2ßhell: Pre-authentication RCE on stock Rails

read article ↗ hn thread ↗

A critical one-byte heap overflow in Ruby's string case conversion allows pre-authentication remote code execution (RCE) in Rails and Sinatra.

read it Detailed technical explanation of a critical RCE vulnerability affecting major frameworks and self-hosted software.

summary

Ruby2ßhell is a vulnerability caused by a bounds-checking error when upcasing the character 'ß' in legacy encodings (like ISO-8859 and Windows-125x), which expands to two bytes ('SS'). This one-byte heap overflow can be leveraged for RCE and is reachable without authentication in default Rails and Sinatra configurations. Affected versions include Ruby 3.3.0-3.3.13, 3.4.0-3.4.12, and 4.0.0-4.0.9, with older versions also vulnerable. Major self-hosted products like GitLab and GitHub Enterprise Server are affected, though some like Mastodon and OpenProject have already patched.

key points

  1. The vulnerability occurs when upcasing 'ß' in legacy encodings, where the output buffer is only checked for one byte instead of two.
  2. RCE is possible by grooming the heap to place victim structs where the one-byte overflow occurs.
  3. The bug is reachable in Rails via multipart/form-data POST requests by specifying a legacy charset in the Content-Type header.
  4. Fixed Ruby versions are 3.3.14, 3.4.13, and 4.0.10.

who should read it

Ruby developers, DevOps engineers, and security researchers managing Rails or Sinatra applications.

discussion positive

consensus

Commenters are concerned about a recent wave of RCEs in major languages (Java, PHP, Nginx, Ruby) and speculate that AI is helping researchers find and chain these vulnerabilities more quickly.

pushback

Some argue that the vulnerability is overhyped or that the lack of an immediate PoC makes it less critical, while others debate the relative memory safety of Rust vs Java.

best comment by tptacek ↗

The simplest core mechanism of these kinds of exploits is that you can groom the heap by triggering lots of similar-sized allocations, so you have a good guess as to what the heap will contain where your wild write occurs, and then you can trigger specific allocations to land juicy victim structs in the heap where you want them.

It's an evolution of the old "nop sled" idea from stack overflows (and viruses before that), where you don't know exactly what the stack addresses you're targeting are, but you can in your exploit trigger payload include data that will carpet bomb the stack with NOP …

Explains the technical mechanism of heap grooming used to turn a single-byte overflow into a full RCE.

Generated by an LLM from the article and thread. Check the sources before relying on it.