All vulnerabilities

npm

CVE-2026-102277

brace-expansion: Quadratic-time expansion of the `{a},b}` rewrite causes CPU denial of service

Severity
Medium 5.3
Published
29 Sept 2026
Last changed
30 Sept 2026
Added to UpHeron
22 Oct 2026
Fixed in
1.1.21, 2.1.7, 3.0.9, 5.0.12
Exploit chance
0.4% in the next 30 daysHigher than 37% of CVEs. EPSS by FIRST, 19 Nov 2026
Weakness
Uncontrolled resource consumption (CWE-400)Inefficient algorithmic complexity (CWE-407)
Attack
Over the network · No login needed · No user action needed
Attacker can
Slow it down
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Also known as
GHSA-q2hr-2g5m-vwhr
Sources
OSV.dev and GitHub

Description

Expanding {a},b}-shaped input takes time quadratic in the number of literal } characters, blocking the event loop.

Bash preserves a quirk where a brace group followed by a comma set still expands ({a},b}). The parser implements this by rewriting the string and restarting the scan. Each pass absorbs exactly one } and re-scans from the beginning, so n trailing braces cost n full passes.

Instrumenting the rewrite branch confirms it runs exactly n + 1 times, once per literal }, each re-scanning the whole string.

There is a second multiplier. The rewrite replaces the group's closing } with the internal escClose sentinel, which is '\0CLOSE' + Math.random() + '\0' - about 25 characters. The working string therefore grows by ~25 characters on every pass:

So the input is inflated roughly 26x, and that factor multiplies both the quadratic constant and peak memory. This makes it partly a memory-pressure issue as well as a CPU one.

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

Affected software

SoftwareAffected versions
brace-expansionnpm · osv:npm:brace-expansion
  • Every version before 1.1.21
  • From 2.0.0 before 2.1.7
  • From 3.0.0 before 3.0.9
  • From 4.0.0 before 5.0.12

About brace-expansion

Weekly downloads (npm)
838,345,228npm, 16 Nov 2026

References