21 ß's, 1 byte: Ruby's upcase overflows its own buffer
21 characters of input. 1 byte past the end of the buffer. That is the entire vulnerability: Ruby's upcase has been overflowing a heap buffer since version 2.4.0 — eight years — and it took a single character, ß , to do it. Veria Labs disclosed it on November 18 as Ruby2Shell (GHSA-34m4-m9fh-gqp5), pre-authentication remote code execution on stock Rails.
The root cause is a bounds check that counts bytes in the wrong unit. Most of Ruby's single-byte encodings have no capital ß . Upcasing it produces two bytes, SS , but the conversion loop only bounds-checks for one. Here is the loop, quoted from the write-up:
while ( * pp < end && to < to_end ) { /* room for one byte */ code = * ( * pp ) ++ ; if ( code == SHARP_s ) { if ( flags & ONIGENC_CASE_UPCASE ) { * to ++ = 'S' ; /* first byte */ code = 'S' ; } /* ... */ } /* ...…