{"id":"CVE-2026-13149","aliases":["CVE-2026-13149","GHSA-3jxr-9vmj-r5cp"],"related":[],"kind":"vulnerability","state":"published","title":"brace-expansion: DoS via exponential-time expansion of consecutive non-expanding {} groups","summary":"brace-expansion through 5.0.6 is vulnerable to denial of service. The expand() function exhibits exponential-time complexity in the number of consecutive non-expanding '{}' brace groups. An attacker who passes a crafted string to expand(), directly or transitively, can cause significant CPU consumption and event-loop blocking. The max option does not mitigate this, as it bounds the output size rather than the recursion work.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"brace-expansion through 5.0.6 is vulnerable to denial of service. The expand() function exhibits exponential-time complexity in the number of consecutive non-expanding '{}' brace groups. An attacker who passes a crafted string to expand(), directly or transitively, can cause significant CPU consumption and event-loop blocking. The max option does not mitigate this, as it bounds the output size rather than the recursion work.","source":"cvelist"},{"lang":"en","text":"### Summary\nbrace-expansion's expand() exhibits exponential-time - O(2ⁿ) - behavior in the number of consecutive non-expanding {} groups. A short, all-ASCII input (~90 bytes/30 groups) blocks the calling thread for minutes; a slightly longer input hangs it effectively indefinitely. Because the dominant consumers run on Node's single-threaded event loop, one small input can fully stall a worker/process.\n\nIn `expand_`, `post` is computed unconditionally at the top of the function, before the early-return branches that don't use it:\n```js\nconst post = m.post.length ? expand_(m.post, max, false) : [''];   // always recurses\n  ...\nif (!isSequence && !isOptions) {\n  if (m.post.match(/,(?!,).*\\}/)) {\n    str = m.pre + '{' + m.body + escClose + m.post;\n    return expand_(str, max, true); // restart — `post` discarded\n  }\n  return [str];\n}\n```\n\nFor input like a{},{},…, the first {} is non-expanding, so control reaches the {a},b} rewrite branch - but `expand_` has already recursed into post over the entire remaining tail, only to throw the result away.\nEach level therefore spawns two recursive expansions over essentially the same remaining work: `T(n) = 2·T(n−1) ⇒ O(2ⁿ)`.\n\nThe max option does not mitigate this: max only bounds the output-building loops; neither the post recursion nor the rewrite recursion consults it.\n  \nMeasured on 5.0.6:\n\n| groups (n) | input bytes | time |\n|---|---|---|\n| 20 | 60 | 130 ms |\n| 24 | 72 | 1.9 s |\n| 26 | 78 | 7.8 s |\n| 30 (PoC) | 90 | ~2 min |\n\n### Proof of concept\n```js\nconst { expand } = require('brace-expansion');\n// 30 non-expanding groups, ~90 bytes — blocks for minutes:\nexpand('a{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}');\n```\n\n### Impact\n\nAny application that passes attacker-influenced strings to brace-expansion.expand() - directly or transitively via minimatch/glob brace patterns - can be driven into a multi-minute-to-indefinite CPU hang by a tiny request, denying service on that thread/process.\n\n### Remediation\n\nUpgrade to a patched release. The fix:\n1. Defers computing post until after the early-return branches (and computes it locally in the $-suffix branch), so post is only expanded when a brace set actually expands and the value is used. This alone removes the exponential.\n1. Converts the {a},b} rewrite from recursion to an in-function loop, so a long run of rewrites cannot grow the call stack.\n\nVerified: the PoC drops from ~2 min to 0.55 ms, 5,000 groups complete in ~344 ms, and output is identical to 5.0.6 across a behavioral-equivalence suite (sequences, padding, $-prefix, a{},b}c, {},a}b, x{{a,b}}y, etc.). Post-fix complexity is ~O(n²) on this input class - acceptable for the security fix; a linear rewrite can be a non-urgent follow-up.\n\nIf immediate upgrade isn't possible, avoid passing untrusted input to expand() / glob brace patterns, or run such expansion under a timeout/worker.","format":"markdown","source":"ghsa"},{"lang":"es","text":"brace-expansion hasta la 5.0.6 es vulnerable a denegación de servicio. La función expand() presenta una complejidad de tiempo exponencial en el número de grupos de llaves ’{}’ consecutivos no expansibles. Un atacante que pasa una cadena manipulada a expand(), directa o transitivamente, puede causar un consumo significativo de CPU y el bloqueo del bucle de eventos. La opción max no mitiga esto, ya que limita el tamaño de la salida en lugar del trabajo de recursión.","source":"nvd"}],"published":"2026-06-30T08:30:34.502Z","modified":"2026-10-25T21:10:00.770Z","severity":{"scorer":"seal","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:P/S:N/AU:Y/R:U/V:D/RE:M/U:Amber","score":7.7,"rating":"HIGH"},"severities":[{"scorer":"seal","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:P/S:N/AU:Y/R:U/V:D/RE:M/U:Amber","score":7.7,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:P/S:N/AU:Y/R:U/V:D/RE:M/U:Amber","rating":"HIGH"}],"cwes":["CWE-400","CWE-407"],"affected":[{"ranges":[{"type":"semver","introduced":"0","lastAffected":"5.0.6","status":"affected"}],"vendor":"juliangruber","product":"brace-expansion","package":"brace-expansion","repo":"https://github.com/juliangruber/brace-expansion","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"3.0.0","status":"affected","fixed":"5.0.7"}],"ecosystem":"npm","package":"brace-expansion","purl":"pkg:npm/brace-expansion","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.1.16"}],"ecosystem":"npm","package":"brace-expansion","purl":"pkg:npm/brace-expansion","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"2.0.0","status":"affected","fixed":"2.1.2"}],"ecosystem":"npm","package":"brace-expansion","purl":"pkg:npm/brace-expansion","source":"ghsa"}],"references":[{"url":"https://github.com/juliangruber/brace-expansion/commit/c7e33ec13ac1a684c116720843ce24e208611754","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.npmjs.com/package/brace-expansion","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/juliangruber/brace-expansion/security/advisories/GHSA-3jxr-9vmj-r5cp","tags":["web"],"sources":["ghsa"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-13149","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/pull/122","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/pull/123","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/commit/835d6be91201122d9adffb0c0c8c094189ace265","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/commit/d74e63030c012e3b7ae81657b8d665619cd51b95","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/releases/tag/v1.1.16","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/releases/tag/v2.1.2","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/juliangruber/brace-expansion/releases/tag/v5.0.7","tags":["web"],"sources":["ghsa"]}],"credits":["bnbdr"],"assigner":"seal","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-06-30T12:43:12.568Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-13149","url":"https://www.cve.org/CVERecord?id=CVE-2026-13149","licence":"CVE Terms of Use","modified":"2026-07-08T11:38:35.974Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3jxr-9vmj-r5cp","url":"https://github.com/advisories/GHSA-3jxr-9vmj-r5cp","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:10.092Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-13149","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-13149","licence":"Public domain","modified":"2026-10-25T21:10:00.770Z"}],"updatedAt":"2026-11-25T22:59:26.674Z","epss":{"score":0.00364,"percentile":0.32252,"date":"2026-12-01T12:00:22.000Z"}}