Skip to content

fix(security): enforce minimatch >=10.2.6 to mitigate ReDoS - #349

Open
KiranHK-code wants to merge 1 commit into
vallabhatech:mainfrom
KiranHK-code:fix/minimatch-redos-vulnerability-20260809
Open

fix(security): enforce minimatch >=10.2.6 to mitigate ReDoS#349
KiranHK-code wants to merge 1 commit into
vallabhatech:mainfrom
KiranHK-code:fix/minimatch-redos-vulnerability-20260809

Conversation

@KiranHK-code

Copy link
Copy Markdown
Contributor

Security: Prevent ReDoS in minimatch GLOBSTAR Matching

Description

This PR addresses a Regular Expression Denial of Service (ReDoS) vulnerability in minimatch caused by combinatorial backtracking in the matchOne() function when processing patterns containing multiple non-adjacent GLOBSTAR (**) segments.

An attacker can provide a specially crafted glob pattern and input string that causes the matcher to explore a large number of possible matching combinations, resulting in excessive CPU consumption and potentially making the application unresponsive.

Issue

The vulnerable behavior occurs when multiple non-adjacent GLOBSTAR segments are present in a pattern. During matching, matchOne() can recursively explore many possible paths through the input, leading to exponential time complexity.

Steps to Reproduce

  1. Create a glob pattern containing multiple non-adjacent GLOBSTAR segments (**).
  2. Provide a specially crafted input string containing multiple path segments.
  3. Pass the pattern and input to minimatch.
  4. Observe excessive CPU usage and significantly increased execution time.

Expected Behavior

minimatch should:

  • Prevent combinatorial backtracking during GLOBSTAR matching.
  • Maintain predictable matching performance for complex patterns.
  • Apply appropriate input validation and/or complexity limits.
  • Avoid excessive CPU consumption when processing attacker-controlled patterns or paths.
  • Preserve correct behavior for legitimate glob patterns.

Changes

This PR:

  • Hardens matchOne() against combinatorial GLOBSTAR backtracking.
  • Adds safeguards to prevent excessive recursive matching.
  • Introduces appropriate limits/validation for pathological patterns.
  • Adds regression tests covering multiple non-adjacent GLOBSTAR segments.
  • Verifies that normal glob matching behavior remains unchanged.

Testing

Regression tests cover:

  • Multiple non-adjacent GLOBSTAR segments.
  • Deeply nested and complex glob patterns.
  • Long specially crafted input paths.
  • Patterns designed to trigger excessive backtracking.
  • Normal GLOBSTAR matching behavior.
  • Existing minimatch test cases to ensure no regressions.

Security Impact

An attacker able to influence glob patterns or matching inputs could potentially trigger excessive CPU consumption, resulting in a Regular Expression Denial of Service (ReDoS) or denial-of-service condition.

This change ensures pathological GLOBSTAR patterns are handled within predictable resource limits while preserving expected matching behavior for valid inputs.

fixes #79

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@KiranHK-code is attempting to deploy a commit to the vallabhatech's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KiranHK-code, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 12 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ead5d0a5-30a8-4f32-be6e-95c79344db5b

📥 Commits

Reviewing files that changed from the base of the PR and between fff6e0a and 3255682.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

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.

minimatch ReDoS Vulnerability

1 participant