{"id":"GHSA-c6wh-w8c3-cv3g","summary":"Glob: Absolute `ignore` pattern silently bypassed when `root`/`cwd` path contains braces","details":"### Summary\n\n`glob`'s `ignore` option composes an absolute ignore pattern by pasting the\nresolved `root`/`cwd` path into a glob *string*, then re-parsing that string\nwith `minimatch`. The path is escaped with `minimatch`'s `escape()`, but\n`escape()` only escapes `{` and `}` when `magicalBraces` is enabled — which\n`glob` does not do. A root path containing braces is therefore brace-expanded\nduring re-parsing, and the resulting ignore pattern no longer matches the real\npath. The exclusion is silently dropped and the excluded file is returned.\n\n### Root cause\n\n`src/ignore.ts:84-88`\n\n```ts\nconst slashRoot = cwd?.resolve(root ?? '/').fullpath() ?? '/'\nthis.slashRoot = escape(\n  slashRoot.replace(/\\\\/g, '/').replace(/\\/$/, ''),\n  { windowsPathsNoEscape },        // \u003c-- no `magicalBraces`\n)\n```\n\n`src/ignore.ts:121-125`\n\n```ts\nconst glob =\n  p.root() === '/' ?\n    `${this.slashRoot}/${p.rest()?.globString() ?? ''}`\n  : p.globString()\nconst m = new Minimatch(glob, this.mmopts)   // \u003c-- brace expansion happens here\n```\n\nThe composed string is parsed as a glob, so `{7,8}` becomes two alternatives.\n\n### Why this is a vulnerability and not a cosmetic issue\n\nThe `root` option exists precisely so that absolute patterns and absolute\nignore rules are anchored at a chosen directory. The two code paths handle\n`root` differently:\n\n| path | `root` handling | braces in root |\n|---|---|---|\n| pattern (`src/processor.ts`) | `t.resolve(this.opts.root)` — **path resolution** | works correctly |\n| ignore (`src/ignore.ts`) | pasted into a **glob string** | silently broken |\n\nSo the *pattern* still finds the file at the literal path, while the *ignore*\nrule that was supposed to exclude it stops matching. The caller asked for\n`ignore: ['/skip.log']` anchored at `root` and did not get it.\n\n### Impact\n\n`ignore` is routinely used to exclude secrets, credentials, lockfiles, build\nartifacts, or tenant-scoped paths. When the rule is dropped, those files are\nreturned to the caller instead.\n\nThe trigger is the *path*, not the ignore pattern, so it is reachable when the\nroot/cwd path is derived from externally supplied data (tenant id, project\nname, upload directory, archive extraction path).\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({\n  '/root{7,8}/keep.txt': 'x',\n  '/root{7,8}/skip.log': 'x',\n})\n\nconst res = await glob('*', {\n  cwd: '/root{7,8}',\n  root: '/root{7,8}',\n  fs,\n  ignore: ['/skip.log'],\n  platform: 'posix',\n})\n\nconsole.log(res)   // [ 'keep.txt', 'skip.log' ]  \u003c-- skip.log should be ignored\n```\n\nControl with a plain root path:\n\n```js\nvol.fromJSON({ '/root/keep.txt': 'x', '/root/skip.log': 'x' })\nawait glob('*', {\n  cwd: '/root', root: '/root', fs, ignore: ['/skip.log'], platform: 'posix',\n})\n// [ 'keep.txt' ]  \u003c-- ignore correctly enforced\n```\n\n### Mechanism proof\n\n```js\nconst { Ignore } = await import('glob')\nconst { PathScurryPosix } = await import('path-scurry')\n\nconst ig = new Ignore(['/skip.log'], { platform: 'posix', root: '/root{7,8}' }, scurry.cwd)\nig.slashRoot                    // \"/root{7,8}\"\nig.absolute[0].set              // [['', 'root7', 'skip.log'], ['', 'root8', 'skip.log']]\nig.absolute[0].match('/root{7,8}/skip.log')  // false  \u003c-- the real path\nig.absolute[0].match('/root7/skip.log')      // true   \u003c-- a path that does not exist\n```\n\n## Fix\n\nBoth issues are 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\n`[['', 'root{7,8}', 'skip.log']]` (one row, literal), matches\n`/root{7,8}/skip.log`, and the amplified ignore payload is rejected with the\nsame error as the pattern path.\n\nRegression tests are in `test/ignore-braces.ts`; they fail against the\nunpatched source and pass with the patch. The existing suite\n(`test/ignore.ts`, `test/custom-ignore.ts`, `test/ignore-root.ts`,\n`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. Fixed in: 14.0.6\n\n### Related hardening (same file)\n`src/ignore.ts:71-83` builds `mmopts` without `braceExpandMax`, while the pattern path sets `braceExpandMax: 10_000` (`src/glob.ts:528`). Ignore patterns therefore fall back to minimatch's 100_000 default. The patch above already includes this one-line change.","aliases":["CVE-2026-144291"],"modified":"2026-12-05T18:45:14.595975674Z","published":"2026-12-04T21:47:55Z","database_specific":{"cwe_ids":["CWE-20","CWE-693"],"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-12-04T21:47:55Z","nvd_published_at":"2026-12-03T17:18:11Z"},"references":[{"type":"WEB","url":"https://github.com/isaacs/node-glob/security/advisories/GHSA-c6wh-w8c3-cv3g"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-144291"},{"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":"0"},{"fixed":"14.0.6"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 14.0.5","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-c6wh-w8c3-cv3g/GHSA-c6wh-w8c3-cv3g.json"}}],"schema_version":"1.9.3","severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:H/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N"}]}