Skip to content

fix:ReDoS fix about pull/5971 and issues/6031#6032

Closed
mmmsssttt404 wants to merge 4 commits intoUnitech:masterfrom
mmmsssttt404:master
Closed

fix:ReDoS fix about pull/5971 and issues/6031#6032
mmmsssttt404 wants to merge 4 commits intoUnitech:masterfrom
mmmsssttt404:master

Conversation

@mmmsssttt404
Copy link
Copy Markdown
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1234, #5678
License MIT
Doc PR #5971

#5971
#6031
Sorry for the impact on you, this was caused by an extra space,We modified it and made it more consistent with the original regex
Regex Change to

(?<![\w\-])([\w\-]+\="[^"]*")|(?<![\w\-])([\w\-]+\='[^']*')|"([^"]*)"|'([^']*)'|\s
1b8321137c2c6303224ee6b97099ba6 036d78f59b83eb3281ef4ab69deb65b 58ea4378766d19c0cd53dd71c67dc32

https://github.com/mmmsssttt404/pm2/blob/1e0e96c5257041bc19b1fd796ea455c4085bec6e/lib/tools/Config.js#L203-L205
屏幕截图 2025-09-03 104716

{7637AE83-E457-4994-86FB-52BF0403BEAA}

I'm deeply sorry for the errors I introduced in the code changes. My original intention was to fix Redos, but it caused a bug. In the future, I will be more cautious and fully verify before making any changes.

@mmmsssttt404
Copy link
Copy Markdown
Contributor Author

{4EEAE694-A32F-490A-A4CB-58A593931609} {7EB0BDB3-467E-4913-907B-DD1FF1575869}

@mmmsssttt404
Copy link
Copy Markdown
Contributor Author

{08F62FE6-BFC8-43D9-84C9-E90FBFB7E1C1} I add one test in https://github.com/mmmsssttt404/pm2/blob/master/test/programmatic/json_validation.mocha.js to test https://github.com//issues/6031 this problem

@Unitech
Copy link
Copy Markdown
Owner

Unitech commented May 2, 2026

Thanks for catching this and proposing a fix. The vulnerable value.split(/([\w\-]+\="[^"]*")…/) in lib/tools/Config.js was rewritten in pm2 7.0.0 to a linear match(/[^\s"'=]+="[^"]*"|…/g) (no catastrophic backtracking). Closing as resolved by 7.0.0 — appreciate the report!

@Unitech Unitech closed this May 2, 2026
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.

2 participants