Skip to content

Conversation

@mmmsssttt404
Copy link

Q A
Bug fix? yes
New feature? no
Breaking changes? no
Deprecations? no
New tests added? yes
Fixed tickets none
License MIT

Description

[Description of the bug or feature]
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/marktext/blob/c59b3ad423dfa082869933baf9f5d5c69bdcc560/src/main/utils/index.js#L15

test:
https://github.com/mmmsssttt404/marktext/blob/c59b3ad423dfa082869933baf9f5d5c69bdcc560/test/unit/specs/match-electron-accelerator.spec.js#L155-L164
{BB30E401-916E-4980-BFD6-4FF3DD10EF6B}

use time:
屏幕截图 2025-03-25 155626
3108s
Proposed Solution:
Change the regular expression to
#{1,6} {1,}(?! )(.*\S.*)(?:\n|$)
{44866EAF-65B7-4D62-814E-014FCE2A9669}

then:
屏幕截图 2025-03-25 155651

1.git clone https://gitclone.com/github.com/mmmsssttt404/marktext.git
2.cd marktext
3.yarn install
4.yarn unit

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

@ShubhamYadav25
Copy link

We can add timeout too in Regex to prevent ReDoS

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