Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair ReDoS (issue #493, PR #494) #531

Merged
merged 4 commits into from
Oct 9, 2023

Conversation

Crozzers
Copy link
Contributor

This PR fixes #493 by patching a ReDoS vulnerability in the <strong> and <em> regexes.

Full credit to @DarkTinia for the discovery and for #494, which this PR is based off of. However, this PR negates the need for adding third party regex libraries to the project.

The fix works by removing the lookbehinds from the relevant regular expressions. From my testing, this was sufficient to patch the ReDoS whilst not breaking any test cases.

@nicholasserra
Copy link
Collaborator

LGTM thanks!

@nicholasserra nicholasserra merged commit 191b660 into trentm:master Oct 9, 2023
18 checks passed
@gitbra
Copy link

gitbra commented Oct 17, 2023

Hi team,

The patch is okay when code-friendly is not enabled.

Unfortunately, the conversion remains slow in the following configuration:
python markdown2.py issue493.md -x code-friendly

I have no suggestion to help more.

@Crozzers
Copy link
Contributor Author

My bad, I forgot to apply all the RE changes to both the strong RE and the code friendly strong RE. I'll get a fix for this submitted soon

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.

A ReDoS vulnerability exists in markdown2.py
4 participants