GitLab CE/EE, CVSS 10.0 · root cause in Onigmo, the engine Ruby bundles ·
upstream fix ruby/ruby 493d26dc (PR #16801)
A browser cannot run the vulnerable engine. Every number below was produced by executing the C lab in this repository and copying the value out of its output. The two diagrams are drawn from those measured values; the geometry of the address-space diagram is schematic (not to scale) and is labelled as such.
| ✅ Demonstrates (measured) | ❌ Does not demonstrate |
|---|---|
the 16-bit truncation and its exact wrap point · the resulting index arithmetic
(id = −32768 → −262144 bytes) · a real memory-safety failure
(SIGSEGV unsanitised; ASAN out-of-bounds write) · the vuln-vs-patched behavioural
delta on byte-identical input · the complete 4-hunk vendor patch · trigger cost
(557,073 bytes, no auth) · that the write window has exactly two reachable classes ·
that a wrapped ID steers a branch by reading foreign heap memory
|
weaponised RCE · the unauthenticated route in GitLab (its HackerOne report is still restricted; the work item is private for 90 days) · heap grooming against Ruby's allocator · any pointer-grade primitive (the capture and null-check arms were measured to be unreachable — see negative results) |
int num_repeat = reg->num_repeat; /* an unbounded int */ r = add_mem_num(reg, num_repeat); /* OP_REPEAT ID — regcomp.c */ reg->num_repeat++; /* ... and nothing checks it */ typedef short int MemNumType; /* 16-bit signed — regint.h */ /* later, at match time — regexec.c */ GET_MEMNUM_INC(mem, p); /* mem is now -32768 */ repeat_stk[mem] = GET_STACK_INDEX(stk); /* 8-byte out-of-bounds write */ if (reg->repeat_range[mem].lower == 0) /* out-of-bounds read */
Unit (?:foobar){0,100} = one range-repeat node = 17 bytes of wire.
| Build | nodes | wire bytes | compile | outcome |
|---|---|---|---|---|
| vulnerable | 32,767 | 557,039 | accepted | matches cleanly, no fault |
| vulnerable | 32,768 | 557,056 | accepted | no fault — every ID still representable |
| vulnerable | 32,769 | 557,073 | accepted | OOB write id=−32768 → SIGSEGV |
| vulnerable | 100,000 | 1,700,000 | accepted | ASAN out-of-bounds write |
| patched | 32,767 | 557,039 | accepted | matches cleanly |
| patched | ≥32,768 | — | rejected | RegexpError: too many range repeat (ONIGERR −224) |
Note: the vendor check is conservative by one — at 32,768 nodes every ID is still in range, yet the patched engine rejects the pattern.
repeat_stk[mem] writes 8 bytes at repeat_stk + mem*8.
The ID block is one xmalloc allocation; MAX_PTR_NUM=100 forces the heap
path.
All 65,536 representable IDs are selectable by choosing the number of range-repeat nodes, at 17 bytes of wire per unit of ID. Class BEFORE-BLOCK is the only out-of-allocation class, and it is where the corruption lands.
Per-offset probe: exactly one out-of-range access per run, ~1.3 s. The executed pattern is identical across these rows — only never-executed lookahead padding differs. So match-vs-no-match is decided by foreign heap bytes, not by the pattern.
| ID | delta (bytes) | value read at repeat_range[ID] | branch | match outcome |
|---|---|---|---|---|
| −32768 | −262144 | {lower=0, upper=0} | PUSH-ALTERNATIVE | match at 0 |
| −24576 | −196608 | {0, 0} | PUSH-ALTERNATIVE | match at 0 |
| −16384 | −131072 | {0, 0} | PUSH-ALTERNATIVE | match at 0 |
| −8192 | −65536 | {0, 0} | PUSH-ALTERNATIVE | match at 0 |
| −64 | −512 | {0, 0} | PUSH-ALTERNATIVE | match at 0 |
| −256 | −2048 | {lower=−865167687, upper=−865167687} | NO-PUSH | no match (−1) |
| −1 | −8 | {lower=28, upper=0} | NO-PUSH | no match (−1) |
| −4096 | −32768 | read faulted | — | SIGSEGV — DoS with no write |
| −1024 | −8192 | read faulted | — | SIGSEGV — DoS with no write |
| 0, 1, 32767 | in-bounds | no out-of-range access | — | match at 0, clean |
| IDs | repeat_inc count | distinct stack slots | ASAN | result | |
|---|---|---|---|---|---|
| collision | 0, 0 | 100 | 1 | clean | match, survived |
| control | 0, 2 | 100 | 1 | clean | match, survived |
Byte-for-byte identical. In a sequential layout the earlier unit's
OP_REPEAT_INC always runs before the later unit's write, and the pushed alternative
skips the loop rather than re-entering it.
| Test | Result |
|---|---|
| capture groups: 100 vs 32,768 | 100 compiles; 32,768 → −210 "too many capture groups" — capture IDs are bounded at 32,767 |
| does any write land in a mem array? (n = 32,769 / 65,536 / 100,000) | 0 violations |
| capture offsets with a wrapped ID present | all correct — group0 (0,3), group1 (0,1), group2 (1,2), group3 (2,3) |
| null-check tag collision vs control | identical (result 0, group0 beg=0 end=0) |
A null-check ID is a stack tag, never an array index:
STACK_PUSH_NULL_CHECK_START touches no mem slot. And arithmetically a wrapped ID is at
most +32767 while the mem arrays begin at index num_repeat ≥ 32768.
Root cause in one line: ONIG_MAX_CAPTURE_GROUP_NUM = 32767 —
exactly the 16-bit range — while ONIG_MAX_REPEAT_NUM = 100000 and
num_null_check had no such bound.
RCE ≠ root: a successful exploit would run code as the service account
(git, gitlab-www), and privilege escalation is a separate problem.
git clone <this repo> && cd <repo> ./run.sh # clones Onigmo, builds 4 configurations, prints a verdict per step cat RESULTS.txt # frozen output of a full run (absolute paths rewritten to repo-relative)
No root, no container runtime, no GitLab install, no Ruby install. Everything is
built from upstream source in a disposable vendor/ tree. Nothing here targets a remote
system — do not point anything derived from it at systems you do not own.
cveawg.mitre.org/api/cve/CVE-2026-110264docs.gitlab.com/releases/patches/patch-release-gitlab-19-5-1-released/ruby-lang.org/en/news/2026/10/23/regexp-fixes-for-gitlab-cves/github.com/ruby/ruby/commit/493d26dcdea8b2f0ac5d28e057b401bc809e7fae73cec6d8