CVE-2026-110264 — 16-bit ID overflow in the regexp engine

GitLab CE/EE, CVSS 10.0 · root cause in Onigmo, the engine Ruby bundles · upstream fix ruby/ruby 493d26dc (PR #16801)

⚠ VISUALISATION OF MEASURED LAB DATA — not a live vulnerable service

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.

Scope

✅ 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)

1 · The bug, in the engine's own code

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          */

2 · Boundary and wrap — measured

Unit (?:foobar){0,100} = one range-repeat node = 17 bytes of wire.

Buildnodeswire bytescompileoutcome
vulnerable32,767557,039acceptedmatches cleanly, no fault
vulnerable32,768557,056acceptedno fault — every ID still representable
vulnerable32,769557,073acceptedOOB write id=−32768 → SIGSEGV
vulnerable100,0001,700,000acceptedASAN out-of-bounds write
patched32,767557,039acceptedmatches cleanly
patched≥32,768—rejectedRegexpError: 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.

ID as a function of compile-order node index

id = (short)node — exact formula, not interpolated measured rows (32,767 / 32,768 / 32,769)

3 · Write window — the only reachable corruption

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.

reachable, out of allocation reachable, in allocation not reachable by any wrapped ID

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.

4 · The read is an oracle — measured per offset

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.

IDdelta (bytes)value read at repeat_range[ID]branchmatch outcome
−32768−262144{lower=0, upper=0}PUSH-ALTERNATIVEmatch at 0
−24576−196608{0, 0}PUSH-ALTERNATIVEmatch at 0
−16384−131072{0, 0}PUSH-ALTERNATIVEmatch at 0
−8192−65536{0, 0}PUSH-ALTERNATIVEmatch at 0
−64−512{0, 0}PUSH-ALTERNATIVEmatch at 0
−256−2048{lower=−865167687, upper=−865167687}NO-PUSHno match (−1)
−1−8{lower=28, upper=0}NO-PUSHno match (−1)
−4096−32768read faulted—SIGSEGV — DoS with no write
−1024−8192read faulted—SIGSEGV — DoS with no write
0, 1, 32767in-boundsno out-of-range access—match at 0, clean

5 · Negative results — measured, and why the search stopped there

Two plausible exploitation routes were tested and CLOSED

Index poisoning (colliding IDs) — no difference

IDsrepeat_inc countdistinct stack slotsASANresult
collision0, 01001cleanmatch, survived
control0, 21001cleanmatch, 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.

Null-check / capture arm — unreachable

TestResult
capture groups: 100 vs 32,768100 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 presentall correct — group0 (0,3), group1 (0,1), group2 (1,2), group3 (2,3)
null-check tag collision vs controlidentical (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.

6 · Where this sits in the exploitation chain

1 · Reach the corrupt state inside the declared limits demonstrated
2 · Control location of the write (offset selectable, 65,536 choices) demonstrated
content is only weakly controllable: a small, incrementing stack index
3 · Control heap layout so a chosen object occupies the −256 KiB window; turn the write into a hijack not demonstrated
4 · Bypass mitigations (NX, canaries, ASLR) once control exists not demonstrated
5 · Reliability across a live multi-worker pool not demonstrated

RCE ≠ root: a successful exploit would run code as the service account (git, gitlab-www), and privilege escalation is a separate problem.

7 · Reproduce it

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.

8 · Sources