Skip to content

Dependencies: patched picomatch builds for GHSA-fc5q-39xc-vjpf (no upstream fix yet) - #3678

Merged
integry merged 3 commits into
mainfrom
picomatch-ghsa-fc5q-vendored
Nov 17, 2026
Merged

integry merged 3 commits into
mainfrom
picomatch-ghsa-fc5q-vendored

Conversation

@integry

@integry integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Why

The picomatch advisory GHSA-fc5q-39xc-vjpf (high, ReDoS through single-branch repeated extglobs such as +(*)) was updated on 2026-11-17 to cover every published version (<= 4.0.7, the latest). There is no fixed release; upstream fixes are open, unmerged pull requests (micromatch/picomatch #237, #238, #246). Since the update, npm run audit:runtime and npm run desktop:audit:packaging fail on main and on every pull request.

What

These are the two commits ProPR's CI follow-up made on the API/core epic (#3630), lifted onto main unchanged so the fix can be reviewed and merged on its own:

  • Vendored, patched builds of both picomatch lines in the tree (vendor/picomatch, 4.0.7 base, and vendor/picomatch-v2, 2.3.2 base), installed through package.json overrides. Same approach as the existing vendored braces build.
  • The guard treats the risky extglobs as literal text. Both builds also replace a quadratic removeBackslashes regex with a linear scan (CodeQL alerts 246 and 247).
  • test/vendoredPicomatch.test.mjs guards the tarballs, the lockfile and the matching behaviour; docs/dependency-audit-exceptions.md records provenance and when to remove it.

Checked locally

  • Both audits pass on this branch; they fail on main.
  • After a clean install, all 8 picomatch copies in the tree resolve to the vendored builds, and the 11 guard tests pass.
  • +(*), +(*a) and *(a*) against a 40-character non-matching string return in under 3 ms; ordinary globs, braces and negation still match as before.

Remove the vendored builds and overrides when upstream publishes fixed releases.

🤖 Generated with Claude Code

propr-dev[bot] added 2 commits November 17, 2026 18:20
…: a new picomatch advisory, GHSA-fc5q-39xc-vjpf, was published with no fixed release. Locally, both audit gates the job runs (`npm run audit:runtime` and `npm run desktop:audit:packaging`) now pass, and so do the related test suites. CI hasn't run on the change yet.

I fixed the failing check. No code on this branch caused it: a new picomatch advisory, GHSA-fc5q-39xc-vjpf, was published with no fixed release. Locally, both audit gates the job runs (`npm run audit:runtime` and `npm run desktop:audit:packaging`) now pass, and so do the related test suites. CI hasn't run on the change yet.

**Cause.** The advisory covers every `picomatch` up to 4.0.7, which is the latest release. Patterns like `+(*)` or `+(*a)` make picomatch build a regex that takes exponentially long to fail. I reproduced it: about 35 seconds on a 29-character string, on both 2.3.2 and 4.0.7. `main` has the same problem, so other open branches will fail the same way. Both copies in our tree are affected: 4.0.7 (used by `vite`, `vitest`, `tinyglobby`) and 2.3.2 (used by `micromatch`, `anymatch` and `readdirp`, which `fast-glob`, Repomix and `chokidar` use).

**Fix.** I followed the same approach the repo already uses for `braces`: I didn't add an audit exception. Instead both picomatch copies now install from patched versions stored in the repo:
- **The patch:** a small check in `lib/parse.js` treats any `+(…)`/`*(…)` pattern containing a bare `*` or `+` as plain text, using picomatch's existing handling for patterns it already considers risky. All the attack patterns now finish in under 2 ms.
- **`vendor/picomatch`:** 4.0.7 plus the patch, used by everything that needs picomatch 4.
- **`vendor/picomatch-v2`:** 2.3.2 plus the same patch, used by `anymatch`, `micromatch` and `readdirp` (overridden in `package.json`). I kept these on the 2.x code because the 4.x line changed path handling that `micromatch` and `fast-glob` rely on.
- **Version numbers:** both versions must sort above 4.0.7 or the audit still flags them, so the 2.x one is named `4.0.8-v2.3.2-extglobguard.1`.
- **Lockfile:** npm 10 and npm 11 both kept collapsing the 2.x consumers onto the 4.x copy. I wrote those three lockfile entries by hand. They stay unchanged through `npm install` and lockfile-only installs on both npm versions, and a clean `npm ci` installs the right copy for each package.

Other changes:
- **Signed-RPM acceptance:** its allowlist and Dockerfile now include the two new tarballs.
- **New test:** `test/vendoredPicomatch.test.mjs` checks that the source, tarball, lockfile and installed copies match, and that normal matching still works.
- **Docs and notices:** README provenance notes in each vendored folder, a section in `docs/dependency-audit-exceptions.md`, a CHANGELOG Security entry, and a regenerated `THIRD_PARTY_LICENSES.md` (new picomatch row, and the date moves to today).

**Behaviour change and remaining risk.** I ran picomatch's own test suite against both patched copies. Four assertions now fail, and each one checks that a vulnerable pattern (`+(*)c`, `*(a*|b)`, `*/*(W*, *)*`) still matches. Those patterns now match only their literal text, and no glob in this repo uses one. Nested repeats like `+(a*(a))` are still slow. I left them alone because picomatch's own tests require the same shape (`*(f*(o))`) to keep working, and upstream tracks that case separately (issue #175).

Once picomatch publishes fixed releases, the vendored copies can be removed; the vendored READMEs list the steps.

PR: #3630
Comment by: @propr-dev[bot] (ID: 6955352684)
Model: Claude Opus 5.5
…red picomatch builds. The flagged regex really was slow: on a string of 65,000 `[` characters, `removeBackslashes` took about 1.6 s. It now takes about 1 ms. CI hasn't run on the change yet.

I fixed both CodeQL alerts (#246 and #247) in the two vendored picomatch builds. The flagged regex really was slow: on a string of 65,000 `[` characters, `removeBackslashes` took about 1.6 s. It now takes about 1 ms. CI hasn't run on the change yet.

**Cause.** `removeBackslashes` in `lib/utils.js` used upstream's `REGEX_REMOVE_BACKSLASH` (`/(?:\[.*?[^\\]\]|\\(?=.))/g`). From every `[` with no closing `]`, that regex rescans to the end of the line, so the time grows with the square of the input length.

**Fix.** In both `vendor/picomatch/lib/utils.js` and `vendor/picomatch-v2/lib/utils.js`, `removeBackslashes` is now a single pass over the string. It returns exactly what the old regex returned:
- It returns the input unchanged when there is no backslash, since only backslashes are ever removed.
- A text in brackets is kept as is under the same rule the regex used.
- A backslash followed by any character other than a line break is removed.

`lib/constants.js` is unchanged, so `REGEX_REMOVE_BACKSLASH` is still exported as part of `constants`. `utils.js` just no longer imports it.

**Same output as before.** I compared the new function with the old regex on every string up to six characters built from `[`, `]`, `\`, `a`, `*` and the four line terminators, plus 300,000 random strings. There were no differences in either build.

**Other changes:**
- **Tests:** `test/vendoredPicomatch.test.mjs` has a new check for each build. It compares the function with the upstream regex on every short string, requires the 65,000-character inputs to finish in under 200 ms, and runs a few `scan(..., { unescape: true })` cases.
- **Tarballs and lockfile:** I repacked both tarballs and updated the four lockfile integrity entries. Only those integrity lines changed in `package-lock.json`. The version stays `4.0.8-extglobguard.1`, so `npm install` didn't refresh the locally installed copies; I removed them and reinstalled.
- **Docs:** both READMEs now say `lib/utils.js` differs from upstream and why. `docs/dependency-audit-exceptions.md` mentions it too.

**Checks run:**
- `test/vendoredPicomatch.test.mjs`: 11 of 11 pass, including the byte-identity, lockfile-integrity and installed-copy checks.
- `apps/desktop/scripts/signed-rpm-acceptance-context.test.mjs`: 5 of 5 pass. It checks the tarballs against the lockfile integrity.
- `npm run audit:runtime` and `npm run desktop:audit:packaging` both pass.

There's nothing visual in this change, so there are no previews.

PR: #3630
Comment by: @github-advanced-security[bot] (ID: 4603531940)
Comment by: @github-advanced-security[bot] (ID: 4603532037)
Model: Claude Opus 5.5

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

/review

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The vendoring, dependency wiring, and provenance documentation are thorough, but the new guard misses single-branch wildcard patterns that remain vulnerable to exponential backtracking. Changes are needed before merge.

✅ Installation consistency — Tests compare readable source, tarball contents, lockfile integrity, and installed consumer packages.

✅ Packaging coverage — Both new tarballs are included in the sanitized RPM acceptance context and copied before npm ci.

This review uses static analysis only, as requested. The supplied status reports no failed checks and 17 pending checks.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Bracket handling bypasses the wildcard guard

  • Category: correctness

  • Required behavior: The new guard must literalize repeated extglobs containing bare unbounded wildcards, including the single-branch patterns this PR aims to remediate.

  • Evidence: vendor/picomatch/lib/parse.js, hasUnboundedWildcard; identical affected helper in vendor/picomatch-v2/lib/parse.js.

    1. Compile +([*) using default options. The main parser treats the unmatched [ as literal text because no closing ] exists, then compiles * as an unbounded wildcard.
    2. At the outer extglob’s close, hasUnboundedWildcard increments its bracket counter for [. It never decrements that counter and therefore skips the active *.
    3. The other analysis checks neither rewrite nor reject this single branch. The resulting regex contains (?:\[[^/]*?)+.
    4. Matching '['.repeat(n) + '/' fails at the trailing slash after exploring exponentially many partitions of the preceding brackets, blocking the synchronous matching thread.

    The same mismatch occurs with the valid bracket expression in +([[]*): the parser treats the second [ as a literal class member, while the helper counts it as another bracket opening and misses the following wildcard. Neither case requires the documented residual nested-extglob behavior or an option disabling protection. Existing guard tests contain neither form.

    static trace: followed both supplied parsers’ bracket handling, wildcard emission, and analyzeRepeatedExtglob paths; no commands were executed.

  • Minimum fix: Make wildcard detection follow the parser’s bracket semantics, including unmatched brackets and literal [ inside classes, in both builds. Add regression coverage for these bypasses, then repack both tarballs and update their lockfile integrity values.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Assert literal matching through regexes

In test/vendoredPicomatch.test.mjs, picomatch.isMatch(glob, glob) returns true through the exact-input shortcut in picomatch.test, so it does not verify that the compiled regex matches literal text. Testing makeRe(glob).test(glob) directly would strengthen that assertion. This is an optional improvement to the existing tests beyond the bypass regressions required by F1.

S2: 🟢 Isolate backtracking performance probes

The synchronous timing helper can only check elapsed time after matching returns. Running adversarial probes in a worker or child process with an external timeout would make future regressions fail promptly instead of potentially stalling the suite. This is optional test hardening.

Score

The packaging and integrity safeguards are strong, but a concrete bypass leaves the targeted single-branch backtracking problem incompletely remediated. The correction is localized to the guard and its regression coverage.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 56s
  • Tokens: 115,399 (114,108 in / 1,291 out)
  • Cost: $1.10

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 S1 S2

🤖 Review by ProPR

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

/ultrafix goal=8 max=3

@propr-dev propr-dev Bot added the ultrafix label Nov 17, 2026
@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

🔄 Ultrafix loop started (goal: 8/10, max cycles: 3)

First action: /fix

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Applied the requested follow-up changes in commit 7b16ed4

Addressed 1 AI review comment (IDs: 6957060592)

Addressed finding F1

Summary of Changes

The background job that just stopped was my first timing fuzz, which was cut off at its time limit before finishing. Nothing is lost: a second, faster version replaced it and finished on both builds. It found nothing slow within this fix's scope; the only slow cases left are the three upstream ones I reported. Nothing needs to be rerun, and the fix and its results are unchanged.

Review digest

Risk-tiered paths

  • High risk (1 file)
    • package-lock.json (+4/−4): lockfile
  • Normal risk (4 files)
    • vendor/picomatch-4.0.8-extglobguard.1.tgz (+0/−0)
    • vendor/picomatch-4.0.8-v2.3.2-extglobguard.1.tgz (+0/−0)
    • vendor/picomatch-v2/lib/parse.js (+37/−3)
    • vendor/picomatch/lib/parse.js (+37/−3)
  • Low risk (3 files)
    • test/vendoredPicomatch.test.mjs (+18/−0)
    • vendor/picomatch-v2/README.md (+9/−1)
    • vendor/picomatch/README.md (+9/−1)

Validation evidence

  • No repository validation commands ran.

Diff size: 8 files changed, +114/−12 lines


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 20m 55s
  • Tokens: 3,428,183 (3,427,868 in / 315 out)
  • Cost: $1.19

Undo Changes • View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR
Processing comment ID: 6957550230✓

…zz, which was cut off at its time limit before finishing. Nothing is lost: a second, faster version replaced it and finished on both builds. It found nothing slow within this fix's scope; the only slow cases left are the three upstream ones I reported. Nothing needs to be rerun, and the fix and its results are unchanged.

The background job that just stopped was my first timing fuzz, which was cut off at its time limit before finishing. Nothing is lost: a second, faster version replaced it and finished on both builds. It found nothing slow within this fix's scope; the only slow cases left are the three upstream ones I reported. Nothing needs to be rerun, and the fix and its results are unchanged.

PR: #3678
Comment by: @integry (ID: 6957550230)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

The bracket bypass (F1) is fixed at 7b16ed4: +([*) and +([[]*) now return in about 1 ms in both builds. One more pattern family is still exponential in both vendored builds (and in upstream 4.0.7), measured with picomatch(glob)('a'.repeat(n) + '/'):

glob n=18 n=22 n=26 compiled
(*)+ 6 ms 102 ms 1723 ms ^(?:([^/]*?)+)$
@(*)+ 42 ms 99 ms 1804 ms ^(?:([^/]*?)+)$
(*a)+ 13 ms 34 ms 557 ms ^(?:([^/]*?a)+)$
(a*)+ 9 ms 24 ms 373 ms ^(?:(a[^/]*?)+)$
(*)+x 40 ms 105 ms 1905 ms ^(?:([^/]*?)+x)$

So a parenthesised group (plain parens or an @(...) extglob) that contains an unbounded wildcard and is followed by a regex-style + quantifier compiles to the same repeated-wildcard regex the guard exists to prevent. (*)* and @(*)* are fine (the trailing * is compiled as a glob star).

Please handle it with the same rule and the same helper the guard already uses: when a closing paren of a single-branch group that contains an unbounded wildcard is followed by +, treat that + as literal text (or the group as literal, whichever matches what the existing guard does for +(...)). Apply it identically to both builds, add these five patterns to test/vendoredPicomatch.test.mjs with a time bound, repack both tarballs, update the lockfile integrity values, and note it in the two vendor READMEs and docs/dependency-audit-exceptions.md.

Keep it bounded: if this cannot be done as a small extension of the existing guard, do not redesign the parser. Instead document the residual case next to the existing nested-repeat residual and say so in the summary.

@propr-dev

propr-dev Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR provides a focused vendored mitigation for both picomatch lines, with dependency overrides, packaging updates, and provenance documentation. Static review found no verified PR-introduced merge blocker. It is merge-ready within scope, conditional on the three pending checks completing successfully.

✅ Artifact consistency checks — Tests compare readable sources, tarballs, lockfile integrity, and consumer-resolved installations for both builds.

✅ Parser-aware guarding — The token-based check supplements source scanning for malformed brackets and swallowed quotes that would otherwise hide live wildcards.

✅ Packaging integration — Both tarballs are included in the signed RPM acceptance context and Dockerfile, with integrity validation before installation.

This was a static review of the supplied code; no commands were run or files modified.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S3: 🟢 Assert literal matching directly

In test/vendoredPicomatch.test.mjs, picomatch.isMatch(glob, glob) can succeed through the input === glob shortcut in both builds’ lib/picomatch.js, without exercising the compiled regex. Supplement it with regex.test(glob) and representative nonliteral inputs to verify the intended literalization explicitly. This strengthens coverage without demonstrating a current implementation defect.

S4: 🟢 Isolate backtracking performance probes

The synchronous regex.test() calls in timedTest cannot enforce their elapsed-time limit until matching returns. Running potentially exponential probes in a worker or child process with an external timeout would make future regressions fail promptly instead of potentially stalling CI. This is optional test hardening.

S5: 🟢 Track residual nested repetition

Both vendored READMEs explicitly document the remaining exponential +(a*(a)) case. Track that limitation alongside upstream replacement work, particularly because context generation accepts include patterns. It is a pre-existing limitation outside this patch’s bare-wildcard mitigation, not a newly introduced blocker.

Score

The implementation is coherent within its stated scope and includes substantial artifact and behavior coverage. The supplied current-head status shows no failures, with three checks still pending; runtime results were not independently reproduced during this static review.

Score: 8/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 32s
  • Tokens: 117,199 (116,482 in / 717 out)
  • Cost: $1.09

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S3 S4 S5

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 17, 2026

integry commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

Please implement the request in my previous comment on this PR (the table of (*)+, @(*)+, (*a)+, (a*)+, (*)+x): a single-branch group containing an unbounded wildcard and followed by a regex-style + still compiles to a repeated-wildcard regex and is exponential in both vendored builds. Extend the existing guard to cover it in both builds, add those five patterns to test/vendoredPicomatch.test.mjs with a time bound, repack both tarballs and update the lockfile integrity values and the notes. If it is not a small extension of the existing guard, document it as a residual case instead and say so.

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.

1 participant