Ruby2Shell (GHSA-34m4-m9fh-gqp5)
Ruby2Shell vulnerability (GHSA-34m4-m9fh-gqp5) impacts popular software bundles. Certain frameworks, when configured with default settings, are exposed to this bug. Other frameworks may also be vulnerable if application code mishandles legacy encoding strings.
Ruby 3.3.14, 3.4.13 and 4.0.10 address the issue. Users should upgrade their Ruby version to a fixed release from these versions. Self-hosted software providers also offer fixed versions of popular products.
Most of Ruby's single-byte character encodings lack capital ß. When this character is upcased, it writes two bytes (SS) instead of one. The loop that bounds-checks the output buffer fails to account for this extra byte. If an input string contains 21 ß characters, it overflows the output buffer by one byte.
The vulnerable code exists in several ISO-8859 and Windows-125x encodings since Ruby 2.4.0. It is triggered by the upcase, swapcase, downcase(:fold) and casecmp? methods. These methods only affect non-UTF-8 strings.
A one-byte heap overflow occurs, writing either S (0x53) when upcasing or s (0x73) when case-folding directly after the output buffer. The attacker can control the buffer size through the input length. Copying the manipulated result from the buffer results in reading one byte out of bounds.
A proof of concept will be released in a week, giving users time to upgrade their Ruby versions.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.