yarn icon indicating copy to clipboard operation
yarn copied to clipboard

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

Open mmmsssttt404 opened this issue 4 months ago • 2 comments

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.

https://github.com/yarnpkg/yarn/blob/7cafa512a777048ce0b666080a24e80aae3d66a9/src/resolvers/exotics/registry-resolver.js#L12

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

use time: 屏幕截图 2025-08-13 113000

{5E0F92FD-75D8-4AD5-A0E1-8FEDF44C44A2}

Proposed Solution: Change the regular expression to

https://github.com/mmmsssttt404/yarn/blob/5150f8613c99219a7e4c51d7f2e0c1febed532de/src/resolvers/exotics/registry-resolver.js#L12 {44CD9C84-2220-4BB3-A47F-3FDFC6D2E161} 屏幕截图 2025-08-13 113050

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

mmmsssttt404 avatar Aug 13 '25 03:08 mmmsssttt404

3.yarn test __tests__/resolvers/exotics/hosted-git-resolver.js this change to yarn test __tests__/resolvers/exotics/registry-resolver.js

mmmsssttt404 avatar Aug 13 '25 03:08 mmmsssttt404

Benchmarks show clear quadratic growth with input size, not linear. Even at ~100k chars, runtime reaches several seconds. ReDoS does not require exponential blowup — Polynomial behavior is already recognized as exploitable redos_result (9)

mmmsssttt404 avatar Aug 23 '25 07:08 mmmsssttt404