What happened
The Ruby project announced on November 18 that it fixed seven memory-safety flaws in its regular expression engine and its string case-conversion code. The maintainers say: "We are aware of PoCs that prove some of them can be used to trigger remote code execution." The advisories report no attacks so far.
CVE IDs have not been assigned yet. The project has requested them, so the GitHub advisory IDs are the tracking identifiers for now.
The seven flaws
| Severity | Advisory | Issue |
|---|---|---|
| Critical | GHSA-34m4-m9fh-gqp5 | One-byte heap overflow when changing the case of a string in certain single-byte encodings (such as ISO-8859-1 and Windows-1252). RCE PoC exists. |
| Critical | GHSA-7x2q-68qv-6p8x | Double free when compiling a regex that uses character-class intersection (&&). RCE PoC exists. |
| Critical | GHSA-3p8q-wmhx-vm2w | Heap overflow when the size of a compiled regex overflows during compilation. RCE PoC exists. |
| High | GHSA-87fm-7w84-j2px | Heap overflow when a case change produces a result larger than 4 GiB. A PoC exists, but the size needed makes it impractical for most requests. |
| High | GHSA-7whj-cfh7-xgm4 | Heap overflow when Regexp#to_s converts a crafted compiled regex back to text. RCE PoC exists. |
| High | GHSA-wpqw-5qxg-m68r | Out-of-bounds read in case-insensitive matching. The PoC shows attacker-controlled memory corruption; RCE is considered possible but not shown. |
| Moderate | GHSA-pvgc-g7gj-pv6h | Out-of-bounds read matching a case-insensitive backreference against a crafted subject string. May leak memory or crash the process. No PoC published. |
Affected and fixed versions
| Ruby line | Affected | Fixed in |
|---|---|---|
| 4.0 | 4.0.0 to 4.0.9 | 4.0.10 |
| 3.4 | 3.4.0 to 3.4.12 | 3.4.13 |
| 3.3 | 3.3.13 and earlier | 3.3.14 |
| 3.2 and earlier | End of life | No fix; move to a supported line |
Ruby 3.3 moved from security maintenance to legacy maintenance with 3.3.14. Its support ends at the end of March 2027.
Who is exposed
- Regex flaws: applications that build a regex from attacker-controlled input, then compile or run it. Matching untrusted text against a developer-written pattern is generally a different risk, except for the moderate backreference bug.
- Case-conversion flaws: applications that change the case of crafted strings, especially imported or external text.
Recommended actions
- Upgrade the Ruby interpreter on application servers, background workers and container images, then restart or rebuild them.
- Remember that updating gems or the framework does not replace a vulnerable interpreter.
- Move Ruby 3.2 and earlier to a supported release.
- Audit code that compiles regexes from user input, and avoid it where possible.
Related
An October 23 release (Ruby 4.0.9, 3.4.12, 3.3.13) fixed separate regex compilation bugs found by GitLab. See our earlier coverage: Ruby Fixes Three Regex Engine Bugs.
Credit goes to Stephan Lipp (Ada Logics) and Anthropic for four findings, and to baba_yaga, aphantom, Hiroya Fujinami and Hiroshi SHIBATA for three.
