re2: Out-of-bounds heap read in `exec`/`test`/`match` via attacker-influenced `lastIndex` on a non-ASCII subject → uncatchable process crash (DoS)
Collected exploitation and prediction evidence
Risk source coverageCISA KEV is observed exploitation evidence. FIRST EPSS is a dated prediction of exploitation in the next 30 days. Missing scores are unknown. This collector requests predictions only for explicit CVE aliases in the public NuGet archive; Microsoft release views retain their existing prediction scope.
No collected risk observation for these identifiers. This does not establish absence of exploitation or a zero probability.
cve-program · CVE-2026-67550
Publishedre2 provides Node.js bindings for Google's RE2 regular expression engine. Prior to 1.25.2, re2 validates lastIndex against the UTF-8 byte length of a subject but uses it as a UTF-16 code-unit offset in exec, test, match, replace, and split, allowing an attacker-influenced lastIndex on a non-ASCII subject to trigger an out-of-bounds heap read and an uncatchable process crash, with limited heap information disclosure in some cases. This issue is fixed in 1.25.2.
- Source published
- 30 Jul 2026 19:59:55 UTC
- Source modified
- 31 Jul 2026 23:07:18 UTC
- Observed here
- 23 Oct 2026 15:48:27 UTC
- Source terms
- CVE Program Terms of Use
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: cve-program · CVE Program Terms of Use. Source text is retained; field grouping and change labels are provided by ChangeIntel.
CVSS 3.1 · 5.7 CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H
nvd · CVE-2026-67550
Publishedre2 provides Node.js bindings for Google's RE2 regular expression engine. Prior to 1.25.2, re2 validates lastIndex against the UTF-8 byte length of a subject but uses it as a UTF-16 code-unit offset in exec, test, match, replace, and split, allowing an attacker-influenced lastIndex on a non-ASCII subject to trigger an out-of-bounds heap read and an uncatchable process crash, with limited heap information disclosure in some cases. This issue is fixed in 1.25.2.
NVD analysis and CPE criteria are source context, not proof that a package or your environment is affected. Complete affected data, logical configurations and SSVC are retained in the original JSON.
Source analysis status: Awaiting Analysis
Weakness classifications: CWE-125
Original publisher date fields
published: 2026-07-30T20:18:15.030
lastModified: 2026-10-23T22:10:00.160
- Source published
- 30 Jul 2026 20:18:15 UTC
- Source modified
- 23 Oct 2026 22:10:00 UTC
- Observed here
- 25 Oct 2026 15:18:51 UTC
- Source terms
- NIST NVD usage terms; underlying source attribution retained
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: nvd · NIST NVD usage terms; underlying source attribution retained. Source text is retained; field grouping and change labels are provided by ChangeIntel.
CVSS 3.1 · [email protected] · Secondary · 5.7 CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H
osv · GHSA-ff84-5f28-78qj
Published## Summary `re2` validates the user-settable `lastIndex` against the subject's **UTF-8 byte length** but then uses it as a **UTF-16 code-unit count** to walk the subject buffer, with no bounds check. For any non-ASCII subject, the byte length is larger than the true character count, so a `lastIndex` between those two values passes validation while pointing past the end of the buffer. The subsequent walk reads out of bounds. With a large subject the read marches into unmapped memory and the process dies with **SIGABRT/SIGSEGV** — an uncatchable crash (`try/catch` cannot stop it), i.e. a denial of service for any worker/process that runs the match. In some cases the out-of-bounds bytes are copied into the returned value (a bounded, best-effort heap information leak). ## Root cause The subject wrapper stores the UTF-8 **byte** length in `StrVal::length`: - `lib/addon.cc:200` `auto argLength = utf8Length(s, isolate);` — UTF-8 **byte** count - `lib/addon.cc:209` `lastStringValue.reset(buffer, argSize, argLength, startFrom, false, isAscii);` `setIndex` then validates the (UTF-16) `lastIndex` against that byte length and walks the buffer by character count: ```cpp // lib/addon.cc:229 void StrVal::setIndex(size_t newIndex) { isValidIndex = newIndex <= length; // length == UTF-8 BYTE length, not UTF-16 length if (!isValidIndex) { index = newIndex; byteIndex = 0; return; } ... // addon.cc:263 byteIndex = index < newIndex ? getUtf16PositionByCounter(data, byteIndex, newIndex - index) : getUtf16PositionByCounter(data, 0, newIndex); index = newIndex; } ``` `getUtf16PositionByCounter` reads `data[from]` and advances by the UTF-8 char size with **no check of `from` against the buffer size**: ```cpp // lib/wrapped_re2.h:264 inline size_t getUtf16PositionByCounter(const char *data, size_t from, size_t n) { for (; n > 0; --n) { size_t s = getUtf8CharSize(data[from]); // <-- OOB read once `from` passes the buffer end from += s; if (s == 4 && n >= 2) --n; } return from; } ``` `lastIndex` is user-settable to any positive integer (capped only at `>= 0`, no upper bound): ```cpp // lib/accessors.cc:166 NAN_SETTER(WrappedRE2::SetLastIndex) { ... int n = value->NumberValue(...).FromMaybe(0); re2->lastIndex = n <= 0 ? 0 : n; // no upper bound relative to the subject } ``` For an ASCII subject the byte length equals the UTF-16 length, so the guard is correct — this only triggers on non-ASCII subjects. The out-of-bounds read happens inside `prepareArgument` for any `global`/`sticky` regex, reached by `exec`, `test`, `String.prototype.match`, `replace`, and `split`. ## Proof of concept **Minimal (AddressSanitizer, deterministic OOB read):** ```js const RE2 = require('re2'); const re = new RE2('a', 'y'); // sticky; 'g' also works re.lastIndex = 3; // 3 <= byteLen(4) passes the guard; only 2 real chars exist re.exec('éé'); // U+00E9 = 2 bytes each ``` Built with `-fsanitize=address`, this aborts with: ``` ERROR: AddressSanitizer: heap-buffer-overflow ... READ of size 1 #0 getUtf16PositionByCounter wrapped_re2.h:268 #1 StrVal::reset addon.cc:277 #2 WrappedRE2::prepareArgument addon.cc:209 #3 WrappedRE2::Exec exec.cc:17 ``` The overflowed region is the subject buffer allocated by `node::Buffer::New` at `addon.cc:205`. **Real-world impact on the shipped prebuilt binary (no ASAN) — uncatchable crash:** ```js const RE2 = require('re2'); const s = '中'.repeat(40000000); // UTF-16 length 40M, UTF-8 bytes 120M const re = new RE2('a', 'y'); re.lastIndex = Buffer.byteLength(s) - 1; // passes the byte-length guard, far exceeds real char count re.exec(s); // walks into unmapped memory -> SIGSEGV (exit 139) ``` `try { ... } catch (e) {}` around the call does **not** prevent termination — it is a native fault, not a JS exception. Validated on a clean `npm install [email protected]` (latest): stock prebuilt → SIGSEGV; ASAN build → the heap-buffer-overflow read above. ## Impact - **Denial of service (primary):** an uncatchable native crash that terminates the Node process/worker. Reachable remotely and without authentication wherever an application (a) uses a `global` or `sticky` `RE2`, (b) applies it to a non-ASCII subject, and (c) sets `lastIndex` from attacker-influenced data (e.g. resuming a scan/pagination at a client-supplied offset). - **Information disclosure (secondary, best-effort):** the out-of-bounds `byteIndex` can cause adjacent heap bytes to be copied into the returned value (e.g. the leading segment of a `replace` result). This is bounded and unreliable — the subject buffer is `calloc`-allocated (zero-filled) and the over-read distance depends on interpreting out-of-bounds bytes as UTF-8 sizes — so it is noted for completeness, not as a dependable primitive. This is distinct from GHSA-8hcv-x26h-mcgp (the global `replace()` output-amplification abort), which was fixed in 1.25.1. This `lastIndex` out-of-bounds read is a separate defect and remains present in 1.25.1. ## Suggested fix Two independent hardenings; either closes the crash, both is safest: 1. **Bound the walk** so it can never read past the buffer: ```cpp inline size_t getUtf16PositionByCounter(const char *data, size_t size, size_t from, size_t n) { for (; n > 0 && from < size; --n) { size_t s = getUtf8CharSize(data[from]); from += s; if (s == 4 && n >= 2) --n; } return from > size ? size : from; } ``` (thread `size` through the two call sites in `StrVal::setIndex`). 2. **Validate `lastIndex` against the true UTF-16 length**, not the UTF-8 byte length — e.g. store `s->Length()` (UTF-16 units) as the value compared in `isValidIndex = newIndex <= <utf16Length>`, so an out-of-range `lastIndex` takes the existing `!isValidIndex` early-return path. ## Resolution Fixed in re2 1.25.2. `lastIndex` is now validated against the subject's UTF-16 length instead of its UTF-8 byte length (`lib/addon.cc`), so an out-of-range `lastIndex` is rejected before the buffer is walked. As defense in depth, the code-unit walk (`getUtf16PositionByCounter` in `lib/wrapped_re2.h`) is now bounded by the buffer size and can no longer read past the end. **Remediation:** upgrade to `[email protected]` or later. **Workaround** (if you cannot upgrade): do not assign `lastIndex` from untrusted input, or clamp it to the subject's string length (`str.length`) before calling `exec`/`test`/`match`/`replace`/`split` on a non-ASCII subject.
- Source published
- 31 Jul 2026 16:53:16 UTC
- Source modified
- 31 Jul 2026 17:00:20 UTC
- Observed here
- 24 Oct 2026 13:17:17 UTC
- Source terms
- GitHub Advisory Database · CC-BY-4.0
Original source record · Cite this exact observation · Complete original publisher JSON
This view projects the publisher's source fields for reading; the original JSON retains additional fields and CVE enrichment containers. Attribution: osv · GitHub Advisory Database · CC-BY-4.0. Source text is retained; field grouping and change labels are provided by ChangeIntel.
CVSS_V3 · CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H
Publisher rating · MODERATE