On November 18, 2026, the Ruby core team published an advisory covering seven separate bugs, all living in two places you’d never think to suspect: the C code that changes a string’s case (.upcase, .downcase, and friends), and the C code that compiles and runs regular expressions. None of these are logic bugs or “this method returns the wrong thing” bugs. Every one of them is memory corruption — the kind of bug where feeding the wrong input doesn’t just give you a wrong answer, it can hand an attacker control of the process running your code. The advisory says plainly that proof-of-concept exploits already exist for remote code execution “in some scenarios” for most of these.
No CVE numbers exist yet — Ruby’s team requested them but they hadn’t been assigned at publish time, so each bug is tracked only by a GitHub Security Advisory (GHSA) ID for now. That shouldn’t make you take it less seriously; CVE assignment is paperwork, not a severity signal.
This post walks through what actually goes wrong, in each of the four underlying bug shapes (not all seven individually — several of them are the same mistake happening in a different spot), using made-up example code to show the kind of call that lands in the broken code path. I’m deliberately not giving you anything resembling a working trigger input — that’s not knowledge this post needs to hand out, and the official advisory doesn’t publish one either.
1. Summary
- Seven vulnerabilities, four underlying bug patterns: buffer overflows from bad size math (in case conversion and in regex compilation), a double free (in regex compilation), out-of-bounds reads (in two different kinds of regex matching), and a dedicated buffer overflow specifically in
Regexp#to_s. - Several of the seven come with confirmed proof-of-concept exploits capable of remote code execution, at least in some scenarios. Two of the seven (the out-of-bounds read bugs) are described as leading to crashes or memory disclosure rather than confirmed RCE.
- Affected: Ruby 3.3.13 and everything before it, Ruby 3.4.0 through 3.4.12, and Ruby 4.0.0 through 4.0.9.
- Fixed: Ruby 4.0.10, Ruby 3.4.13, and Ruby 3.3.14 — all released the same day as the advisory.
- Ruby 3.2 and anything older gets nothing. Those lines are past end-of-life, and Ruby’s team has said outright they won’t be patched. If you’re on 3.2 or earlier, upgrading the Ruby version is the only fix available to you — there’s no backport coming.
- Most of the people who reported these bugs are credited as “Stephan Lipp (Ada Logics) and Anthropic” — meaning this batch of seven was very likely found by an AI-assisted fuzzing/auditing effort, not a human manually poking at the code line by line. Worth noting as a sign of where a lot of serious bug-hunting is heading.
2. What’s actually broken, explained without the jargon
All four of these bug shapes come from the same general family: C code that has to calculate, ahead of time, exactly how many bytes of memory it will need, allocate that many, and then write into it. Get the calculation wrong in either direction, and you’re writing data into memory that was never set aside for it.
Bug shape 1: case conversion writes past the end of its own buffer
Two of the seven bugs (one a plain heap overflow, one an integer overflow that causes a heap overflow) live in the code behind .upcase, .downcase, .capitalize, and friends.
Here’s the detail that makes this bug class believable rather than suspicious: changing a string’s case doesn’t always keep the string the same length. Most Unicode case conversions are simple one-character-for-one-character swaps, but not all of them are. The German letter “ß” uppercases to two characters, “SS”. Some other Unicode characters expand or shrink by a byte or two when their case changes, depending on how they’re encoded.
So the code converting a string’s case has to do a little math first: “given this input, how many output bytes will I actually need?” — allocate a buffer that size — and then do the conversion. If that size calculation is wrong for some unusual, specially-crafted sequence of characters (undercounting by even one byte, or wrapping around entirely if the math overflows), the conversion routine writes its output past the end of the buffer it was given. That’s the overflow.
In plain Ruby terms, the dangerous shape looks like this — I’m not showing you which specific sequence of characters triggers the miscalculation, just the shape of the call that reaches the vulnerable code:
# Anywhere user-controlled text reaches a case-conversion method is# the risk surface here — not just obvious cases like login forms.def normalize_username(raw_input) raw_input.downcase.stripend
normalize_username(params[:username])That’s an ordinary, boring line of Rails code you’ve probably written a hundred times. The bug isn’t in writing code like this — it’s in what Ruby’s own C implementation does internally when .downcase runs on a byte sequence engineered to confuse its size math.
Bug shape 2: compiling a regex miscounts memory, or frees it twice
Two more of the seven bugs happen when Ruby compiles a regular expression — turning the pattern text you wrote into the internal, optimized representation the matching engine actually runs against.
One of these is the same “miscounted buffer size” mistake as above, just happening during compilation instead of case conversion: a complex enough pattern (deeply nested groups, heavy repetition — the compiler has to compute how large the compiled program needs to be based on the pattern’s structure) can trick that size calculation into producing a number that’s too small, and the compiler then writes the full compiled program into a buffer that’s too small to hold it.
The other is a genuinely different mistake: a double free. Somewhere in the compiler’s error-handling or cleanup logic, there’s a code path where the same block of memory gets handed back to the allocator twice. On its own, a double free usually just corrupts the allocator’s internal bookkeeping and crashes the process — but it’s also one of the oldest, best-understood building blocks for turning a crash into something an attacker can actually steer, because freeing memory twice lets an attacker influence what ends up reusing that memory the second time around.
The risk surface for both of these is the same, and it’s worth sitting with: anywhere your app compiles a regex pattern that didn’t come entirely from your own source code.
# This is the dangerous shape. "search_term" here is a regex PATTERN,# not a plain string being searched for — a common mix-up.def advanced_search(search_term) Regexp.new(search_term)end
advanced_search(params[:q])A lot of “advanced search” or “custom filter” features end up looking exactly like this, usually without anyone on the team realizing that Regexp.new on user input means the user is handing your server a program to compile, not just a string to search for.
Bug shape 3: matching a regex reads past the end of the string
Two of the seven bugs are out-of-bounds reads — not writes, reads. These show up in two specific matching scenarios: case-insensitive matching, and matching against a backreference (where a pattern like (\w+)\1 requires the engine to go back and compare text it already matched earlier in the same string).
Both of these situations require the matching engine to look at more than one candidate position or character form at once — a case-insensitive match has to consider every case-folded variant of a character, and a backreference match has to re-examine earlier text. Near the very end of a string, an off-by-one in that lookup logic can read one byte (or more) past the end of the buffer actually allocated for the string.
The consequences are real but narrower than the buffer-overflow bugs: an out-of-bounds read can crash the process outright (if the byte just past the buffer happens to be unmapped memory), or, in the worse case, leak whatever happened to be sitting in adjacent memory into something an attacker can observe — for example, if that leaked byte changes how the match result comes back, or how long the match takes. That’s a smaller blast radius than “attacker gets code execution,” which is likely why one of these two (the backreference one) is described only as a crash/disclosure risk, with no RCE claim attached to it.
# Case-insensitive matching against untrusted strings and patterns# both carry risk here — this reaches the vulnerable comparison path.pattern = /#{Regexp.escape(params[:keyword])}/isome_user_supplied_text.match?(pattern)Bug shape 4: turning a regex back into text overflows a buffer
The last bug is the only one of the seven tied to one specific, named method: Regexp#to_s. Calling .to_s on a compiled regex has to reconstruct its textual form — the pattern, wrapped in slashes, with its flags appended, with certain characters re-escaped along the way. That reconstruction has the same “calculate the output size first” problem as case conversion does, and for a sufficiently unusual pattern, that calculation can come up short, overflowing the buffer being written into.
What makes this one sneaky is where .to_s gets called from without anyone noticing it’s a meaningful operation at all:
def log_search_filter(pattern_source) compiled = Regexp.new(pattern_source) Rails.logger.info("Applying search filter: #{compiled}") compiledendThat #{compiled} string interpolation calls Regexp#to_s implicitly. A line of code that looks like nothing more than a debug log statement is exactly the kind of place this bug gets triggered — which is a good reminder that “just logging it” is still executing code, not a safe no-op.
Warning
Notice the pattern across all four bug shapes: the dangerous ingredient isn’t any single
method, it’s letting text you don’t control reach case-conversion or regex-compilation code
at all. A search box, a CSV import column, a webhook payload, a config file populated from an
admin UI — anywhere a string that started outside your app ends up inside .downcase,
Regexp.new, or an interpolated #{some_regex}, is the actual surface these bugs live on.
3. The fixes, and what this means for Ruby versions already in production
The fix itself is simple to state: upgrade your Ruby interpreter. These are bugs in Ruby’s own C implementation — not in a gem, not in your application code — so there’s no bundle update that touches this. You need a new ruby binary.
| Your current version | What to do |
|---|---|
| Ruby 4.0.0 – 4.0.9 | Upgrade to 4.0.10 |
| Ruby 3.4.0 – 3.4.12 | Upgrade to 3.4.13 |
| Ruby 3.3.0 – 3.3.13 | Upgrade to 3.3.14 |
| Ruby 3.2 and earlier | No fix is coming. These lines are end-of-life; upgrading to a maintained minor version is the only real option. |
A few things worth being deliberate about rather than just running rbenv install and moving on:
- This is a C-level patch, so it needs a real interpreter rebuild, not just a gem bump. If you’re on a container base image that pins an exact Ruby patch version (
FROM ruby:3.4.12-slim, for example), that pin is now the thing that needs updating, and it won’t happen automatically just because your gems are current. - If you’re genuinely stuck on Ruby 3.2 or earlier — and plenty of production Rails apps still are, usually for reasons that have nothing to do with wanting to be — this advisory is a forcing function, not just an inconvenience. There is no patched 3.2 coming. The only way to close these seven holes on an old Ruby is to stop being on an old Ruby.
- The actual risk to any one app depends entirely on whether attacker-influenced text reaches these code paths, as section 2 covered. An app that never compiles a regex from user input and never runs case conversion on anything outside a tightly-controlled set of values is lower-risk than one with a “custom search” feature — but “lower-risk” isn’t “no-risk,” since plenty of input ends up in a regex or a
.downcasecall indirectly, through a gem, a validation helper, or a sanitizer you didn’t write yourself. - No CVE numbers exist yet for any of the seven. If your organization’s patch-tracking process waits for a CVE ID to show up in a feed before treating something as “a real vulnerability to act on,” that process will miss this one for a while. Track it by the GHSA IDs in the official advisory instead of waiting.
4. Summary
Seven bugs, one root cause pattern repeated four ways: C code that has to predict how much memory an operation will need, getting that prediction wrong for specially-crafted input, and either writing past a buffer’s end, reading past it, or freeing the same memory twice. Most of them have confirmed working exploits capable of remote code execution in at least some real-world setups — this isn’t a theoretical “could maybe be an issue” advisory.
If you remember nothing else from this post: check what Ruby patch version you’re actually running in production right now, not what your Gemfile or your rbenv default says you should be running — and if it’s below 4.0.10, 3.4.13, or 3.3.14, that gap is the thing to close this week, not next quarter.
Source: Multiple vulnerabilities in Regexp and String, ruby-lang.org, published November 18, 2026.