⏱️ Reading time: 6 min
Ruby released versions 4.0.10, 3.4.13, and 3.3.14 to patch seven vulnerabilities in its regular expression engine and in the case conversion of strings. The Ruby team already has proof-of-concept exploits demonstrating remote code execution in at least five of the seven flaws, according to the security advisory published on November 19, 2026.
📑 En este artículo
- The Regex Engine Ruby Never Rewrote From Scratch
- One Byte Out of Bounds and a Double Free: the Path to RCE
- The Detail the Summary Leaves Out: Who Found the Flaws
- What to Check if You Run a Ruby App in Production
- Why RE2 and Rust’s Regex Engine Don’t Share This Problem
- What This Update Doesn’t Fix
- References
The Regex Engine Ruby Never Rewrote From Scratch
Ruby does not build its own regular expression support: it uses Onigmo, a C fork of the Oniguruma library, to compile and execute every Regexp object. Case conversion operations (upcase, downcase, capitalize) also run in C, because they depend on conversion tables that vary by each string’s encoding.
That C code, with manual memory management, is exactly where the seven flaws fixed by this update showed up. None of them live in the Ruby interpreter or the garbage collector: all of them sit in the two standard library pieces that process raw bytes without the protection a language with automatic memory management provides.
One Byte Out of Bounds and a Double Free: the Path to RCE
The advisory groups the issues under GHSA identifiers, not CVEs: Ruby requested the corresponding CVEs, but they have not been assigned yet. The most cited flaw, GHSA-34m4-m9fh-gqp5, is a single-byte heap overflow when converting the case of a crafted string. The advisory confirms proof-of-concept exploits achieving remote code execution through that single out-of-bounds byte.
Another, GHSA-7x2q-68qv-6p8x, is a double free when compiling a crafted regular expression pattern. If an application compiles a Regexp from text that comes from a user (a search feature with exposed regex syntax, a dynamically built validator, a form filter), that pattern can free the same memory region twice. That opens the door to arbitrary code execution, according to the same advisory.
The other five flaws repeat the same family of bugs, with public proof-of-concept exploits for most of them:
- GHSA-87fm-7w84-j2px: an integer overflow during case conversion that ends in a heap overflow.
- GHSA-wpqw-5qxg-m68r: an out-of-bounds read during case-insensitive matching.
- GHSA-3p8q-wmhx-vm2w: another heap overflow, this time when compiling a pattern.
- GHSA-7whj-cfh7-xgm4: an overflow when converting a
Regexpto a string withRegexp#to_s. - GHSA-pvgc-g7gj-pv6h: an out-of-bounds read during backreference matching, which can leak memory or hang the process.
The Detail the Summary Leaves Out: Who Found the Flaws
The advisory’s summary doesn’t say it, but the credits at the bottom of the page do: of the seven flaws, four (GHSA-34m4, GHSA-7x2q, GHSA-wpqw, and GHSA-7whj) were jointly reported by Stephan Lipp, of Ada Logics, and Anthropic, according to the same credits list in the advisory.
Anthropic appearing as a co-reporter on four separate flaws suggests part of this research now runs with language-model assistance, not only traditional fuzzing harnesses. The other three flaws were reported separately by baba__yaga, aphantom, and the duo of Hiroya Fujinami and Hiroshi Shibata, according to the same credits list.
On Hacker News, the discussion around the advisory drifted toward an older debate: some commenters revive the idea that Ruby’s string and encoding handling is too flexible for its own good, an argument that resurfaces every time a flaw lands in exactly that layer of the language.
What to Check if You Run a Ruby App in Production
If you maintain a Ruby on Rails, Sinatra, or Hanami application in production, the first step is running ruby -v in every environment and comparing it against the fixed versions. The advisory covers Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. If your .ruby-version falls in that range, update with rbenv, rvm, or asdf to 4.0.10, 3.4.13, or 3.3.14, depending on the branch you use.
The most direct risk falls on features that compile a Regexp from text you don’t control: search features with regex syntax exposed to users, dynamic validators built from configuration, or any DSL that turns an input string into a pattern. Review that code first, not just your Gemfile.lock.
But the risk isn’t limited to that: converting a string’s case is such a common operation (normalizing an email, comparing a username) that the upcase/downcase flaws expose almost any app that processes user input, even without regex involved. If you use Dependabot, Renovate, or a version matrix in your CI, this is a good time to add a check that fails the build if Gemfile.lock doesn’t pin a patched version, instead of relying on someone remembering at the next deploy.
Ruby 3.3 is still in its security maintenance phase, so it receives this patch despite not being the newest branch. If you run Ruby 3.2 or earlier, the advisory is harsher: those versions reached end of life and will not receive a patch. There, the real update isn’t bumping a patch version, it’s moving to a newer major branch, with the compatibility work that implies.
Why RE2 and Rust’s Regex Engine Don’t Share This Problem
The seven flaws share a root cause: Onigmo is written in C with manual memory management, the same ground where most buffer overflows and use-after-free bugs in software history show up. It is not the only regex engine with that design risk, but it is worth comparing it to the ones that solved the problem differently.
| Engine | How it manages memory | Where it’s used |
|---|---|---|
| Onigmo (Ruby) | C with manual memory management, the same code behind these seven flaws | The Regexp engine in CRuby |
| RE2 (Google) | An automaton that avoids the exhaustive searches that cause ReDoS, but still written in C++ with manual memory | Go’s regexp package and Ruby’s re2 gem |
| regex (Rust) | The Rust compiler rejects overflows and use-after-free bugs of this kind at compile time | ripgrep and most command-line tools written in Rust |
None of the three eliminates logic errors: a poorly written pattern is still a poorly written pattern in any engine. But changing the implementation language does eliminate the entire bug category Ruby just patched, the one born from managing memory by hand in C.
What This Update Doesn’t Fix
Updating Ruby fixes the engine, not your code. If your application already exposed Regexp.new to user input without any limit, you still need a timeout or a length check to prevent a regular expression denial-of-service attack, a different problem that none of this advisory’s seven flaws cover.
⚠️ Heads up: Ruby 3.2 and earlier do not receive this patch. If your stack depends on one of those versions, updating isn’t enough: you need to migrate to a newer major branch.
References
- Ruby security advisory: details the seven vulnerabilities, their GHSA identifiers, and the affected versions.
- Update recommendation in the same advisory: fixed versions 4.0.10, 3.4.13, and 3.3.14, and the end of life of Ruby 3.2 and earlier.
- Advisory credits: identifies Stephan Lipp (Ada Logics) and Anthropic as reporters of four of the seven flaws.
- Hacker News discussion: community thread about the advisory and Ruby’s string handling.
Featured image: Foto de Pankaj Patel en Unsplash
How each article is made (sources, testing and editorial criteria): How we work.
Did it work for you? Got a different error? Say so below: questions get answered and help the next reader.
Leave a comment
0 Comments