
Independent measurement harness verifying CVE-2026-93687: reproduces cold-process stack exhaustion in braces 3.0.3 under the default maxLength and tests mitigations.
This repo verifies, with measurements, the claim in CVE-2026-93687 (GHSA-vfj7-8cjw-p6xm)
that the npm package braces at version 3.0.3 and below is vulnerable to
"stack exhaustion through deeply nested patterns" (CWE-674, uncontrolled
recursion). The advisory lists no patched version.
This is a verify repo, not a patch repo. It does not fork or fix braces. It
pins the exact affected versions, drives every public entry point, and reports
numbers.
Deeply nested brace patterns (for example {a,{a,{a,...}}} or {{{...}}}) drive
recursive functions in braces past the call stack limit, throwing
RangeError: Maximum call stack size exceeded and crashing the process. The
advisory references point at the recursive code in lib/compile.js (L49-53),
lib/expand.js (L102-105) and lib/parse.js (L38-40) of braces 3.0.3.
In micromatch/braces issue #70 the maintainer (jonschlinkert, 2026-10-05) called it "complete nonsense" and made three points:
maxLength below that is all that is needed, and is already supported.maxDepth option would not solve glob DoS in general: glob patterns are
regular expressions, negation forces the engine to build and invert a DFA,
and that state space can blow up exponentially (the star height problem).Upstream has collected twelve fix PRs since the issue opened (#72 through #89), five still open, all variations on bounding nesting depth. None is merged.
Machine: Apple Mac mini (Mac16,10), arm64, macOS 25.6 (Darwin 25.6.0). Node: v26.8.1. braces 3.0.3, micromatch 4.0.8, fast-glob 3.3.1, exact pins.
Two facts about braces shape everything:
maxLength (lib/constants.js MAX_LENGTH) is 10000
characters, not the 65536 of older releases. It was lowered to 10000 in
upstream PR #40 (2024).lib/parse.js sets the effective cap to Math.min(MAX_LENGTH, opts.maxLength).
So maxLength can only lower the 10000 cap, never raise or disable it.
braces will not accept an input longer than 10000 characters. parse is also
iterative (an explicit stack array), so it never recurses and never
overflows; the recursion lives in expand and compile.The question is therefore whether a pattern of 10000 characters or fewer nests
deeply enough to overflow the recursive expand/compile. The answer depends
on whether the call is cold or warm, and this matters a lot:
Each probe below therefore runs in its own fresh node process
(repro/child.mjs via spawnSync): one build, one call, print the outcome. The
warm column repeats the same search inside a single process, to show the gap.
Outcomes: stack (a caught RangeError), guarded (the length guard rejected
it first), other (a different caught error, e.g. V8 "regex too large"), ok.
Shapes: commaNested = {a,{a,...}} (about 4 chars per level), braceNested =
{{{...a...}}} (about 2 per level), rangeNested = {1..2,{1..2,...}} (about
7 per level). maxLength default = 10000.
| entry point | shape | cold break depth | pattern len | cold | warm |
|---|---|---|---|---|---|
| braces() | commaNested | 2500 | 10001 | guarded | guarded@2500 |
| braces() | braceNested | 3510 | 7021 | stack | guarded@5000 |
| braces() | rangeNested | 1429 | 10007 | guarded | guarded@1429 |
| braces.expand() | commaNested | 2500 | 10001 | guarded | guarded@2500 |
| braces.expand() | braceNested | 3984 | 7969 | stack | guarded@5000 |
| braces.expand() | rangeNested | 1429 | 10007 | guarded | guarded@1429 |
| braces.compile() | braceNested | ~3500 | ~7000 | stack (edge) | guarded@5000 |
| braces.parse() | braceNested | 5000 | 10001 | guarded | guarded@5000 |
| micromatch() | commaNested | 5653 | 22613 | other (regex too large) | same |
| micromatch() | braceNested | 16383 | 32767 | other (regex too large) | same |
| micromatch() | rangeNested | 9362 | 65538 | guarded | same |
| micromatch.isMatch() | braceNested | 16383 | 32767 | other (regex too large) | same |
| fast-glob.generateTasks() | braceNested | ~3976 | ~7953 | stack (edge) | guarded@5000 |
| fast-glob.sync() | braceNested | 128 | 257 | other (benign glob Error) | same |
| (all braces/fast-glob) | commaNested / rangeNested | 2500 / 1429 | ~10000 | guarded | guarded |
Reading the table:
braces() and
braces.expand() overflow the stack on the brace shape at a pattern length of
about 7000 to 8000 characters, well under the 10000 cap. This is
deterministic across repeated fresh runs (confirmed 5 of 5 at depth 4000, len
8001, for both). The compile path and fast-glob.generateTasks sit at the
same cold threshold band (about depth 3500 to 4000); right at the edge the
exact depth wobbles a few hundred between runs, but a few hundred deeper it is
a reliable crash.braces.parse() never overflows (it is iterative), on any shape.MAX_LENGTH = 65536) and does its own brace handling; below that cap it builds
a regex so large that V8 throws a catchable
SyntaxError: Invalid regular expression ... too large. The long pattern is
not forwarded into a braces stack overflow. picomatch is a different package
from braces.fast-glob.sync() (a real glob on a temp dir) is not the DoS vector: it
throws an ordinary, catchable Error very early (depth 128), not a stack
overflow. The pattern-parsing path generateTasks is the one that can reach
the recursion.In every crashing case the overflow is a RangeError that a surrounding
try/catch catches; the child process prints its outcome and exits 0, so it is
a thrown error, not an uncatchable abort. There is no data exposure and no code
execution.
expand/compile accept an AST object directly, bypassing the length guard. A
hand-built nested AST overflows at whatever depth the stack allows (about 6200
on the default stack warm, higher with --stack-size larger, lower with it
smaller). So the recursion itself has no bound; the only thing standing between
it and a crash is the 10000 character input cap, and on the brace shape that cap
is not enough cold.
Measured cold, per shape, the first crashing length and the maxLength that
rejects it: