{"id":"GHSA-qxr8-q827-836c","summary":"Glob : `ignore` patterns lack the braceExpandMax limit applied to `pattern`","details":"`glob` sets `braceExpandMax: 10_000` when it parses *pattern* patterns, but the `Ignore` class builds its own `minimatch` options and omits `braceExpandMax` entirely, so ignore patterns fall back to minimatch's default of `100_000`. Both paths force `optimizationLevel: 2`, which is the exact precondition for minimatch's globparts amplification (CVE-2026-118764, GHSA-g3hv-75wg-m249) — minimatch's own default is `1`.\n\nThe consequence is that the same payload is rejected in milliseconds when passed as a pattern, but is accepted and burns far more CPU when passed as an ignore pattern.\n\n### Root cause\n\n`src/glob.ts:527-529` — pattern path, limit present:\n\n```ts\nconst mmo: MinimatchOptions = {\n  braceExpandMax: 10_000,\n  ...opts,\n```\n\n`src/ignore.ts:71-83` — ignore path, limit missing:\n\n```ts\nthis.mmopts = {\n  dot: true,\n  nobrace,\n  nocase,\n  noext,\n  noglobstar,\n  normalize,\n  optimizationLevel: 2,     // forced, and the amplification precondition\n  platform,\n  nocomment: true,\n  nonegate: true,\n  windowsPathsNoEscape,\n}                            // \u003c-- no braceExpandMax\n```\n\nminimatch `\u003e= 11.0.1` fixed CVE-2026-118764 by throwing a `RangeError` once `globParts.length \u003e= braceExpandMax`. The pattern path caps rows at `10_000`; the ignore path allows `100_000`. The amplified rows then go through minimatch's `secondPhasePreProcess()`, which is O(n²) pairwise `partsMatch`.\n\n### Reproduction\n\n```js\nimport { Volume, createFsFromVolume } from 'memfs'\nimport { glob } from 'glob'\n\nconst vol = new Volume()\nconst fs = createFsFromVolume(vol)\nvol.fromJSON({ '/p/f.txt': 'x' })\n\n// 14 '**/..' groups -\u003e 2^14 = 16384 rows, over the 10_000 limit\nconst payload = Array.from({ length: 14 })\n  .map((_, i) =\u003e `**/../x${i}/y${i}`)\n  .join('/')\n\nglob.sync(payload, { cwd: '/p', fs, platform: 'posix' })\n// throws: optimizationLevel 2: too many patterns from '**/..'   (rejected fast)\n\nglob.sync('*', { cwd: '/p', fs, ignore: [payload], platform: 'posix' })\n// accepted, ~1.5-2.0 s of CPU\n```\n\nMeasured on the published `glob@14.0.4`:\n\n```\npayload: 175 bytes\n  as PATTERN :      6 ms  REJECTED (optimizationLevel 2: too many patterns from '**/..)\n  as IGNORE  :   1985 ms  accepted\n```\n\n### Impact\n\nAn attacker who can influence ignore patterns can force disproportionate CPU consumption on the event loop.\n\n## Fix\n\nIssue is in `src/ignore.ts`. A minimal change closes them:\n\n```diff\n     this.mmopts = {\n+      braceExpandMax: 10_000,\n       dot: true,\n       nobrace,\n       nocase,\n@@\n     this.slashRoot = escape(\n       slashRoot.replace(/\\\\/g, '/').replace(/\\/$/, ''),\n-      { windowsPathsNoEscape },\n+      { magicalBraces: true, windowsPathsNoEscape },\n     )\n```\n\n- `magicalBraces: true` makes `escape()` escape `{` and `}` as well, so the\n  composed path stays literal and is not brace-expanded on re-parse.\n- `braceExpandMax: 10_000` makes the ignore path use the same limit as the\n  pattern path.\n\nVerified: with this patch the ignore matcher becomes `[['', 'root{7,8}', 'skip.log']]` (one row, literal), matches `/root{7,8}/skip.log`, and the amplified ignore payload is rejected with the same error as the pattern path.\n\nRegression tests are in `test/ignore-braces.ts`; they fail against the unpatched source and pass with the patch. The existing suite (`test/ignore.ts`, `test/custom-ignore.ts`, `test/ignore-root.ts`, `test/pattern.ts`, `test/root.ts`, `test/absolute.ts`) remains green: 167/167.\n\nTested on published `glob@14.0.4` (current HEAD f26bdac). Earlier versions not checked.","aliases":["CVE-2026-137196"],"modified":"2026-12-01T01:45:03.942946080Z","published":"2026-12-01T01:39:39Z","database_specific":{"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-12-01T01:39:39Z","nvd_published_at":"2026-11-30T21:17:25Z","cwe_ids":["CWE-400","CWE-405","CWE-770"]},"references":[{"type":"WEB","url":"https://github.com/isaacs/node-glob/security/advisories/GHSA-qxr8-q827-836c"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-137196"},{"type":"WEB","url":"https://github.com/isaacs/node-glob/commit/17cb20749bc65a64ec44d40de2736cc587564866"},{"type":"PACKAGE","url":"https://github.com/isaacs/node-glob"},{"type":"WEB","url":"https://github.com/isaacs/node-glob/releases/tag/v14.0.6"}],"affected":[{"package":{"name":"glob","ecosystem":"npm","purl":"pkg:npm/glob"},"ranges":[{"type":"SEMVER","events":[{"introduced":"13.0.5"},{"fixed":"14.0.6"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-qxr8-q827-836c/GHSA-qxr8-q827-836c.json","last_known_affected_version_range":"\u003c= 14.0.5"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"}]}