Skip to content

fix: enforce bounded ambiguity checks for repeated extglobs - #261

Closed
diegomors wants to merge 3 commits into
micromatch:masterfrom
diegomors:fix/mandatory-safe-repeated-extglobs
Closed

diegomors wants to merge 3 commits into
micromatch:masterfrom
diegomors:fix/mandatory-safe-repeated-extglobs

Conversation

@diegomors

@diegomors diegomors commented Nov 17, 2026 •

Copy link
Copy Markdown

Repeated extglobs can still compile nested or overlapping unbounded quantifiers in 4.0.7. The existing raw-text checks miss single wildcard branches, normalized alternatives, case folding and configurations that disable the recursion heuristic. Wrapping a validated extglob in raw or escaped/counting quantifiers also reintroduces the issue.

This change applies a mandatory, bounded ambiguity check to the generated token output. A position automaton retains nullable-path multiplicity and parallel edges; a square automaton detects distinct accepting paths. Character classes conservatively cover later ignore-case flag changes. Assertions are bounded and checked before overapproximation, and proof limits fail closed. Final rendered output is checked again when raw operators, nobrace or unescape can wrap an extglob.

Single-character alternatives become one class. A proven single-star ASCII branch absorbs repeated copies; capture-dependent and Bash dot-segment cases are excluded from that rewrite. Ordinary and safely delimited nested extglobs remain supported. Existing literalization remains where applicable; other ambiguous or unproven repetitions now raise SyntaxError, even with maxExtglobRecursion: false. README documents this compatibility change and the trusted raw-RegExp API boundary.

Validation: npm test passes lint and 2,009 tests. Added isolated-process deadlines, advisory and alternate encodings, arrays/ignore/posix/direct parser entry points, parsed-state flag changes, counted/escaped wrapping quantifiers, captures, unanchored match spans, resource limits and short-input language comparisons. Existing unsafe-pattern expectations were changed to explicit error assertions; no tests were skipped.

Addresses CVE-2026-112366 / GHSA-fc5q-39xc-vjpf. Related proposals: #237, #238, #246 and #254. This is a proposed correction, not a claim that an official patched release already exists.

@DaleMckeown

Copy link
Copy Markdown

See #235 (comment).

@msalaheldincontractor-wsl

Copy link
Copy Markdown

Reviewed from the diff; I did not run this branch. For reference, on master (9fab7bf, Node 22) each of +(*), +(*a), *(*), *(*a), +(*)a and the two-branch +(*a|*b) takes more than 3 s for isMatch('a'.repeat(28) + '/', pattern).

  • For repeated extglobs that aren't collapsed and fail hasSafeRepetition, this now throws SyntaxError('Unsafe repeated extglob (CVE-2026-112366)'). Several existing tests change from match assertions to assert.throws. For example, isMatch('bar', '*(!(foo))', { bash: true, windows: true }) was true and now throws.
  • Throwing where matching used to work is a breaking change for callers that evaluate globs from user config (watchers, linters, bundlers), so it seems more like a major-version change than a patch for the CVE. A rewrite that keeps the meaning (e.g. the star-led collapse in fix: drop redundant repetition from star-led repeated extglobs #257) would fix the advisory's patterns without changing existing results.

@G-Rath

G-Rath commented Nov 18, 2026

Copy link
Copy Markdown

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.

@diegomors

Copy link
Copy Markdown
Author

Thanks for the clarification and for following up on the advisory. GHSA-fc5q-39xc-vjpf is now marked withdrawn because this behavior is not a security issue. We had treated the advisory as valid and proposed a compatibility-breaking workaround; we are reverting that downstream workaround and restoring the upstream picomatch package. I’m closing this PR as unnecessary. Apologies for the noise, and thank you for the review and clarification.

@diegomors diegomors closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants