Ruby Releases Fixes for 7 Regex and String Flaws, Warns 5 Have Proof-of-Concept RCE
Ruby contains seven memory-safety flaws in its regular expression engine and its string case-conversion code. For five of them, its maintainers say, proof-of-concept exploits, or PoCs, have shown that crafted input can run code on the machine.
"We are aware of PoCs that prove some of them can be used to trigger remote code execution," the maintainers said. The project released fixed versions yesterday: Ruby 4.0.10, 3.4.13 and 3.3.14.
Whether an application is at risk depends on whether an attacker can get crafted patterns or strings into the affected code, and the advisories report no attacks so far. The other two flaws are weaker. The maintainers say one has proof-of-concept code that corrupts memory under an attacker's control but has not been shown to run code, and the other can only read memory it should not or crash the program.
The project set the seven out in a security announcement and a separate advisory for each. The advisories rate three flaws critical, three high, and one moderate, and say which carry the remote-code-execution PoCs.
Flaws by Severity
In order of severity:
- Critical.
GHSA-34m4-m9fh-gqp5, a one-byte heap overflow when Ruby changes the case of a string in certain single-byte encodings, such asISO-8859-1orWindows-1252. It has a remote-code-execution PoC. (GitHub advisory) - Critical.
GHSA-7x2q-68qv-6p8x, a double free when Ruby compiles a crafted regular expression that uses a character-class intersection (&&). It has a remote-code-execution PoC. (GitHub advisory) - Critical.
GHSA-3p8q-wmhx-vm2w, a heap overflow when the size of a compiled regular expression overflows during compilation. It has a remote-code-execution PoC. (GitHub advisory) - High.
GHSA-87fm-7w84-j2px, a heap overflow when a case change produces a result larger than 4 GiB. It has a remote-code-execution PoC, though the size needed puts it out of reach for most requests. (GitHub advisory) - High.
GHSA-7whj-cfh7-xgm4, a heap overflow when Ruby turns a crafted compiled regular expression back into text withRegexp#to_s. It has a remote-code-execution PoC. (GitHub advisory) - High.
GHSA-wpqw-5qxg-m68r, an out-of-bounds read during case-insensitive matching. Its PoC shows attacker-controlled memory corruption, and the maintainers say remote code execution is possible but not shown. (GitHub advisory) - Moderate.
GHSA-pvgc-g7gj-pv6h, an out-of-bounds read when Ruby matches a case-insensitive backreference against a crafted subject string. The advisory says it "may disclose memory contents or crash the process." (GitHub advisory)
The project credits Stephan Lipp of Ada Logics and Anthropic with four of the findings, and baba__yaga, aphantom, Hiroya Fujinami and Hiroshi SHIBATA with the other three.
Which Applications Are Exposed
The flaws are in Ruby's own code, so every application on an affected version carries them. Whether an attacker can reach one depends on how the application handles external input.
The regex flaws need an application that builds a regular expression from input an attacker controls and then compiles or runs it. Matching untrusted text against a pattern the developers wrote themselves does not pose the same risk, except in one case below.
The two case-conversion flaws do not involve regular expressions at all. They fire when the application changes the case of a crafted string, so code that runs case conversion over imported or outside text is worth checking.
The one case is the moderate read flaw, which fires when the application matches a crafted subject string against a fixed pattern that uses a case-insensitive backreference. The announcement and advisories do not include the proof-of-concept code.
Fixed Versions and Affected Ranges
The fixes are in Ruby 4.0.10, 3.4.13 and 3.3.14. The affected ranges are:
- Ruby 4.0.0 through 4.0.9, fixed in 4.0.10.
- Ruby 3.4.0 through 3.4.12, fixed in 3.4.13.
- Ruby 3.3.13 and earlier, fixed in 3.3.14.
- Ruby 3.2 and earlier, end of life and not fixed.
Those older versions will not get a fix, and the project recommends moving to a supported line. With 3.3.14, the maintainers renamed the Ruby 3.3 phase from security maintenance to legacy maintenance, and support still ends at the end of March 2027.
Because the fixes ship inside Ruby, updating an application's gems or framework does not replace a vulnerable interpreter. The version that matters is the Ruby running on application servers, background workers, and container images, which must be updated and then restarted or rebuilt.
The seven do not have CVE numbers yet. The project says it has requested them, and until they are assigned, the GitHub advisory IDs are the only way to track flaws in scanners and software inventories.
It is the second time in a month that the project has patched its regular expression engine. In the October fixes, released on October 23, it shipped Ruby 4.0.9, 3.4.12, and 3.3.13 to patch compilation bugs GitLab found, which sat behind four critical GitLab flaws. One of those GitLab flaws drew an attempted attack on Alpine Linux's own GitLab server. CISA later added it to the KEV catalog, its list of Known Exploited Vulnerabilities, as actively exploited.
Those are different bugs from this week's seven, and the new advisories do not say that GitLab or any other named product can be attacked through them. What the October case showed is that a regular expression built from user input can become a real way onto a server, not just a theoretical one.
Comments
No comments yet. Start the discussion.