CVE-2026-102278: brace-expansion: DoS via uncontrolled recursion on nested brace groups causing stack exhaustion
High CVSS 7.5
- OSV id
- GHSA-qhr7-859c-m2p7
- Also known as
- CVE-2026-102278
- Published
- Last modified
Affected packages
| Package | Affected versions | Fixed in |
|---|---|---|
| brace-expansion npm |
>= 4.0.0, < 5.0.11 | 5.0.11 |
| brace-expansion npm |
>= 3.0.0, < 3.0.8 | 3.0.8 |
| brace-expansion npm |
>= 2.0.0, < 2.1.6 | 2.1.6 |
| brace-expansion npm |
< 1.1.20 | 1.1.20 |
Versions we track that it affects: brace-expansion 2.0.1; brace-expansion 2.0.1; brace-expansion 2.0.1; brace-expansion 2.0.1
How to fix it
brace-expansion (npm)
Upgrade brace-expansion to 5.0.11 or later.
npm install brace-expansion@5.0.11
# if it is an indirect dependency: npm update brace-expansion (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
brace-expansion (npm)
Upgrade brace-expansion to 3.0.8 or later.
npm install brace-expansion@3.0.8
# if it is an indirect dependency: npm update brace-expansion (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
brace-expansion (npm)
Upgrade brace-expansion to 2.1.6 or later.
npm install brace-expansion@2.1.6
# if it is an indirect dependency: npm update brace-expansion (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
brace-expansion (npm)
Upgrade brace-expansion to 1.1.20 or later.
npm install brace-expansion@1.1.20
# if it is an indirect dependency: npm update brace-expansion (or npm audit fix)
- If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
- Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.
Not sure whether your project uses an affected version? Check your lockfile below for free.
Details
Summary
expand_() recurses once per level of brace nesting. Deeply nested input exhausts the native stack and crashes the process.
This is distinct from CVE-2026-14257 / GHSA-mh99-v99m-4gvg, which made the tail iterative (recursion on m.post, driven by how many groups are chained). Nesting depth drives a different recursion that the tail fix never touched, so the documented constant-stack-depth guarantee only ever covered chained input, not nested input.
It is also distinct from GHSA-6j4f-fj2g-mc7p, which fixed recursion in parseCommaParts(). Both payloads below still crash with that fix applied.
Two recursion sites
Comma members. Each alternative of a brace set is expanded by a recursive call, so nesting a set inside every alternative recurses once per level:
expand('{a,'.repeat(4000) + 'z' + '}'.repeat(4000))
// RangeError: Maximum call stack size exceeded
Crashes at depth 3,907 - about 15.6 KB of input.
Single set. A brace set whose body parses to a single part is expanded by a recursive call before being re-wrapped (x{{a,b}}y -> x{a}y x{b}y), which recurses once per nesting level:
expand('{'.repeat(3200) + 'a,b' + '}'.repeat(3200))
// RangeError: Maximum call stack size exceeded
Crashes at depth 3,125 - about 6.25 KB of input. This is the cheapest stack-exhaustion payload known against this package: roughly a quarter the input of GHSA-6j4f-fj2g-mc7p (29 KB), and about a tenth of minimatch's MAX_PATTERN_LENGTH (65,536).
Why max and maxLength do not help
Both crashes happen while recursing into sub-expansions, before the result set grows. The payloads produce almost no output - the single-set case yields 2 results - so neither bound is ever the limiter. expand(payload, { max: 1, maxLength: 1 }) still overflows.
Impact
Any application passing an untrusted string to expand(), directly or through minimatch / glob as a user-supplied glob pattern, can be crashed. In Node a RangeError the application does not catch terminates the process, so a server globbing user input is exposed to remote unauthenticated denial of service.
Availability only. No code execution, no data exposure.
Affected versions
Verified affected on 1.1.18, 2.1.4, 3.0.6 and 5.0.9, at near-identical depths on every line (single set: 3,125 on all four; comma members: 3,907-4,102). Not a regression from any recent fix - the gap predates them.
Patch
A maxDepth bound (default EXPANSION_MAX_DEPTH) is threaded through expand_(). Past the cap a group is treated as non-expanding and returned literally, which is how the parser already handles a group that cannot expand. This matches the existing max / maxLength caps, which truncate rather than throw, so expand() continues never to throw on any input.
The default sits far above any realistic nesting depth and well below the crash threshold.
References
- GHSA-qhr7-859c-m2p7 on OSV.dev
- Web: https://github.com/juliangruber/brace-expansion/security/advisories/GHSA-qhr7-859c-m2p7
- Advisory: https://nvd.nist.gov/vuln/detail/CVE-2026-102278
- Web: https://github.com/juliangruber/brace-expansion/commit/1efee7c397c191da6287a78ec19512476a966a7b
- Web: https://github.com/juliangruber/brace-expansion/commit/935d78f32f335b2ff76578e5c5e877d31ae9888c
- Web: https://github.com/juliangruber/brace-expansion/commit/de84f144e9816f30e25fc8179e2e1249ab6df0db
- Package: https://github.com/juliangruber/brace-expansion
Am I affected?
Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.
About this data
Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.