CVE
CVE-2026-132825
CWE
CWE-122, CWE-190, CWE-415, CWE-125, CWE-787
Affected Surface
- CRuby (`ruby`) `4.0.0` through `4.0.9` (fixed in `4.0.10`), `3.4.0` through `3.4.12` (fixed in `3.4.13`), and `3.3.13` and earlier (fixed in `3.3.14`)
- End-of-life CRuby `3.2.x` and older, which Ruby will not patch (Aikido reports the case-conversion bug goes back to `2.4.0`)
- Applications that change the case of attacker-supplied strings tagged with an ISO-8859-x or Windows-125x encoding (`upcase`, `downcase`, `capitalize`, `swapcase`, `casecmp?` folding)
- Applications that build regular expressions from attacker-supplied text with `Regexp.new`, `Regexp.union`, `Regexp.compile` or `/#{input}/`, then compile, match or call `to_s` on them
- Container images, CI runners and self-hosted products that ship their own Ruby interpreter; Aikido lists GitLab `19.6.0`, GitHub Enterprise Server `3.22.5`, Mastodon `4.7.5`, OpenProject `17.9.7`, Discourse `2026.10.1` and Chatwoot `4.20.0` as still bundling an affected Ruby on 19 November
Update (21 November 2026): Three of the self-hosted products named below now ship a fixed Ruby. GitLab released critical patch versions 19.6.1, 19.5.8 and 19.4.10 on 20 November, bumping its bundled Ruby to 3.3.14 and 3.4.13. GitLab.com and GitLab Dedicated were already patched. Self-compiled GitLab installs have to rebuild their own Ruby. The same GitLab releases also carry an input-validation fix for a separate GPGME double free (CVE-2026-129975). GnuPG moved that disclosure up from 25 November because GitLab had to ship early for Ruby2Shell. Mastodon released 4.7.6, 4.6.12 and 4.5.22 on 19 November “primarily to update Ruby in our docker container images”, and says non-Docker installs need Ruby 4.0.10, 3.4.13 or 3.3.14. Chatwoot 4.20.1 (20 November) moves to Ruby 3.4.13 and requires it for non-Docker installs. GitHub Enterprise Server’s newest 3.22 release notes are still for 3.22.5, and we found no Discourse release. Several GitHub repositories named after the CVE appeared on 19 and 20 November. Most are version checkers or Suricata/ModSecurity rules. One claims to be a Go proof of concept, but we haven’t verified it, so treat it as untrusted code. Nobody has reported exploitation, EPSS was 0.0019 on 20 November, and the CVE isn’t in KEV.
TL;DR
Ruby released 4.0.10, 3.4.13 and 3.3.14 on 18 November 2026 to fix seven memory-safety bugs. Three are in how CRuby changes the case of strings and four are in the bundled Onigmo regular-expression engine. The maintainers say they know of proofs of concept that reach remote code execution for five of them. None of the PoCs is public, and nobody has reported an attack yet.
The bug getting the attention is CVE-2026-132825 / GHSA-34m4-m9fh-gqp5, which Aikido calls Ruby2Shell. Calling upcase on a string in ISO-8859-1, Windows-1252 or a related single-byte encoding writes one byte past the end of a heap buffer when the string contains the German sharp s (0xDF). UTF-8 strings don’t take this path. The other headline bug is a double free when Onigmo parses a character-class intersection ([a&&b]), which only matters if an attacker controls the pattern.
Who should move first:
- Anyone running Ruby
3.3.13or older,3.4.0to3.4.12, or4.0.0to4.0.9. Ruby 3.2 and older are end of life and will not get a fix. - Apps that compile user-supplied regexes (search filters, rule engines, CI config, “advanced search” boxes).
- Apps that handle legacy single-byte encodings: CSV and email imports, mainframe or ERP feeds,
force_encoding("ISO-8859-1")calls. - Operators of self-hosted Ruby products. Aikido says GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot all still bundled a vulnerable Ruby on 19 November.
Updating gems or Rails doesn’t help, because the bug is in the interpreter. Upgrade Ruby itself, rebuild your images and restart every process. The official Docker images (ruby:4.0.10, ruby:3.4.13, ruby:3.3.14) were rebuilt between 00:49 and 01:59 UTC on 19 November.
Affected packages and projects
| Ecosystem | Package / product | Advisory | Ruby severity | Affected versions | Fixed version |
|---|---|---|---|---|---|
| Ruby runtime | CRuby ruby | CVE-2026-132825 / GHSA-34m4-m9fh-gqp5 (sharp s case-map overflow) | Critical (NVD/MITRE CVSS 3.1: 7.4) | <= 3.3.13, 3.4.0 to 3.4.12, 4.0.0 to 4.0.9 | 3.3.14, 3.4.13, 4.0.10 |
| Ruby runtime | CRuby ruby | GHSA-7x2q-68qv-6p8x (double free in && class parsing) | Critical | same | same |
| Ruby runtime | CRuby ruby | GHSA-3p8q-wmhx-vm2w (compiled program size overflow) | Critical | same | same |
| Ruby runtime | CRuby ruby | GHSA-87fm-7w84-j2px (case-map length overflow above 4 GiB) | High | same | same |
| Ruby runtime | CRuby ruby | GHSA-7whj-cfh7-xgm4 (Regexp#to_s heap overflow) | High | same | same |
| Ruby runtime | CRuby ruby | GHSA-wpqw-5qxg-m68r (OOB read in case-insensitive exact match) | High | same | same |
| Ruby runtime | CRuby ruby | GHSA-pvgc-g7gj-pv6h (OOB read in case-insensitive backreference) | Moderate | same | same |
| Ruby runtime | CRuby 3.2.x and older | all of the above | n/a | all | none (end of life) |
| Docker Hub | library/ruby | all of the above | n/a | tags built before 19 November | 4.0.10, 3.4.13, 3.3.14 tags |
On 19 November only the sharp-s bug had a CVE. MITRE assigned CVE-2026-132825 at 06:34 UTC and scored it CVSS 3.1 7.4 (AV:L/AC:H), lower than Ruby’s own “critical” label. Ruby says it has requested CVEs for the other six, so until those land, scanners have to match on the GHSA IDs.
Technical analysis
The backports landed on the ruby_3_4 branch between 20:07 and 22:09 UTC on 18 November. Most of the original fixes were written by Yusuke Endoh between 28 October and 18 November. The commit trailers on four of them credit Anthropic’s Claude models as co-author, and four of the reports came from Stephan Lipp of Ada Logics with Anthropic.
1. CVE-2026-132825: the sharp s writes two bytes into one
Single-byte encodings in CRuby each have a case_map callback in enc/*.c. For most characters, upcasing or downcasing swaps one byte for another. The exception is ß (0xDF, SHARP_s): in these encodings it has no single-byte uppercase form, so upcase writes "SS" and case folding writes "ss". Two output bytes for one input byte.
Here is the vulnerable loop from enc/iso_8859_1.c in Ruby 3.4.12:
static int
case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
const OnigUChar* end, OnigUChar* to, OnigUChar* to_end,
const struct OnigEncodingTypeST* enc)
{
...
while (*pp < end && to < to_end) { // only checks that ONE byte is free
code = *(*pp)++;
if (code == SHARP_s) {
if (flags & ONIGENC_CASE_UPCASE) {
flags |= ONIGENC_CASE_MODIFIED;
*to++ = 'S'; // first byte
code = (flags & ONIGENC_CASE_TITLECASE) ? 's' : 'S';
}
...
}
...
*to++ = code; // second byte: can land at to_end
}
The loop guard to < to_end only checks that one byte of output space is left. When the last free byte of the buffer is reached and the next input byte is 0xDF, the function writes 'S' into that byte and then a second 'S' at to_end, one past the allocation.
Reaching that state is easy because of how rb_str_casemap in string.c sizes its output buffers:
#define CASE_MAPPING_ADDITIONAL_LENGTH 20
...
while (source_current < source_end) {
size_t capa = (size_t)(source_end-source_current)*++buffer_count + CASE_MAPPING_ADDITIONAL_LENGTH;
current_buffer = xmalloc(offsetof(mapping_buffer, space) + capa);
...
buffer_length_or_invalid = enc->case_map(flags, &source_current, source_end,
current_buffer->space,
current_buffer->space+current_buffer->capa, enc);
The first buffer holds the input length plus 20 bytes. A string of 21 ß characters needs 42 output bytes and gets a 41-byte buffer. After 20 of them the buffer has one byte left, and the 21st ß writes two. An attacker who controls the string length and contents decides exactly where that buffer runs out, which is the starting point Ruby says the PoCs build on.
Two conditions have to hold. The string must be tagged with one of the affected encodings, because UTF-8 uses a different case_map. And it must contain a non-ASCII byte, because rb_str_upcase takes a single-byte fast path (upcase_single) for pure 7-bit strings. Aikido says Rails and classic-style Sinatra reach this path in their default setup. Ruby’s advisory doesn’t name any framework, and we have not reproduced Aikido’s claim.
The fix, commit b841d6f4f1, changes the guard in 14 encoding files to require two free bytes:
--- a/enc/iso_8859_1.c
+++ b/enc/iso_8859_1.c
@@ -264,7 +264,7 @@ case_map(OnigCaseFoldType* flagP, const OnigUChar** pp,
OnigUChar *to_start = to;
OnigCaseFoldType flags = *flagP;
- while (*pp < end && to < to_end) {
+ while (*pp < end && to_end - to > 1) {
code = *(*pp)++;
if (code == SHARP_s) {
if (flags & ONIGENC_CASE_UPCASE) {
The same one-line change went into iso_8859_2, _3, _4, _9, _10, _13, _14, _15 and _16, plus windows_1250, windows_1252, windows_1254 and windows_1257. If the loop exits with input left over, rb_str_casemap allocates another buffer and carries on, so the stricter guard doesn’t change the output.
2. GHSA-87fm-7w84-j2px: the same function, overflowing past 4 GiB
rb_str_casemap stored the total output length in an int. Once a case change produced more than 4 GiB, the counter wrapped and the final copy wrote past the end of the result string. THN notes that a request this large is out of reach for most web apps. The fix, commit f2e5063748, credited to HackerOne researcher baba__yaga, widens the counter and caps each buffer at INT_MAX:
- int target_length = 0;
+ long target_length = 0;
...
if (RSTRING_LEN(source) == 0) return str_duplicate(rb_cString, source);
+ if (RSTRING_LEN(source) > INT_MAX - CASE_MAPPING_ADDITIONAL_LENGTH)
+ rb_raise(rb_eArgError, "string size too big");
...
- size_t capa = (size_t)(source_end-source_current)*++buffer_count + CASE_MAPPING_ADDITIONAL_LENGTH;
+ size_t capa = (size_t)(source_end-source_current);
+ if (capa > (INT_MAX - CASE_MAPPING_ADDITIONAL_LENGTH) / ++buffer_count)
+ capa = INT_MAX;
+ else
+ capa = capa * buffer_count + CASE_MAPPING_ADDITIONAL_LENGTH;
...
- if (buffer_length_or_invalid < 0) {
+ if (buffer_length_or_invalid < 0 || buffer_length_or_invalid > LONG_MAX - target_length) {
3. GHSA-7x2q-68qv-6p8x: double free on && inside a character class
This one needs an attacker-controlled pattern. In parse_char_class (regparse.c), the handler for a class intersection such as [a-z&&[^aeiou]] frees cc->mbuf, the buffer holding the multibyte ranges, but leaves the pointer in place. If the next step, intersecting the ASCII-only copy of the class, fails, the error path frees cc->mbuf a second time. Commit 28aad344e1 clears the pointer after the free:
--- a/regparse.c
+++ b/regparse.c
@@ -4979,6 +4979,7 @@ parse_char_class(Node** np, Node** asc_np, OnigToken* tok, UChar** src, UChar* e
r = and_cclass(prev_cc, cc, env);
if (r != 0) goto err;
bbuf_free(cc->mbuf);
+ cc->mbuf = NULL;
if (IS_NOT_NULL(asc_cc)) {
r = and_cclass(asc_prev_cc, asc_cc, env);
if (r != 0) goto err;
The regression test shows the trigger shape. You need a case-insensitive pattern with a negated non-ASCII class, thousands of multibyte ranges, and two && operators, so that and_cclass runs out of room on the ASCII copy:
chars = (0...9999).map { |i| (0x4e00 + 2 * i).chr("UTF-8") }.join
cc = "[[:^ascii:][^#{chars}]&&[^\u9fff]&&x]"
assert_raise(RegexpError) { Regexp.new(cc, Regexp::IGNORECASE) }
On a fixed Ruby this raises RegexpError. On an affected one, the same input frees the same buffer twice.
4. The other four
GHSA-3p8q-wmhx-vm2w(critical, reporteraphantom): Onigmo’s compiled-program size check only ran insideadd_opcode(). The bulk writers (add_bytes,add_bitset,add_multi_byte_cclass,add_compile_string) wrote straight into the buffer, and several callers ignored their return values. A long chain of multibyte property classes could overflow the size accounting and write past the end. Fixed by6c6e6c9273,65b71a8844and57c24699fe. It’s the same family as the October compiled-program-size bugs behind the GitLab CVEs (see our October write-up). The new commits extend that size check to the bulk writers.GHSA-7whj-cfh7-xgm4(high):Regexp#to_sre-parsed the raw pattern source to decide whether it could drop the(?opts:...)wrapper, whileRegexp.newhad compiled the preprocessed source. A(?#...)comment inside a character class makes the two disagree, and the mismatch overflows a heap buffer. Fixed bycdd499eccdinre.c. Interpolating a regex into a string or another regex ("#{re}",/x#{re}/) callsto_s.GHSA-wpqw-5qxg-m68r(high):OP_EXACT1_ICandOP_EXACTN_ICadvanced the bytecode pointer by the length of a character’s case fold without checking it against the operand. A fold of a different length (for example U+1E98 in UTF-16) made the matcher run the following pattern bytes as instructions. Fixed bye12e722695.GHSA-pvgc-g7gj-pv6h(moderate): case-insensitive backreference comparison instring_cmp_iccould read past the end of the subject string. This is the only one of the seven that fires with a developer-written pattern, but Ruby rates it as a read or crash, not code execution. Fixed byb469749b37.
Exploitation status
On 19 November there were no reports of attacks and no public exploit code. Ruby’s advisory says the maintainers “are aware of PoCs” for RCE on five of the bugs. Aikido says the researchers plan to publish theirs in about a week. EPSS had no score for CVE-2026-132825 on 19 November, and none of these bugs is in CISA KEV.
The October Onigmo bugs are a useful warning. Those were also regex-compiler memory bugs, and one of them (CVE-2026-97229, via GitLab) reached the KEV catalog within a week of Ruby’s release, after an attempted attack on Alpine Linux’s GitLab server.
IOCs
These are vulnerability fixes, not a malware campaign, so there are no network IOCs. A failed exploit attempt usually crashes the process. Look for:
free(): double free detected in tcache 2,malloc(): corrupted top sizeorcorrupted size vs. prev_sizein Puma, Unicorn, Sidekiq or GitLab worker logs.[BUG] Segmentation faultcrash reports from CRuby withonig_compile,parse_char_class,onig_search,rb_str_casemap,rb_reg_to_sor acase_mapframe in the C-level backtrace.- Bursts of worker restarts that line up with requests whose parameters contain long runs of
%DFor a regex with&&inside brackets.
Detection and remediation
# 1. Which Ruby is actually running? (check each host, container and CI image)
ruby -e 'puts RUBY_DESCRIPTION'
# Affected: < 3.3.14, 3.4.0-3.4.12, 4.0.0-4.0.9, and every 3.2.x or older
# 2. Pinned versions in repos
grep -rnE '^(ruby )?"?[0-9]+\.[0-9]+\.[0-9]+' .ruby-version .tool-versions 2>/dev/null
grep -rnE 'FROM +(docker\.io/)?(library/)?ruby:' --include='Dockerfile*' .
grep -rnE 'ruby-version:|ruby: ' .github/workflows/ 2>/dev/null
grep -n -A1 'RUBY VERSION' Gemfile.lock
# 3. Container images you ship
for img in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep -v '<none>'); do
printf '%s ' "$img"; docker run --rm --entrypoint ruby "$img" -e 'puts RUBY_VERSION' 2>/dev/null || echo "(no ruby)"
done
# 4. Code paths that hit the vulnerable functions
# Regex built from input:
grep -rnE 'Regexp\.(new|union|compile)\(|/#\{' app lib --include='*.rb'
# Strings forced into the affected encodings:
grep -rnE 'ISO-8859-[0-9]+|ISO8859|Windows-125[0-8]|CP125[0-8]|Encoding::(ISO_8859|Windows_125|CP125)' app lib config --include='*.rb'
# 5. Self-hosted products: check the bundled interpreter, not the system one
sudo /opt/gitlab/embedded/bin/ruby -v 2>/dev/null
What to do:
- Upgrade Ruby to
4.0.10,3.4.13or3.3.14, then rebuild images and restart app servers, job workers and anything else that keeps a Ruby process running. Bundler and gem updates don’t replace the interpreter. - Leave EOL Ruby. Ruby
3.2and older will not get these fixes. If you can’t move this week, at least stop compiling user-supplied regexes, and reject or transcode single-byte-encoded input to UTF-8 before case operations. - Turn on a regex timeout anyway (
Regexp.timeout = 1.0). It won’t stop memory corruption at compile time, but it does limit pathological matching while you upgrade. - Self-hosted Ruby products. Watch for vendor releases for GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot. Aikido recommends taking public instances behind a VPN or IP allowlist until then.
- No credentials to rotate unless you find crash signatures that match exploitation attempts. If you do, treat that host’s secrets (
secret_key_base, database URLs, cloud keys in the environment) as exposed.
Timeline
- 2026-10-28: Yusuke Endoh writes the first fixes, including the sharp-s case-map fix (
b841d6f4f1), the&&double-free fix (28aad344e1) and the case-insensitive exact-match fix (e12e722695). - 2026-11-09:
rb_str_casemaplength check (f2e5063748) committed. - 2026-11-14 to 2026-11-18: compiled-program size fixes (
6c6e6c9273,65b71a8844) finished. - 2026-11-18, 20:07 to 22:09 UTC: backports merged to
ruby_3_4, and the version bumped to3.4.13. Ruby4.0.10,3.4.13and3.3.14tagged. The advisory on ruby-lang.org is dated 18 November. - 2026-11-19, 00:13 to 00:17 UTC: Ruby publishes the seven GitHub security advisories.
- 2026-11-19, 00:49 to 01:59 UTC: Docker Hub
ruby:4.0.10,ruby:3.3.14andruby:3.4.13images published. - 2026-11-19, 01:03 UTC: Alan Coopersmith forwards the advisory to oss-security.
- 2026-11-19, 06:34 UTC: MITRE publishes
CVE-2026-132825for the sharp-s overflow. NVD receives it at 07:17 UTC. - 2026-11-19, 09:42 UTC: Aikido publishes “Ruby2Shell”, including a list of self-hosted products that bundle an affected Ruby.
- 2026-11-19: The Hacker News reports the release. No public PoC and no reported attacks yet.
Related
From research to remediation
Check whether this pattern exists in your codebase
Turn this research into a remediation workflow. Use AI-native static analysis to find similar application vulnerabilities and generate review-ready fixes.
References
- Ruby security advisory (18 November 2026): multiple vulnerabilities in Regexp and String case conversion
- oss-security (2026/11/19/1): Ruby: multiple vulnerabilities in Regexp and String case conversion
- GHSA-34m4-m9fh-gqp5 (CVE-2026-132825): Heap buffer overflow in case conversion of strings
- GHSA-7x2q-68qv-6p8x: Double free in regular expression compilation
- GHSA-3p8q-wmhx-vm2w: Heap buffer overflow in regular expression compilation
- GHSA-87fm-7w84-j2px: Integer overflow in case conversion of strings
- GHSA-7whj-cfh7-xgm4: Heap buffer overflow in Regexp#to_s
- GHSA-wpqw-5qxg-m68r: Out-of-bounds read in case-insensitive regular expression matching
- GHSA-pvgc-g7gj-pv6h: Out-of-bounds read in case-insensitive backreference matching
- ruby/ruby commit b841d6f4f1: Fix a heap buffer overflow in case mapping of the sharp s
- ruby/ruby commit f2e5063748: Check the lengths in rb_str_casemap
- ruby/ruby commit 28aad344e1: Fix a double free in the && handler of parse_char_class
- Aikido: Ruby2Shell, critical Ruby RCE, affected versions and how to fix it (CVE-2026-132825)
- The Hacker News: Ruby releases fixes for 7 regex and string flaws, warns 5 have proof-of-concept RCE
- NVD: CVE-2026-132825
- GitLab Critical Patch Release: 19.6.1, 19.5.8, 19.4.10 (20 November 2026)
- Mastodon v4.7.6 release notes (Ruby update in Docker images)
- Chatwoot v4.20.1 release notes (Ruby 3.4.13)