Repository navigation
Conversation
…ne pass A `*` wildcard inside `+(...)` or `*(...)` nests one unbounded quantifier in another: `+(*a)` compiled to `(?:[^/]*?a)+`, which backtracks exponentially on a short string that does not match (GHSA-fc5q-39xc-vjpf, CVE-2026-112366). analyzeRepeatedExtglob only looked at bodies with more than one branch, so these were never flagged. When the single branch holds nothing but literal characters, `?` and at least one `*`, the repetition adds no strings: two matches side by side are again one match, because the star of the first takes everything up to the last literal of the second. Such a body is now compiled once, `+(X)` as `(?:X)` and `*(X)` as `(?:X)?`, so every pattern that matched before still matches the same strings. A single branch that mixes a wildcard star with a slash, a bracket, a brace or a nested group cannot be collapsed that way and is matched as literal text, like the other risky repeated extglobs. `maxExtglobRecursion: false` keeps the old output.
|
This fix is now adopted and shipped in production by the @webomage fork: https://github.com/webomage/picomatch (branch Verified here against the ReDoS PoC from GHSA-fc5q-39xc-vjpf (CVSS 8.7): |
|
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. |
|
A correction on scope, since this branch is now shipped: the webomage fork's tag This PR fixes 4 of the 13 extglob forms I found that backtrack without bound, and matches the same strings for those 4. A fifth,
I am not extending this PR one shape at a time: each change of this kind rewrites one regex shape, and the table shows the shapes outnumber the rewrites. #278 takes a different route, bounding |
|
Closing in favor of #278, which handles these forms and more without changing what any glob matches in the tests. This PR changes |
For GHSA-fc5q-39xc-vjpf (CVE-2026-112366). I know there are other pull requests open for it. This one keeps the matching: no existing test changes, and a pattern such as
+(*)cor+(*.js)matches the same strings as before.The problem
A
*wildcard inside+(...)or*(...)nests one unbounded quantifier in another.+(*a)compiles to(?:[^/]*?a)+, which backtracks exponentially on a short string that does not match.analyzeRepeatedExtglobonly looks at bodies with more than one branch, so a single branch is never flagged.What changes
?and at least one*is compiled once.+(X)becomes(?:X)and*(X)becomes(?:X)?. For such a body the repetition adds no strings: two matches side by side are again one match, because the star of the first takes everything up to the last literal of the second. Nothing in the body can match a slash, so that holds in any position.+(a|aa)and+(*|?)already are. This is the one change in behavior:+(a/*)was a working glob and is now literal.*that opens a nested*(...)is not a wildcard and stays with the star sequence rewrite:+(*(a))is stilla*.maxExtglobRecursion: falsekeeps the old output.Both changes are in
lib/parse.js: a classifier next toanalyzeRepeatedExtglob, and three lines inextglobClosethat pick the closing quantifier.Proof
One
isMatchof n lettersaand ab, in ms, Node 24 on Windows:+(*a)+(*a)*(*a)*(*a)npm run mochaon masternpm run mochaon this branchlib/parse.js*(X)closed with)where)?belongsnpm run linta b . / x)mutationWhat it does not do
+(a|*a)still takes 179 ms for 16 letters and 8370 ms for 20 on this branch, as on master. The advisory is about the single branch, and a rewrite that keeps the meaning of several branches is a larger change than this one.