Multiple vulnerabilities in Regexp and String case conversion ruby-lang.org · 31...
HN Best 30 @best30
Multiple vulnerabilities in Regexp and String case conversion ruby-lang.org · 314 points · 120 comments · HN thread
TL;DR Ruby's maintainers published an advisory for seven vulnerabilities in the regular expression engine and in string case conversion, several of which can lead to heap memory corruption and, per PoCs they are aware of, remote code execution. Fixed releases are Ruby 4.0.10, 3.4.13 and 3.3.14; affected are 3.3.13 and earlier, 3.4.0 to 3.4.12, and 4.0.0 to 4.0.9. CVE IDs were requested but not yet assigned, so GHSA identifiers are used.
- Four issues are heap buffer overflows or double frees in case conversion or regex compilation, and the advisory says PoCs exist that can trigger RCE in some scenarios.
- Other issues include an out-of-bounds read in case-insensitive regex matching, a heap overflow in Regexp#to_s, and an out-of-bounds read in case-insensitive backreference matching that may disclose memory or crash the process.
- Ruby 3.3 is in security maintenance; 3.2 and earlier are end of life and will not receive these fixes.
- Credits include Stephan Lipp (Ada Logics) and Anthropic for several reports, plus baba__yaga, aphantom, and Hiroya Fujinami with Hiroshi SHIBATA.
- Commenters highlighted a one-byte overflow in Windows-1252 upcasing where ß expands to SS, and a Shift_JIS downcase test case showing the length bug on an unfixed build.
Discussion The thread mixes close technical reading of the bugs with a broader argument about memory-safe languages. Several commenters dissected the Windows-1252 case-conversion overflow, where ß uppercases to SS and the length check misses the expansion, and a few posted a Shift_JIS reproduction. The discussion then widened into the German ß and Unicode uppercase conventions, C and Rust string handling, and whether AI-assisted bug finding will increase the rate of such reports. The mood is wry and combative, with frequent jokes about the vulnerability name and some frustration at the C-versus-Rust argument, and a practical undercurrent about how exposed Rails apps are to multi-gigabyte inputs.
- C memory unsafety is the root cause; move to safer languages (many): Several commenters argue these are classic C memory-corruption bugs and that AI tools will keep finding such flaws in memory-unsafe code. Others reply that the problem is decades old and Ruby alternatives like JRuby or TruffleRuby already exist.
- Unicode case-conversion rules are the real trap (many): Commenters explain that ß uppercasing to SS, and expansions like U+0130 and U+FB03, make length assumptions unsafe. Some note that Unicode's stability policy makes changing the default hard, though locale-specific tailoring is possible.
- Legacy encodings like Windows-1252 should be dropped (some): Some say there is no good reason for a Rails app to accept Windows-1252 input and that UTF-8 should be enforced at the boundary. Others counter that CSV exports from Excel in France and old ID3 tags still use these encodings, so conversion at ingestion is needed.
- Regex-heavy code is hard to replace (a few): A minority suggests replacing regexes with plain code or generated parsers such as re2c. Others reply that regex complexity and gems outside a team's control make that impractical in the short term.
- Dissent: the bugs are not a language indictment (some): Some push back on blaming C or the language in general, saying that bounds-checking abstractions and careful code avoid these bugs and that any language's standard library can hide similar issues.
Links from the comments
- The GitHub advisory for the heap overflow in case conversion, linked by a commenter discussing AI-found bugs.
- Raymond Chen's post on Windows code pages and string operation difficulty, shared in the Windows-1252 discussion.
- A regex-to-code generator suggested as a way to replace regular expressions with embedded code.
- A Java base64 decode vulnerability linked as a comparison for memory bugs in other ecosystems.