Skip to content

fix: guard repeated wildcard extglobs and repeated-word alternatives - #258

Closed
lailavinson wants to merge 2 commits into
micromatch:masterfrom
lailavinson:codex/rd-3967-repeated-extglob-fix
Closed

lailavinson wants to merge 2 commits into
micromatch:masterfrom
lailavinson:codex/rd-3967-repeated-extglob-fix

Conversation

@lailavinson

@lailavinson lailavinson commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes excessive CPU use when matching repeated extglobs (GHSA-fc5q-39xc-vjpf). The parser simplifies redundant wildcard repetitions and extends its safeguard to repeated words. Patched commit

Some complex patterns now match literally. For simplified patterns, callers using captures can receive a different substring even when the overall match is the same.

All 2,006 upstream tests pass locally on Node 22.16.0. Related PRs include #175 and #194.

@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).

  • The single simple-wildcard collapse covers +(*), +(*a), *(*), *(*a) and +(*)a.
  • A wildcard in a multi-branch body (or a non-simple branch) is marked risky with no safeOutput, so extglobClose emits it as literal text: +(*a|*b) would match only the string +(*a|*b).
  • hasRepeatedWordOverlap (a + b === b + a) also widens the existing check from repeated single characters to any commuting words, so e.g. +(ab|abab) would now become literal text as well. That one is genuinely backtracking-prone, but the change in meaning might deserve a test and a note.

@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.

@lailavinson

Copy link
Copy Markdown
Author

Thank you for the review and the context! Will maintain a separate fork for now as I take that comment to mean this type of issue is not in scope for this repo, closing this

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