Ruby2ßhell: Pre-authentication RCE on stock Rails verialabs.com · 26 points · 2 ...
HN Best 200 @best
Ruby2ßhell: Pre-authentication RCE on stock Rails verialabs.com · 26 points · 2 comments · HN thread
TL;DR Verialabs describes Ruby2ßhell, a one-byte heap overflow in Ruby's string case conversion for single-byte encodings (ISO-8859 and Windows-125x), which they say can lead to pre-authentication remote code execution on stock Rails and Sinatra. Fixed releases are 3.3.14, 3.4.13 and 4.0.10; a proof of concept is promised in a week.
- Upcasing a capital-less ß in affected single-byte encodings writes two bytes (SS) but the loop bounds-checks only one, causing a heap overflow.
- The output buffer is allocated as input length plus 20 bytes, so 21 ß characters overflow it by one byte.
- Affected functions include upcase, swapcase, downcase(:fold) and casecmp?; UTF-8 strings take a different path and are not affected.
- The bug dates to Ruby 2.4.0; affected series are 4.0.0 to 4.0.9, 3.4.0 to 3.4.12 and 3.3.0 to 3.3.13.
- Rails and classic-style Sinatra are exposed by default; GitLab, Mastodon, Discourse and others bundle affected Rubies.
- Fix is upstream in ruby/ruby@d582f8f; the advisory is GHSA-34m4-m9fh-gqp5, CVE pending, and the PoC has not yet been published.
Discussion The thread has no comments yet, so there is no discussion to summarize at the time of this digest.