minimatch: Proto Key Bypasses Cache-Key Weighting in minimatch's Shared Matcher Cache
Published 4 Dec 2026 · Updated 5 Dec 2026
Affected package
- Affected
- >=11.0.6 <11.0.10
- Fixed in
- 11.0.10
npm install minimatch@11.0.10Which minimatch does your project really install?
Works for private projects: the file is read in memory to run the scan and then dropped. Also reads yarn.lock, pnpm-lock.yaml or package.json.
Public repo?
Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Details
Summary
minimatch'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.
Details
src/index.ts:229-234, optionsKey() has no case '__proto__', so it falls through to default and contributes weight 0:
const optionsKey = (o: MinimatchOptions): number | string => {
for (const k in o) {
switch (k) {
// ... no 'case "__proto__":' branch ...
default:
n += (booleanWeights.get(k) ?? 0) * tri(v)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:
const copyOptions = (o?: MinimatchOptions) => {
const copy: Record<string, unknown> = {}
for (const k in o) copy[k] = (o as Record<string, unknown>)[k]
return copy as MinimatchOptions
}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.
Proof of concept
import { minimatch } from 'minimatch'
const smuggled = JSON.parse('{"__proto__":{"nocase":true}}')
// attacker's own call — nocase takes effect for them
const r1 = minimatch(file, patternLower, smuggled)
...Then, with no knowledge of the call above, a second, fully-trusted caller matches the same pattern with zero options:
// SEPARATE caller, SAME pattern string, DEFAULT options const r2 = minimatch(file, patternLower)
Result
minimatch("FOO-....TXT", "foo-....txt", smuggled) = true
minimatch("FOO-....TXT", "foo-....txt") [no options] = true (expected false)
minimatch(<untouched UPPER>, <untouched lower pattern>) [no options] = false (expected false)
cache-poisoned: true
global Object.prototype polluted: NOr2 = 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.
Impact
Any 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.
Suggested Fix
// copyOptions(): never let __proto__ become the copy's own prototype
const copyOptions = (o?: MinimatchOptions) => {
const copy = Object.create(null) as Record<string, unknown>
for (const k in o) if (k !== '__proto__') copy[k] = (o as Record<string, unknown>)[k]
return copy as MinimatchOptions
}Is GHSA-3924-r96c-gp9w in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected minimatch, and gives you the command that fixes it.
More advisories for minimatch
- MediumCVE-2026-140006minimatch: minimatch.escape() output matches more or less than the literal input · 1 Dec 2026
- MediumCVE-2026-140007minimatch: Global pattern cache retains large expansions, enabling memory exhaustion · 1 Dec 2026
- HighCVE-2026-140008minimatch: Quadratic compile time for long wildcard patterns (regression in 11.0.0 `mergeRows`) · 1 Dec 2026
- MediumCVE-2026-118764minimatch has potential denial of service via globparts amplification · 30 Oct 2026
- HighCVE-2026-27903minimatch has ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments · 26 Feb 2026
- HighCVE-2026-27904minimatch ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions · 26 Feb 2026
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.