Skip to content

fix: flatten single-branch wildcard repetition to avoid ReDoS - #254

Open
handeyman wants to merge 1 commit into
micromatch:masterfrom
handeyman:fix/single-wildcard-extglob-redos
Open

handeyman wants to merge 1 commit into
micromatch:masterfrom
handeyman:fix/single-wildcard-extglob-redos

Conversation

@handeyman

Copy link
Copy Markdown

Problem

GHSA-fc5q-39xc-vjpf describes nested unbounded repetition in single-branch extglobs such as +(*a). The current guard handles ambiguous alternatives and nested extglobs, but ordinary wildcard tokens still produce nested quantifiers.

Fix

For a single branch containing wildcard stars and only fixed-width text/qmark/bracket tokens, collapse the outer + repeat to one occurrence, or the outer * repeat to an optional occurrence. The branch language is closed under concatenation: earlier repetitions can be absorbed by a wildcard star. Preserve the already-parsed body, leading guard, escaping, path options and outer capture. Alternatives, slash/globstar/nested constructs, existing safety rewrites and explicit maxExtglobRecursion=false are unchanged. With capture:true the wildcard capture now covers the flattened body rather than the last repeat iteration; outer capture remains the full match.

Verification

  • Reproduced an unpatched +(*a) failing input exceeding an isolated 1-second deadline; patched version completes immediately.
  • npm test: lint and all 2001 upstream tests pass.
  • New hostile-input child-process deadlines and matching/escaping/capture cases.
  • 22860 short-input true/false parity checks against npm 4.0.7 across default, dot, capture, Windows and bash options.

No application code, private data or credentials included. Offered as a focused patch for maintainer review, not a claim of an official published fix.

@tianhuil

tianhuil commented Nov 17, 2026 •

Copy link
Copy Markdown

Could you please merge this and deploy a new version @doowb and @koding88 ?

juanmarin-wq added a commit to Asygnuz-S-A-S/one-star that referenced this pull request Nov 17, 2026
picomatch <=4.0.7 tiene un ReDoS con extglobs de una rama con comodín y
no hay versión corregida publicada (el arreglo es micromatch/picomatch#254).
Llega por @sentry/nextjs -> @rollup/plugin-commonjs (compilación) y por
vitest (pruebas); la tienda nunca le pasa texto de clientes.

- Override picomatch@4 -> 4.0.7 y parche de pnpm con el arreglo de #254.
- Dockerfile copia patches/ antes de instalar.
- Prueba que falla si el parche se pierde (resuelve picomatch por el
  camino de producción).
- docs/seguridad-dependencias.md: sección «Parches locales».

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Luke-Lacina added a commit to TheVoxRox/mail that referenced this pull request Nov 17, 2026
…ile (#937)

On 2026-11-17 GitHub widened GHSA-fc5q-39xc-vjpf (ReDoS in picomatch
extglob matching) to cover 4.0.7, the latest release. npm audit then
reported 15 packages at high, every one of them through picomatch, and the
Lint job failed on every pull request and on main over a finding nobody
could act on: no fixed release exists, the fix is still a proposal
upstream (micromatch/picomatch#254). picomatch runs only in the build and
test tooling (vite through @tailwindcss/vite, vitest, knip, by way of
tinyglobby and fdir); it is not in the built bundle, and the globs it
compiles are this repository's own configuration.

The gate could not accept anything. It now reads
frontend/npm-audit-accepted.json: a GHSA id, the package, a reason and an
until date. It passes when every advisory at high or above in the report's
via objects is accepted on the package it names; a package that is high
only through another package's advisory is excused with it. A report that
carries counts but no advisories excuses nothing, as before.

Each acceptance ends loudly: the day after until it no longer applies, an
entry no finding at high or above matches fails the gate until deleted, and
an until more than 90 days ahead is refused. --accepted and --today let the
suite judge on a fixed list and day; the existing cases run against an
empty list, so the repository's own entry never decides them.

GHSA-fc5q-39xc-vjpf is accepted until 2026-12-17. The decision is in
docs/DECISIONS.md, the procedure in CONTRIBUTING.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CK-7vn added a commit to UnlockedLabs/unlocked-core that referenced this pull request Nov 17, 2026
picomatch <= 4.0.7 is vulnerable to ReDoS through single-branch repeated extglobs (GHSA-fc5q-39xc-vjpf) and no upstream release is patched. Pin picomatch to a fork build that carries the fix from micromatch/picomatch#254. Remove the resolution once upstream ships a patched release.
@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).

  • Removing the outer repeat for a single wildcard branch looks sound, and it covers +(*), +(*a), *(*), *(*a) and +(*)a.
  • The guard requires splitTopLevel(body).length === 1, so the two-branch +(*a|*b) still compiles to a nested quantifier and stays slow. When every branch is star-led the same reasoning holds (one copy absorbs the rest, as in fix: drop redundant repetition from star-led repeated extglobs #257), so the check could cover that case too.

@atabordal

Copy link
Copy Markdown

We applied this PR's lib/parse.js change on top of the published 4.0.7 (and #246 on top of 2.3.2, for consumers still on 2.x), since GHSA-fc5q-39xc-vjpf has no patched release yet and vite depends on picomatch directly.

What we checked on both:

  • ReDoS: isMatch('a'.repeat(24) + '!', '+(*)a') takes ~5.1 s on the unpatched packages; patched, 10,000 characters take ~1 ms for +(*a), *(*a), +(*)a, +(a*b)c and x+(*a).
  • No behaviour change elsewhere: 21 common globs (the kind vite, tailwind and eslint use) × {}, { dot: true }, { windows: true } produce exactly the same makeRe(...).source as the unpatched code, and the single-branch extglobs from this PR's tests match the same inputs as before, without nested quantifiers.

It would be great to get this merged and released (4.0.8, and a 2.3.x with #246), so downstream projects can drop local patches and scanners stop flagging every install. Thanks for the fix!

@andrewkoski

Copy link
Copy Markdown

The fix misses wildcards in non-first branches: picomatch.isMatch('a'.repeat(26) + '!', '*(b|*a)') still takes ~1.5 s with this branch applied (0 ms with #259/#262/#264). Suggest checking every branch for a top-level *, not only the first.

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

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.

7 participants