Repository navigation
fix: literalize single-branch extglobs with a leading bare quantifier (CVE-2026-112366) - #238
Conversation
…CVE-2026-112366) analyzeRepeatedExtglob only flagged a repeated extglob (+(...)/*(...)) as risky when the body had multiple branches, or when a branch was itself a fully parenthesized nested extglob. A single branch that starts with a bare (non-parenthesized) * or ? followed by more content, e.g. the *a in +(*a), slipped through both checks and compiled to a nested-quantifier regex (e.g. (?:[^/]*?a)+) that is prone to catastrophic backtracking. Add hasUnsafeLeadingQuantifier to catch this shape and literalize it like the other risky cases. The check is scoped to a *leading* bare quantifier with trailing content, so it doesn't affect patterns where the quantifier has nothing after it (+(*)) or is anchored by a literal prefix (+(a*), *(W*, *)), which are not ambiguous in the same way and already have test coverage relying on them working as normal globs.
|
Hi, thanks for the work on this fix! Just adding some context on impact: CVE-2026-112366 (CVSS 8.7) is currently being flagged by corporate SCA scanners (Checkmarx in our case) and is blocking CI pipelines. picomatch 4.x is pulled in transitively by very common tooling like Vite and typescript-eslint, so many projects are affected and can't resolve it on their side until a patched version is on npm. Is there an expected timeline for merging this PR and publishing a release (e.g. 4.0.8)? If there's anything blocking it, such as review, tests or edge cases, I'm happy to help test the branch against real projects. Thanks again! |
Hi, thanks for the context and for offering to help test, it's much appreciated! I'm not a maintainer, so I can't commit to a merge or release date. The PR is waiting on review from the maintainers. I'll keep it up to date and address any feedback quickly. In the meantime, testing the branch against a real project would help. If you can try it with your Vite / typescript-eslint setup and share the results here (pass/fail and your Node version), that gives the maintainers more confidence to merge. @doowb @jonschlinkert As a temporary workaround while waiting for a release, you could pin the transitive dependency with overrides (npm), resolutions (yarn) or pnpm.overrides, once a patched version is available. Thanks again! |
|
when this fix will be published ? |
Hey, have you seen "235 (comment)"? I think this PR might not be accepted, do you agree with the comment from the maintainer? |
I understand the concern, but this is a real problem for downstream users: SCA tools like Checkmarx flag picomatch 4.x because of this CVE, and that blocks CI pipelines in many projects, since it's pulled in transitively by Vite, typescript-eslint, etc. If the maintainers believe the CVE doesn't apply (e.g. it's a false positive or the impact is overstated), could that be stated officially? For example, by disputing the advisory on GitHub/NVD so scanners stop flagging it. If it is valid, then a patched release would be the fix. Either way, some clarity from the maintainers would really help. Thanks! |
|
Since the maintainer hasn't responded, I came up with a workaround (not the most elegant): I published the library to our private npm registry and pinned it via a forced override. With this, the Checkmarx scan now passes with no findings. |
|
Just chiming in -- this is breaking our CI as well. If this PR isn't the solution, is another patch in the works? |
|
Tons of CIs failing downstream because of this - Github still stating it's necessary at GHSA-fc5q-39xc-vjpf @0x00-sys @fal3n-4ngel you are both listed as Credits on this one. Can you help out? They are saying this advisory as revoked as per https://security.snyk.io/vuln/SNYK-JS-PICOMATCH-21248802 |
jonymusky
left a comment
There was a problem hiding this comment.
Tested this locally against master (Node 26, isMatch timing on inputs like 'a'.repeat(n) + '/').
Fixed by this PR: +(*a), *(*a), +(**a), +(*[ab]), +(*a)x and +(a|*a) are now literalized and return instantly (+(a|*a) took ~60 s at n=24 on master). Full suite passes (2000 tests).
Still exponential with this PR:
| pattern | n=24 | n=26 | n=28 |
|---|---|---|---|
+(*) |
203 ms | 782 ms | 3063 ms |
*(*) |
75 ms | 309 ms | 1216 ms |
+(a*) |
— | ~1970 ms | — |
+(*) is one of the two examples in the advisory text (GHSA-fc5q-39xc-vjpf), so I don't think this closes CVE-2026-112366 on its own. They compile to (?:[^/]*?)+ and (?:a[^/]*?)+, which are the same nested-quantifier shape as (?:[^/]*?a)+. The new test should preserve non-risky leading/trailing quantifiers by default currently asserts the vulnerable behaviour for +(*) and +(a*).
A suggestion: treat any single branch that contains an unanchored bare */? (leading or trailing) as risky. Alternatively, collapse +(*)/*(*) to plain *, since they are semantically equivalent within a segment.
Repro script:
const pm = require('picomatch');
for (const p of ['+(*)', '*(*)', '+(a*)'])
for (const n of [24, 26, 28]) {
const t = Date.now(); pm.isMatch('a'.repeat(n) + '/', p);
console.log(p, n, Date.now() - t, 'ms');
}
gbanis
left a comment
There was a problem hiding this comment.
We are blocked by this too. Would be great to prioritize this because it seems like there's no version we can fall back to.
|
Reviewed from the diff; I did not run this branch. For reference, on master (9fab7bf, Node 22) each of
|
kleversonglauberandritz
left a comment
There was a problem hiding this comment.
Independent confirmation of the remaining ReDoS case reported in this PR.
In an isolated local test of [email protected] against PR #238 head 44f19226, with an 8-second timeout per subprocess, we observed:
The patch addresses +(*a), but +(*) remains vulnerable. Since +(*) is explicitly mentioned in GHSA-fc5q-39xc-vjpf, the current patch does not appear to fully resolve the advisory.
Thank you for working on this fix.
|
hey, just to clear this up: i didn't find or report this one. my credit on the advisory is only for adding the npm package name + affected range to the github entry (github/advisory-database#10475), so i can't withdraw it or change the score myself, that's up to github and the CNA (VulnCheck). fwiw the slowdown does reproduce on 4.0.7, but only if someone untrusted controls the glob pattern itself, not the path being matched. if your globs come from your own config you're not really exposed, so ignoring GHSA-fc5q-39xc-vjpf in your scanner is reasonable until this gets sorted. snyk already revoked theirs, the CVE itself is still published. i've also suggested lowering the severity to moderate on the github advisory since it needs a user-controlled pattern: github/advisory-database#11397. no guarantee they take it, but that's where it is now. |
Hey @bradleyseanf, From my side, I only added the missing npm package to the advisory. I wasn't the one who originally reported it, nor do I have the ability to remove or revoke it. I was facing the same issue with Fortify reporting this vulnerability across our apps as well. However, it looks like it was removed from Fortify few weeks ago. Hopefully, the other channels will do the same when the source National Vulnerability Database updates / revokes it |
|
Both GitHub and VulnCheck have withdrawn this advisory, as it is not a security issue. If a tool is still reporting you're "vulnerable", then you need to contact the tool author about getting their source updated. |
|
Friendly ping for the maintainers: this PR has been open since 2026-10-22 and is mergeable, and the advisory (GHSA-fc5q-39xc-vjpf / CVE-2026-112366) is still unpatched in the latest release (4.0.7, published 2026-08-24). The impact reaches beyond direct users, because picomatch is also pulled in transitively (e.g. via tinyglobby/node-gyp bundled with npm), so downstream projects and container images keep getting flagged by scanners and can't fix it on their side without a release. Could someone take a look at this PR (or one of the other open fixes, e.g. #237 / #246) and cut a patched release? Thanks for maintaining the project. |
|
@yaoweiprc the advisory has been withdrawn |
|
Even if this is no longer a CVE, is the fix still a good idea? |
Summary
Fixes CVE-2026-112366: a ReDoS vulnerability in repeated extglob parsing.
analyzeRepeatedExtglob(the function that decides whether a+(...)/*(...)extglob is safe to compile as-is, or must be literalized) only flagged a pattern as risky when:branches.length > 1), or*(...)) that it could reduce or whose recursion depth it could count.A single-branch body that starts with a bare (non-parenthesized)
*or?followed by more content — e.g. the*ain+(*a)— fell through both checks. It compiled straight through to a nested-quantifier regex ((?:[^/]*?a)+), which is prone to catastrophic backtracking: matching it against a short crafted string (e.g. manyas with no trailinga) blocks the event loop.Fix
Adds
hasUnsafeLeadingQuantifierinlib/parse.js, called alongside the existing recursion-depth check insideanalyzeRepeatedExtglob's per-branch loop. It flags a branch as risky when it starts with a run of bare*/?quantifier characters that is followed by further content, since there's no fixed prefix anchoring where the quantifier ends.The check is intentionally scoped narrowly, to avoid regressing existing, already-tested behavior:
+(*)) is left alone — it's not ambiguous in the same way, and is already covered by an existing test (should preserve non-risky extglobs by default).+(a*), or a quantifier appearing later in the branch behind other content, as in the existing*(W*, *)test intest/special-characters.js) is left alone — the literal prefix removes the ambiguity, and this shape was already relied upon by existing tests.*(...)/?(...)nested extglob group opener is not treated as a bare quantifier; its own contents continue to be analyzed separately by the existing recursion/char-class-reduction logic above.Testing
test/options.maxExtglobRecursion.js:+(*a),*(*a), and+(a|*a)are literalized and no longer match a long crafted string that would trigger backtracking.+(*)and+(a*)continue to work as normal globs (no regression).npm run mocha) — all 1998 pre-existing tests pass, plus the 2 new ones (2000 total).Known limitation
A non-reducible nested extglob group followed by trailing content in the same branch (e.g.
+(*(ab)c)) is a structurally similar shape that is not covered by this patch, since it wasn't part of the originally reported CVE and widening the check further risked more false positives without being able to verify the exact backtracking behavior empirically. Flagging it, if desired, would need a separate, carefully-scoped follow-up.