Skip to content

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

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 2 commits into
base: master
Choose a base branch
from

Conversation

mmmsssttt404
Copy link

Steps to reproduce
Hello,

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.

Location of Issue:

The vulnerability is related to a regular expression used in the following validation file, which may result in significantly prolonged execution times under certain conditions.

const parts = fragment
.replace(/(.*?)#.*/, '$1') // Strip hash
.replace(/.*:(.*)/, '$1') // Strip prefixed protocols
.replace(/.git$/, '') // Strip the .git suffix
.split('/');

1.git clone https://github.com/mmmsssttt404/yarn.git
2.yarn install
3.change test file
4.yarn test tests/resolvers/exotics/hosted-git-resolver.js

use time: 使用时间:
屏幕截图 2025-07-17 021736
屏幕截图 2025-07-09 100629

Proposed Solution:
Change the regular expression to
https://github.com/mmmsssttt404/yarn/blob/97731871e674bf93bcbf29e9d3258da8685f3076/src/resolvers/exotics/hosted-git-resolver.js#L32-L37

{29A65FAC-6467-4E9F-A64C-6E1E2050D24E} 屏幕截图 2025-07-17 021727

Thank you for your attention to this matter. Your evaluation and response to this potential security concern would be greatly appreciated.

Best regards,

Search keywords: ReDoS

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