A heap overflow in Ruby's string case conversion can be triggered over the network without authentication, and fixed Ruby releases are now available. Researchers say a proof of concept will follow in a week.

The flaw sits in how Ruby upcases strings in several single-byte encodings, including some ISO-8859 and Windows-125x variants. Most of these encodings have no capital form of the German letter ß. When such a string is upcased, ß becomes two characters, SS, but the conversion loop only checks bounds for one byte. The output buffer is sized as the input length plus 20 bytes, so an input containing 21 ß characters overflows the buffer by a single byte. The problem has existed since Ruby 2.4.0 and is reached through upcase, swapcase, downcase(:fold) and casecmp?. UTF-8 strings follow a different code path and are not affected.
The researchers describe the result as a one-byte heap overflow. The written byte is S when upcasing or s when case-folding, and it lands directly after the buffer. Because the attacker influences the buffer size through the input length, the write can be shaped. Copying the result afterward also reads one byte out of bounds. The issue is rated critical and can be reached over the network without authentication in the default configuration of several common Ruby web frameworks. Other frameworks are not exposed by default, but application code that upcases strings received in a legacy encoding may also be vulnerable.
The fix is available in Ruby 3.3.14, 3.4.13 and 4.0.10. Deployments should upgrade Ruby to one of these releases. For self-hosted software that bundles an affected Ruby, administrators should install the vendor's fixed release. The advisory is tracked as GHSA-34m4-m9fh-gqp5, and a CVE identifier is pending. The researchers plan to publish a proof of concept in a week, giving users time to upgrade first.
Source: Veria Labs







