dayjs icon indicating copy to clipboard operation
dayjs 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 • 1 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/iamkun/dayjs/blob/6e831280f010353e298c131cf54c922c5ac8fc82/src/constant.js#L30

https://github.com/iamkun/dayjs/blob/6e831280f010353e298c131cf54c922c5ac8fc82/src/plugin/localizedFormat/utils.js#L3

https://github.com/iamkun/dayjs/blob/6e831280f010353e298c131cf54c922c5ac8fc82/src/plugin/localizedFormat/utils.js#L14

1.git clone https://gitclone.com/github.com/mmmsssttt404/dayjs.git 2.npm install 3.npm test -- test/plugin/localizedFormat.test.js --coverage=falsequit //or npm test

use time: (More than 10s) {6A2B0419-5EAC-4DC8-A4D9-69277F5F56CB} 屏幕截图 2025-07-23 130400

Proposed Solution: Change the regular expression to

https://github.com/mmmsssttt404/dayjs/blob/a6b0f1da9dba76d6beec6573d188f6aa74fca225/src/constant.js#L30

https://github.com/mmmsssttt404/dayjs/blob/a6b0f1da9dba76d6beec6573d188f6aa74fca225/src/plugin/localizedFormat/utils.js#L1-L17

{B92AD442-E04E-42B8-A084-FB750DB35D48} {872770C8-B1C5-43BA-B70C-C17CE119D395} 屏幕截图 2025-08-06 120043 屏幕截图 2025-08-06 120309

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 06 '25 04: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 — quadratic behavior is already recognized as exploitable e50ee7b9211b444f0dbd34a9b19cfb8 fbef23476917e5ecd739a4519300d88 debf5c92283475026da7b7174f9a9af

mmmsssttt404 avatar Aug 22 '25 06:08 mmmsssttt404