Skip to content

fix: Potential ReDoS Vulnerability or Inefficient Regular Expression in Project: Need for Assessment and Mitigation #2057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mmmsssttt404
Copy link

I am writing to report a potential Regular Expression Denial of Service (ReDoS) vulnerability or Inefficient Regular Expression in the project. When using specially crafted input strings in the context, it may lead to extremely high CPU usage, application freezing, or denial of service attacks.

.replace(/(\[)(?=[^/]+\])/g, '[[]') // escape '[' when ']' follows within the path segment

change to:
https://github.com/mmmsssttt404/toolkit/blob/f1d6d994406ccf553f554631c8aeff565b051950/packages/glob/src/internal-pattern.ts#L191

Describe the steps to verify that the changes are working as expected.

1.git clone https://github.com/mmmsssttt404/toolkit.git
2.cd toolkit
3.npm install
4.npm run build
5.npx tsc
6.npm test -- packages/glob/tests/internal-pattern.test.ts

{568630AE-CE1C-45CF-8AB7-D0027F02C32E}

before change:

屏幕截图 2025-05-13 160742 屏幕截图 2025-05-13 161631

after change:
屏幕截图 2025-05-13 162517
屏幕截图 2025-05-13 162554

@mmmsssttt404 mmmsssttt404 requested a review from a team as a code owner May 13, 2025 08:47
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