Summary
Ruby has an integer overflow in its regular expression engine, which causes a heap-based buffer overflow. Compiling a crafted regular expression pattern may allow remote code execution in applications that compile attacker-controlled patterns. We are aware of PoCs that prove this flaw can be used to trigger RCE in some scenarios.
A CVE ID has been requested and is pending.
Details
When compiling a regular expression, the size of the compiled program could overflow, and Ruby could write past the end of a heap buffer.
Impact
This is a heap-based buffer overflow that may allow remote code execution in applications that compile regular expressions from attacker-controlled strings. We are aware of PoCs that prove this flaw can be used to trigger RCE in some scenarios. Applications should upgrade.
Patches
Upgrade to Ruby 3.3.14, 3.4.13 or 4.0.10.
Credits
Thanks to aphantom (https://hackerone.com/aphantom) for reporting this issue.