Ruby Patches 7 Flaws in Regex & String Case Handling—5 Enable RCE

Ruby developers have released urgent patches to address seven memory safety vulnerabilities impacting the regular expression engine and string case-conversion routines. Five of these flaws come with proof-of-concept (PoC) examples that demonstrate the potential for remote code execution (RCE) under certain circumstances.

The fixes are included in Ruby versions 4.0.10, 3.4.13, and 3.3.14. Whether an app is vulnerable depends on whether it accepts crafted input that influences regex compilation, matching, or case conversion. As of now, no active exploitation has been reported.

The Flaws at a Glance

The advisories categorize the seven issues based on severity: three are rated critical, three high, and one moderate. Below are the key vulnerabilities:

  • Critical. A one-byte heap overflow triggers when converting string case under single-byte encodings like ISO-8859-1 or Windows-1252. This issue has a PoC enabling RCE.
  • Critical. Double free vulnerability during compilation of a crafted regular expression using character-class intersection (`&&`)—also exploitable for RCE.
  • Critical. Heap overflow triggered when the size of a compiled regex overflows during the compilation phase; RCE possible as shown by PoC.
  • High. Heap overflow arises when converting string case resulting in output larger than 4 GiB—RCE possible, though impractical for many real-world use cases.
  • High. Overflow occurs when converting a compiled regular expression back into text via `Regexp#to_s`—this too has a remote code execution PoC.
  • High. Out-of-bounds read during case-insensitive matching. PoC shows memory corruption usable by adversaries; RCE is believed possible though unproven.
  • Moderate. Out-of-bounds read when matching a case-insensitive backreference against malicious subject strings; this issue mainly risks memory disclosure or crashes.

Who’s Affected—and What to Do

All applications running vulnerable Ruby interpreters are potentially exposed. The key risk surfaces:

  • If attacker input influences regex compilation or pattern generation.
  • If untrusted strings undergo case conversion.
  • Even regular expression functions like `Regexp#to_s` when handling regex objects derived from unsafe inputs.

The affected version ranges are:

  • Ruby 4.0.0 through 4.0.9 — patched in 4.0.10.
  • Ruby 3.4.0 through 3.4.12 — patched in 3.4.13.
  • Ruby 3.3.13 and earlier — patched in 3.3.14.
  • Ruby 3.2 and earlier are no longer supported and won’t receive any fixes.

Updating the Ruby interpreter itself is essential. Simply upgrading frameworks or gems won’t help if the underlying interpreter remains vulnerable. After updating, developers must restart servers, background workers, and rebuild container images to ensure the patched interpreter is active.

At present, none of the flaws have been assigned CVE identifiers; tracking must rely on the unique GitHub advisory IDs until official CVEs are issued. Findings were contributed by researchers at Ada Logics, Anthropic, and other independent contributors.

Just last month, Ruby patched several regex-related bugs that had been exploited in other contexts. Those earlier fixes serve as a reminder that regular expression engines are a recurring attack vector when untrusted input reaches compilation layers.

Analysis: These vulnerabilities highlight how operations that seem safe—regex construction and case conversion—can open doors to severe risks like remote code execution when not carefully managed. For engineers using Ruby, it’s a chance to audit code paths that perform regex compilation or transform string case using external data. As these are deep interpreter flaws, even middleware and libraries can’t alleviate the danger without upgrading Ruby itself. Watch for the issuance of CVE numbers and ensure your deployment pipelines enforce Ruby version checks to avoid these kinds of embedded interpreter shadows.