Ruby Heap Overflow Enables Pre-Auth Remote Code Execution
A critical heap overflow in Ruby’s string case conversion functions allows remote code execution without authentication in default configurations of common web frameworks. Versions before 3.3.14, 3.4.13, and 4.0.10 are affected. The vulnerability stems from improper bounds checking when converting certain characters to uppercase in single-byte encodings. When the character ß is converted to uppercase, it produces two bytes (SS), but the bounds check only accounts for one. Since the output buffer is allocated as input length plus 20 bytes, supplying 21 of these characters causes a one-byte overflow that lands directly after the buffer.
The flaw affects the upcase, swapcase, downcase with fold argument, and casecmp? methods across ISO-8859 and Windows-125x encoding paths, a problem present since Ruby 2.4.0. UTF-8 strings are unaffected due to different code paths. The overflow byte is either S (0x53) when upcasing or s (0x73) when case-folding.
Users should immediately upgrade Ruby to fixed versions. Administrators managing self-hosted software that bundles affected Ruby versions should install vendor-provided patches. A proof of concept will be published after a one-week period to allow time for patching.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.