CVE-2026-140006: minimatch.escape() output matches more or less than the literal input
Affects minimatchSource GCVE Database
Not known to be exploited · CVSS 5.4 Medium : upgrade to 11.0.8 when convenient.
Data as of 1 Dec 2026, 19:00 UTC
Thin evidence
One scorer or none| CNA (GitHub_M) | CVSS 3.1 | 5.4 |
|---|
- Patch
- Available – fixed in 11.0.8
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:NExploitation evidence
Disclosed: evidence found.
CVE published 30 Nov 2026
Detectable: no evidence on record.
No public nuclei template indexed
Weaponized: no evidence on record.
No public exploit code indexed in Metasploit or Exploit-DB
Exploited in the wildExploited: no evidence on record.
Not in CISA KEV and no source reports exploitation
Observed by OffSeq MirageSeen by Mirage: no evidence on record.
No attack traffic recorded by OffSeq Mirage sensors
A missing step is not evidence of safety. Sources: cve.org (opens in a new tab), the Metasploit, Exploit-DB and nuclei-templates index as of 1 Dec 2026.
What to do
Upgrade minimatch to 11.0.8.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| npmminimatch | Affected
| Fixed in
|
Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.
Description
### Summary `minimatch.escape()` is documented to "Escape all magic characters in a glob pattern, so that it will only ever match literal strings." (README, section `minimatch.escape(pattern, options = {})`). In minimatch 11.0.5 (latest release; `main` is at the `v11.0.5` tag, commit `ea0a4a6`) four classes of input break that contract: 1. A leading `!` is left unescaped. `escape('!secret.txt')` returns `'!secret.txt'`, which is a negated pattern. It matches every path except `secret.txt`, for example `passwd`. This holds in POSIX mode and in `windowsPathsNoEscape` mode. 2. A leading `#` is left unescaped. `escape('#notes.md')` returns `'#notes.md'`, which is a comment pattern. It matches nothing, including `#notes.md`. This holds in both modes. 3. An escaped backslash does not survive brace expansion. For the user text `x\*` (x, backslash, star), `escape()` returns `x\\\*`. Alone, that pattern matches only the literal. When the pattern also contains a brace group, brace-expansion turns `\\` back into a single `\`, so the `*` becomes a live wildcard. The brace group can come from the caller (`escape(u) + '.{js,ts}'`) or, with default options, from the user text itself (`escape('x\\*{,}')`). 4. With `{ windowsPathsNoEscape: true, magicalBraces: true }`, `escape('x{a,b}')` returns `x[{]a,b[}]`. Brace-expansion does not know `[...]` classes and expands it to `x[]a]` and `x[b[]`. The pattern matches `xa` and does not match `x{a,b}`. The README documents negation and comments for patterns in general (README lines 484-493). The `escape()` section does not mention them, and its contract ("only ever match literal strings") is what callers rely on. The README warns that building a matcher from untrusted user patterns is unsafe. `escape()` is the documented way to make text match only as a literal (README.md:213-214), which is how callers embed untrusted text. These cases are inside that boundary. Behaviors 1 and 3 widen a match (fail open for an allowlist). Behavior 2 empties a match (fail open for a denylist or ignore list). Behavior 4 does both. ### Details All line numbers refer to tag `v11.0.5`. brace-expansion line numbers refer to brace-expansion 5.0.12, the version installed under `^5.0.12` at test time, file `dist/commonjs/index.js`. **Behavior 1: leading `!`.** - `src/escape.ts:22-24`: the comment states that `!` needs no escaping because the parens that make extglobs magic are escaped. That is true for `!(...)`. It ignores pattern-level negation. - `src/escape.ts:25-32`: none of the four branches escapes `!`. They escape `?*()[]`, plus `\` in POSIX mode and `{}` with `magicalBraces`. A leading `!` passes through. - `src/index.ts:1360-1374` (`parseNegate`, called from `make()` at `src/index.ts:730`): every leading `!` toggles `this.negate` and is stripped. `match()` then inverts the result. - `\!` is already a supported way to write a literal `!`. `test/patterns.js:260` has the entry `['!\\!a*', ['a!b', 'd', 'e', '\\!a']]`, which excludes `!ab` and `!abc`. The POSIX part of the fix uses that existing syntax, and `unescape()` already reverses it. - `test/escape-has-magic.js` checks the `unescape()` round trip and `hasMagic() === false` for every entry in `test/patterns.js`. That list includes `'!a*'` (line 251), `'!\\!a*'` (line 260) and `'# ignore this'` (line 327). The test never checks `negate` or `comment`. A negated literal pattern reports `hasMagic() === false`, so the suite passes. Measured on 11.0.5 with the port described under Suggested fix: 811 of 811 upstream assertions pass, and 6 of 784 added `negate`/`comment` assertions fail (`'!a*'`, `'!\\!a*'` and `'# ignore this'`, each in POSIX and Windows mode). **Behavior 2: leading `#`.** - `src/escape.ts:25-32`: no branch handles `#`. - `src/index.ts:118-120` (`minimatch()` shortcut) and `src/index.ts:719-722` (`make()`): a pattern whose first character is `#` is a comment. `minimatch()` returns `false` and `Minimatch` builds an empty set. **Behavior 3: escaped backslash collapsed by brace expansion.** - `src/escape.ts:28` and `src/escape.ts:32`: a literal `\` is escaped as `\\` and a literal `*` as `\*`. The user text `x\*` becomes `x\\\*`. - `src/index.ts:733` calls `#expandBraces()`, which reaches `braceExpand()` at `src/index.ts:243-257`. When the pattern contains any `{...}` group, `src/index.ts:256` passes the whole pattern to brace-expansion `expand()`. - brace-expansion `index.js:16` (`slashPattern = /\\\\/g`) and `index.js:54-61` (`escapeBraces`) replace each `\\` pair with a sentinel. `index.js:62-69` (`unescapeBraces`, applied to every result at `index.js:125`) turns that sentinel into one `\` (line 64). `x\\\*.{js,ts}` therefore expands to `x\\*.js` and `x\\*.ts`. In minimatch syntax that is an escaped backslash followed by a live `*`. - With default options, `escape()` leaves `{` and `}` as they are (see the related note below). The user text can then supply the brace group, and the caller appends nothing: `escape('x\\*{,}')` retu