Security: Regular Expression Denial of Service (ReDoS) in glob pattern compilation
Problem
The compileGlobPattern function in match-glob-pattern.ts compiles user-provided glob patterns into regular expressions without any timeout or complexity limits. Malicious patterns like **/a* repeated many times or with nested quantifiers could cause catastrophic backtracking.
Severity: high
File: packages/react-doctor/src/core/config/match-glob-pattern.ts
Solution
Implement a regex complexity check or use a library like safe-regex to validate the compiled regex for potential ReDoS. Alternatively, use a glob-to-regex library with built-in protection.
Changes
packages/react-doctor/src/core/config/match-glob-pattern.ts(modified)
Testing
- [ ] Existing tests pass
- [ ] Manual review completed
- [ ] No new warnings/errors introduced
[!NOTE] Medium Risk Adds hard limits that now throw errors for overly long or wildcard-heavy ignore patterns, which could break existing configs that relied on very large globs. Change is localized but affects config parsing for ignore rules.
Overview Mitigates potential ReDoS in
compileGlobPatternby enforcing maximum glob length and wildcard count before compiling to aRegExp.Invalid/overly complex patterns now throw explicit errors, impacting ignore file/override pattern compilation that calls this helper.
Reviewed by Cursor Bugbot for commit 66f7bc6619e568f5a948b61bc9eff2d574a95361. Bugbot is set up for automated code reviews on this repo. Configure here.
🔴 React Review — 0/100 (unchanged) · No new issues
Reviewed by react-review for commit 66f7bc6619e568f5a948b61bc9eff2d574a95361. Configure here.
@tuanaiseo is attempting to deploy a commit to the Million Team on Vercel.
A member of the Team first needs to authorize it.