Advisory and technical analysis of CVE-2026-97229, a GitLab CI/CD regex integer overflow enabling unauthenticated RCE, with root-cause, patch diff, detection rules, and IoCs.
Regexp.new.| Item | Details |
|---|---|
| CVE ID | CVE-2026-97229 |
| Publication date | 2026-10-12 (GitLab advisory published) / CVE record published 2026-10-13 |
| Affected products | GitLab Community Edition (CE) and Enterprise Edition (EE), self-managed |
| Affected versions | 19.2 (< 19.2.8), 19.3 (< 19.3.5), 19.4 (< 19.4.2) |
| Patched versions | 19.2.8, 19.3.5, 19.4.2 or later (see "Caution" below) |
| CVSS v3.1 | 10.0 (Critical) — CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
| CVSS v4.0 | No v4.0 vector provided in the official vendor (GitLab) advisory or CVE record (no confirmed value) |
| CWE | CWE-190 (Integer Overflow or Wraparound) |
| Reporter | joaxcar (Johan Carlsson), GitLab HackerOne bug bounty |
| Real-world exploitation | Added to CISA KEV (2026-10-29, federal agency remediation deadline 2026-11-01). Public PoC exists (Rapid7, 2026-10-13). Exploitation attempts targeting Alpine Linux instances observed (2026-10-20~21) |
⚠️ Important caution regarding patched versions (fact-checked)
- 19.3.4 is not a valid patch. The initial advisory listed the 19.3 branch fix as 19.3.4, but 19.3.4 had a bug affecting the merge request page when Ona integration is enabled, so it was superseded by 19.3.5. Some secondary sources still incorrectly list 19.3.4 as the patched version. Per the latest vendor advisory, the 19.3 branch fix is 19.3.5.
- Source builds or container images using their own Ruby remain vulnerable even after upgrading GitLab alone. This is because the fix patches the bundled Ruby in GitLab's official Omnibus packages/CNG images. Such environments must upgrade Ruby to 3.3.13 / 3.4.12 / 4.0.9 or later (released 2026-10-22~23). This was indeed an issue in the Alpine Linux case.
GitLab matches user-supplied regular expressions against the repository path in places such as rules:exists:regexp and rules:changes:regexp in CI/CD configuration. These regular expressions are ultimately compiled by Ruby's Regexp.new, and the internal engine Onigmo (Ruby's bundled regular expression engine, written in C) converts them into bytecode (pcode).
The fundamental flaw lies in the quantifier expansion size calculation of the Onigmo compiler. Because it uses a signed 32-bit integer to accumulate the compiled program size and stores jump offsets in the signed 32-bit RelAddrType, once the compilation result exceeds INT_MAX, both the length calculation and the jump offsets wrap around.
The key is the size check in compile_quantifier_node() of Ruby 3.3.12 regcomp.c (based on Rapid7 analysis and Ruby commits):
/* regcomp.c: compile_quantifier_node() — 취약 로직 */
else if (!infinite && qn->greedy &&
(qn->upper == 1 || (tlen + SIZE_OP_PUSH) * qn->upper
<= QUANTIFIER_EXPAND_LIMIT_SIZE)) { // 부호 있는 곱셈 → 오버플로
...
r = compile_tree_n_times(qn->target, qn->lower, reg); // 모든 복사본을 인라인 확장
}
If the product of the repeat body size (tlen) and the repeat count (qn->upper) exceeds INT_MAX, the result wraps to a negative number and passes the check that says "it's small enough, so inline expansion is fine." As a result, Onigmo generates a huge pcode, and the jump offsets computed from the wrapped length then send execution flow to the wrong location.
GitLab has several defenses in place for regular expressions, but they are bypassed as follows (based on the end-to-end path disclosed by Rapid7):
REPEAT_BOUND, upper bound 1,000): recognizes only consecutive digits. The PoC inserts an inline regex comment (?#) in the middle, like {5(?#)7805}, to fool the scanner. Onigmo ignores (?#) and reads the upper bound as 57,805, but the scanner never sees anything above 1,000.rb_reg_prepare_re(). At this point, POSIX character classes like [[:word:]] expand into large Unicode range tables, and GitLab does not check the size of this recompilation result. Also, this recompilation happens outside the match timeout (Regexp.timeout), so it is not blocked by the timeout either.In other words, a small (around 986-byte) regular expression passes the checks, and only then, at match time during the UTF-8 recompilation, does it become a large program that triggers the overflow.
Note (inference): The path analyzed and disclosed by Rapid7 assumes "first pushing a crafted
.gitlab-ci.ymland a special path to a public project (requires write permission)." This conflicts with GitLab'sPR:N(no privileges required) assessment, but because the original HackerOne report is private, it has not been publicly confirmed how the reported attack avoids the write step (Rapid7 also states it does not know). Therefore, the exact path in the original report that underpins the "fully unauthenticated" assessment is currently in the realm of inference.
Based on Ruby PR #19020 (commit cf35145fc4, backport 2d1859ffa6) plus follow-up commit 366f5fdc00. GitLab backported this Ruby patch into its bundled Ruby (omnibus-gitlab MR !9845).
(a) Replacing signed multiplication with a division-based check (making overflow impossible)
/* Before: (tlen + SIZE_OP_PUSH) * qn->upper <= QUANTIFIER_EXPAND_LIMIT_SIZE → 곱셈이 오버플로 */
/* After: regcomp.c */
#define IS_EXPAND_LIMIT_OK(tlen, n) \
((n) <= 0 || (tlen) <= QUANTIFIER_EXPAND_LIMIT_SIZE / (n))
(b) Introducing a hard cap on compiled program size
/* After: regint.h */
#define MAX_COMPILED_PROGRAM_SIZE ((unsigned int)(INT_MAX_LIMIT / 4))
/* After: regcomp.c — 모든 명령어가 통과하는 add_opcode()에서 차단 */
static int
add_opcode(regex_t* reg, int opcode)
{
if (reg->used > MAX_COMPILED_PROGRAM_SIZE)
return ONIGERR_TOO_BIG_COMPILED_PROGRAM;
BBUF_ADD1(reg, opcode);
return 0;
}
(c) Error-clobbering correction — commit 366f5fdc00
Fixed an issue where, immediately after add_opcode(reg, OP_END) returned a size-exceeded error, in patterns containing a subroutine call (\g<n>), r was overwritten by the return value (0) of unset_addr_list_fix(), causing the error to be swallowed.
/* regcomp.c: onig_compile() */
r = add_opcode(reg, OP_END);
+ if (r != 0) goto err_unset; // 추가: 크기 초과 오류를 삼키지 않도록 즉시 분기