---
title: "GHSA-qhr7-859c-m2p7: brace-expansion: DoS via uncontrolled recursion on nested brace groups causing stack exhaustion"
description: "High severity. brace-expansion: DoS via uncontrolled recursion on nested brace groups causing stack exhaustion. Affects brace-expansion; fixed in 5.0.11."
url: https://inlinr.com/advisories/GHSA-qhr7-859c-m2p7
lang: en
---

[Packages](https://inlinr.com/packages) / [brace-expansion](https://inlinr.com/packages/brace-expansion) / [Security](https://inlinr.com/packages/brace-expansion/security)

High Vulnerability GHSA-qhr7-859c-m2p7 CVE-2026-102278 Published 29 Sep 2026

# brace-expansion: DoS via uncontrolled recursion on nested brace groups causing stack exhaustion

Your version 

Affected releases · [brace-expansion](https://inlinr.com/packages/brace-expansion)

- 5.x 5.0.2 – 5.0.10 Fixed in 5.0.11
- 4.x 4.0.0 – 4.0.1 No fix on this line yet
- 3.x 3.0.0 – 3.0.7 Fixed in 3.0.8
- 2.x 2.0.0 – 2.1.5 Fixed in 2.1.6
- 1.x 1.0.0 – 1.1.19 Fixed in 1.1.20
- 0.0.x 0.0.0 No fix on this line yet

On 5.x, the newest line:

```
npm install brace-expansion@5.0.11
```

Every release on a timeline

5.x 

1. Affected

5.0.2 – 5.0.10  
9 releases
2. Fixed

5.0.11 – 5.0.13  
3 releases, latest

4.x 

1. Affected

4.0.0 – 4.0.1  
2 releases

3.x 

1. Affected

3.0.0 – 3.0.7  
8 releases
2. Fixed

3.0.8 – 3.0.10  
3 releases

2.x 

1. Affected

2.0.0 – 2.1.5  
10 releases
2. Fixed

2.1.6 – 2.1.8  
3 releases

1.x 

1. Affected

1.0.0 – 1.1.19  
22 releases
2. Fixed

1.1.20 – 1.1.22  
3 releases

0.x 

1. Affected

0.0.0  
1 release

64 stable releases of brace-expansion, oldest to newest, one row per major.

## What happens

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.

## How it is exploited

Exploitable over the network, with no account and no action from a user.

- **Confidentiality**: none
- **Integrity**: none
- **Availability**: high

CVSS:3.1/​AV:N/​AC:L/​PR:N/​UI:N/​S:U/​C:N/​I:N/​A:H

## References

- [Reference](https://github.com/juliangruber/brace-expansion/security/advisories/GHSA-qhr7-859c-m2p7 "https://github.com/juliangruber/brace-expansion/security/advisories/GHSA-qhr7-859c-m2p7")  
github.com/juliangruber/brace-expansion/securit…
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-102278 "https://nvd.nist.gov/vuln/detail/CVE-2026-102278")  
nvd.nist.gov/vuln/detail/CVE-2026-102278
- [Fix commit](https://github.com/juliangruber/brace-expansion/commit/1efee7c397c191da6287a78ec19512476a966a7b "https://github.com/juliangruber/brace-expansion/commit/1efee7c397c191da6287a78ec19512476a966a7b")  
1efee7c
- [Fix commit](https://github.com/juliangruber/brace-expansion/commit/935d78f32f335b2ff76578e5c5e877d31ae9888c "https://github.com/juliangruber/brace-expansion/commit/935d78f32f335b2ff76578e5c5e877d31ae9888c")  
935d78f
- [Fix commit](https://github.com/juliangruber/brace-expansion/commit/de84f144e9816f30e25fc8179e2e1249ab6df0db "https://github.com/juliangruber/brace-expansion/commit/de84f144e9816f30e25fc8179e2e1249ab6df0db")  
de84f14
- [Package](https://github.com/juliangruber/brace-expansion "https://github.com/juliangruber/brace-expansion")  
github.com/juliangruber/brace-expansion

A whole project to check? Paste its package.json in the [dependency check](https://inlinr.com/tools/dependency-check): every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.
