Repository navigation
fix: collapse single-branch wildcard extglobs (GHSA-fc5q-39xc-vjpf) - #267
Open
Arulraj-a2b wants to merge 1 commit into
Open
Arulraj-a2b wants to merge 1 commit into
Arulraj-a2b wants to merge 1 commit into
Conversation
A repeated extglob whose single branch holds a wildcard, such as +(*a) or +(a*)b, nested an unbounded quantifier and backtracked exponentially. A branch made of single-character matchers and * now collapses (+(P) -> (P), *(P) -> (P)?), slash-delimited repeats are left alone, and other wildcard shapes are literalized like the existing risky patterns.
BYK
added a commit
to getsentry/craft
that referenced
this pull request
Nov 18, 2026
Fixes the two high advisories in the root and `docs/` lockfiles. **[GHSA-mrhx-c7xc-m3w5](GHSA-mrhx-c7xc-m3w5) (zod < 4.6.6), root.** zod 3 came only from `@vercel/client > @vercel/build-utils@14 > @vercel/python-analysis`. `@vercel/client@^18.12.3` uses `@vercel/[email protected]`, which no longer depends on python-analysis, so zod drops out of the tree. A zod override would force zod 4 onto zod 3 code. The `createDeployment` API that the vercel target uses has not changed. **[GHSA-fc5q-39xc-vjpf](GHSA-fc5q-39xc-vjpf) (picomatch ReDoS), root and docs.** There is no fixed release. Following the `braces` precedent, this adds local pnpm patches for both installed versions, 4.0.7 and 2.3.2. 2.3.2 has the same bug. The advisory links micromatch/picomatch#194, but that PR covers `?`-leading extglobs and does not fix `+(*a)`. The patches backport micromatch/picomatch#267 (#268 for 2.x): - A single wildcard branch made of literals, `?`, `*`, and bracket classes that cannot match `/` absorbs its own repetition. `+(P)` compiles as `(P)` and `*(P)` as `(P)?`, and the matches stay the same. - Other single-branch wildcard bodies are literalized, like the existing risky-extglob guard. The patch differs from upstream in one place. Upstream would collapse a bracket range like `[+-0]`, which includes `/`, and that changes what it matches. The patch checks each compiled bracket class first. Details are in `patches/README.md`. **After merge:** Dependabot matches on version, so it will keep flagging the patched picomatch 4.0.7 and 2.3.2, as it already does for braces. Dismiss those alerts by hand. **Not covered:** repeated extglobs with several branches that contain `*`, such as `+(*a|b)`. That is the general upstream issue micromatch/picomatch#175. Literalizing them would break globs like `+(*.js|*.ts)`. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aa3f271eaa645c4e79ce41158088ba41e --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3Aa3f271eaa645c4e79ce41158088ba41e) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aa3f271eaa645c4e79ce41158088ba41e/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]> Co-authored-by: Burak Yigit Kaya <[email protected]>
|
Downstream compatibility check for this change and #268: I tested the parser at |
Merged
8 tasks done
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GHSA-fc5q-39xc-vjpf (CVE-2026-112366).
Problem
A repeated extglob with a single branch that holds a wildcard, such as
+(*a),*(*a),+(*)bor+(a*)b, compiles to a nested unbounded quantifier like(?:[^/]*?a)+. Matching it against a short non-matching string backtracks exponentially. On 4.0.7,+(*a)takes about 20 s on 28 characters.analyzeRepeatedExtglobskipped these bodies because it only looked at multi-branch alternations and nested*(...)sequences.Fix
In
analyzeRepeatedExtglob, a single branch with a wildcard (found from the parser's own tokens, so escaped\*, quoted"*", bracketed[*]and the*of a nested*(...)do not count) is handled in one of three ways:?, plain bracket classes that cannot match/) and*, with no slash, then+(P)matches exactly whatPmatches. The first*absorbs every later repeat. So+(P)becomes(P)and*(P)becomes(P)?, and no nested quantifier is left. Matching is unchanged:+(*a)still matchesaaa,+(a*b)still matchesabab,+(*)cstill matchesabc./, each repeat has to start after a slash that*cannot cross, so the repeat cannot backtrack. For example,+(src/*/)is unchanged.+(@(*a)), or bash mode where*crosses/, is literalized like the existing risky patterns+(a|aa)and+(+(a)).maxExtglobRecursion: falsestill opts out.Tests
test/redos-single-branch-wildcard.js:dot,windows,bashandnocase, that*still does not cross/outside bash mode, and that escaped, quoted and bracketed stars and slash-delimited repeats behave as before.npm testpasses: lint plus 2004 tests onmaster. The same change is in a separate PR againstv2, where 1978 tests pass;v2's lint already fails on master intest/dotfiles.jsandtest/special-characters.js.Before → after on
'a'.repeat(28) + '/':+(*a)21.7 s → 1 ms,*(*a)27.0 s → 0 ms,+(a*)b11.9 s → 0 ms.Related open PRs for the same advisory: #257–#266. This one keeps the change small (one function plus the close quantifier) and changes matching only for the risky shapes. Happy to fold it into whichever one you prefer.