minimatch: Proto Key Bypasses Cache-Key Weighting in minimatch's Shared Matcher Cache
Package Affected versions Patched versions Description Summary minimatch's module-global matcher cache can be poisoned by a __proto__ key in the options object passed to minimatch(). optionsKey() scor
Package
minimatch (npm)Affected versions
>= 11.0.6, <= 11.0.9Patched versions
11.0.10Description
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: NO
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.
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
}
References
Severity
Low CVSS overall score This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS). / 10CVSS v3 base metrics
Attack vector Network Attack complexity High Privileges required None User interaction None Scope Unchanged Confidentiality None Integrity Low Availability None CVSS v3 base metrics Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability. Attack complexity: More severe for the least complex attacks. Privileges required: More severe if no privileges are required. User interaction: More severe when no user interaction is required. Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope. Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user. Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user. Availability: More severe when the loss of impacted component availability is highest. CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:NEPSS score
Exploit Prediction Scoring System (EPSS) This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST. (49th percentile)Weaknesses
Weakness CWE-1321Improperly Controlled Modification of Object Prototype Attributes
The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. Learn more on MITRE.CVE ID
CVE-2026-141514GHSA ID
GHSA-3924-r96c-gp9wSource code
isaacs/minimatchCredits
-
waydeshi Reporter
Uh oh!
There was an error while loading. Please reload this page.
See something to contribute? Suggest improvements for this vulnerability.