Skip to content

Conversation

mmmsssttt404
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

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/mmmsssttt404/pm2/blob/d0e7801184bcf98b7c93ffecc77c623df6ffa22f/lib/tools/Config.js#L204

PoC Files and Comparisons:
gist:https://gist.github.com/mmmsssttt404/407e2ffe3e0eaa393ad923a86316a385
use time:
屏幕截图 2025-04-01 142642

Proposed Solution:
Change the regular expression to

((?<![\w\-])([\w\-]+\="[^"]*")|(?<![\w\-])([\w\-]+\='[^']*')|"([^"]*)"|'([^']*)'|\s )

change:

屏幕截图 2025-04-01 142648 屏幕截图 2025-04-01 143941 屏幕截图 2025-04-01 144551

steps:
1.git clone https://github.com/mmmsssttt404/pm2.git
2.cd pm2
3.git checkout development
4.npm install
5.change regex
6.bash test/unit.sh

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

@CLAassistant
Copy link

CLAassistant commented Apr 1, 2025

CLA assistant check
All committers have signed the CLA.

@mmmsssttt404 mmmsssttt404 changed the title [core] Potential ReDoS Vulnerability or Inefficient Regular Expression in Project: Need for Assessment and Mitigation fix:Potential ReDoS Vulnerability or Inefficient Regular Expression in Project: Need for Assessment and Mitigation Apr 1, 2025
@xqin
Copy link

xqin commented Jul 8, 2025

_valid 是内部方法,仅在 Config.validateJSON 中被调用, Config.validateJSON 的调用方传入的数据 是来自 使用者自己传入的配置项生成的,何着自己DDOS自己算漏洞?

那 写段 nodejs 脚本执行任意命令或者跑个死循环,就可以提 nodejs 官方提 BUG 了吗?

看了一下你的 gist 中的 POC,都是类似的,拿这个套路在 github 上刷 PR 吗?

https://gist.github.com/mmmsssttt404

// If first type is Array, but current is String, try to split them.
if(scht.length > 1 && type != scht[0] && type == '[object String]'){
if(scht[0] == '[object Array]') {
// unfortunately, js does not support lookahead RegExp (/(?<!\\)\s+/) now (until next ver).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be removed because the commit uses lookbehind assertions. The NodeJS implementation of the feature is in 8.10+ (2018-03-06) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Lookbehind_assertion

@Unitech Unitech changed the base branch from master to development August 25, 2025 11:09
@Unitech Unitech merged commit bec32f7 into Unitech:development Aug 25, 2025
1 check passed
@KyorCode
Copy link

KyorCode commented Sep 2, 2025

#6031 this merge is giving issues.

@xqin
Copy link

xqin commented Sep 2, 2025

The new regular expression has problems, and for the problem mentioned before, it cannot cut the parameters correctly.

image

@Unitech Please revert this pull request.

@mmmsssttt404
Copy link
Contributor Author

Sorry for the impact on the project, this was caused by an extra space, but it happened to not be covered by the test, and then fixed it in the new PR
#6032

@mmmsssttt404
Copy link
Contributor Author

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

@mmmsssttt404
Copy link
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 /issues/6031 this problem

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.

6 participants