-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Extremely slow processing on malformed markdown (0.6.2) #1493
Comments
looks like this has to do with marked checking for valid code blocks. If you start deleting |
This ReDOS was introduced in 47365c1, and is caused in fact by the link Line 592 in 396591a
The two branches allowing backticks:
The solution would be to actually try to parse a code span whenever a |
For what it's worth, this patch causes introduce 4 test failures, and only affects fairly obscure situations (namely, a single unmatched backtick).
Thoughts on the performance-correctness tradeoff? |
I'm ok with losing a few tests for security. |
I created PR #1515 with a patch for this vulnerability. |
Describe the bug
Infinite loopExtremely slow processing on malformed markdownEdit: I tested it under Chrome and it finished significantly faster than Firefox, but still quite slow (7 seconds).
I believe it is a combination of malformed input and an exponential-runtime regexp combining to hang the parser. I tried to strip the markdown to the exact syntax that breaks the parser, but it's difficult to narrow down. The reason I suspect it's a run-away regexp is that removing obvious non-syntax like the strings of plain alphabetic words allows it to finish, but only after 30+ seconds of processing.
(for anyone curious, the markdown is from some old notes I had on the AREXX programming language)
To Reproduce
Steps to reproduce the behavior:
Parse this (be careful):
Test string at marked.js.org/demo
I'm running 0.6.2 downloaded from jsdelivr (the header says "/npm/marked@0.6.2/lib/marked.js"), however it's apparently also broken in the demo. I'm doing all this under Firefox 67 but it appears to hang Chrome, too.
Expected behavior
Totally screwy marked up text, but not exponential runtime.
The text was updated successfully, but these errors were encountered: