hn.today

Ruby2ßhell: Pre-authentication RCE on stock Rails

verialabs.com395 points176 comments
Screenshot of Ruby2ßhell: Pre-authentication RCE on stock Rails

Ruby2ßhell is a critical, unauthenticated remote-code-execution vulnerability caused by a one-byte heap overflow in Ruby’s handling of German sharp s (ß) during case conversion. In certain legacy single-byte encodings, converting ß to uppercase produces two characters, “SS,” but Ruby’s loop checks that there is room for only one byte before writing both. The output buffer is sized to the input length plus 20 bytes, so an input containing 21 sharp-s characters can trigger a one-byte write past its end. The overflow writes a predictable “S” or “s”; subsequent copying of the result can also read one byte beyond the buffer. The faulty code affects several ISO-8859 and Windows-125x encodings and has existed since Ruby 2.4. UTF-8 strings use a separate path and are not affected.

The vulnerable conversion routines include upcase, swapcase, downcase with folding, and casecmp?. On affected Ruby versions, Rails and classic-style Sinatra expose the flaw in their default configurations, making remote exploitation possible without authentication. Other frameworks and plain Rack are not exposed by default, though application code that uppercases attacker-controlled strings in a legacy encoding may still be at risk. The notice identifies affected releases in the Ruby 3.3, 3.4, and 4.0 series, as well as older, unsupported versions; fixes are available in Ruby 3.3.14, 3.4.13, and 4.0.10. It also lists several self-hosted products bundling vulnerable Ruby versions and recommends installing vendor-fixed releases. A proof of concept was scheduled for release after users had time to upgrade.

Read on verialabs.com176 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Security

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.