critical

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.13 or older, 3.4.0 to 3.4.12, or 4.0.0 to 4.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

EcosystemPackage / productAdvisoryRuby severityAffected versionsFixed version
Ruby runtimeCRuby rubyCVE-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.93.3.14, 3.4.13, 4.0.10
Ruby runtimeCRuby rubyGHSA-7x2q-68qv-6p8x (double free in && class parsing)Criticalsamesame
Ruby runtimeCRuby rubyGHSA-3p8q-wmhx-vm2w (compiled program size overflow)Criticalsamesame
Ruby runtimeCRuby rubyGHSA-87fm-7w84-j2px (case-map length overflow above 4 GiB)Highsamesame
Ruby runtimeCRuby rubyGHSA-7whj-cfh7-xgm4 (Regexp#to_s heap overflow)Highsamesame
Ruby runtimeCRuby rubyGHSA-wpqw-5qxg-m68r (OOB read in case-insensitive exact match)Highsamesame
Ruby runtimeCRuby rubyGHSA-pvgc-g7gj-pv6h (OOB read in case-insensitive backreference)Moderatesamesame
Ruby runtimeCRuby 3.2.x and olderall of the aboven/aallnone (end of life)
Docker Hublibrary/rubyall of the aboven/atags built before 19 November4.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, reporter aphantom): Onigmo’s compiled-program size check only ran inside add_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 by 6c6e6c9273, 65b71a8844 and 57c24699fe. 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_s re-parsed the raw pattern source to decide whether it could drop the (?opts:...) wrapper, while Regexp.new had compiled the preprocessed source. A (?#...) comment inside a character class makes the two disagree, and the mismatch overflows a heap buffer. Fixed by cdd499eccd in re.c. Interpolating a regex into a string or another regex ("#{re}", /x#{re}/) calls to_s.
  • GHSA-wpqw-5qxg-m68r (high): OP_EXACT1_IC and OP_EXACTN_IC advanced 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 by e12e722695.
  • GHSA-pvgc-g7gj-pv6h (moderate): case-insensitive backreference comparison in string_cmp_ic could 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 by b469749b37.

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 size or corrupted size vs. prev_size in Puma, Unicorn, Sidekiq or GitLab worker logs.
  • [BUG] Segmentation fault crash reports from CRuby with onig_compile, parse_char_class, onig_search, rb_str_casemap, rb_reg_to_s or a case_map frame in the C-level backtrace.
  • Bursts of worker restarts that line up with requests whose parameters contain long runs of %DF or 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:

  1. Upgrade Ruby to 4.0.10, 3.4.13 or 3.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.
  2. Leave EOL Ruby. Ruby 3.2 and 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.
  3. 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.
  4. 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.
  5. 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_casemap length 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 to 3.4.13. Ruby 4.0.10, 3.4.13 and 3.3.14 tagged. 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.14 and ruby:3.4.13 images 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-132825 for 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.

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