[fix] Vulnerability GHSA-x5gf-qvw8-r2rm #6015
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔒 Security Fix: ReDOS Vulnerability in Config.js (CVE-2025-5891)
Summary
This PR fixes a Regular Expression Denial of Service (ReDOS) vulnerability in
/lib/tools/Config.js
that could allow attackers to cause excessive CPU consumption and potentially crash PM2 applications.🚨 Vulnerability Details
Affected Code
The vulnerability exists in the
_valid()
function (lines 181-185) where a complex regular expression with nested quantifiers is used to parse configuration strings:This regex pattern exhibits exponential time complexity when processing specially crafted input strings, leading to catastrophic backtracking.
Attack Scenario
An attacker could:
🛠️ Fix Implementation
This PR implements multiple layers of protection:
1. Regex Complexity Validation
/([+*]{2,}|(\(.{0,10}\)){3,})/
2. Input Sanitization
3. Defensive Programming
validateJSON()
function📋 Changes Made
/lib/tools/Config.js
validateJSON()
✅ Testing
🔗 References
📈 Impact
This fix:
🚀 Deployment
Safe to deploy immediately - this is a security-critical fix with no breaking changes.