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

[cdata re] halt with CPU 100% on some html #267

Closed
puzrin opened this issue Jan 3, 2015 · 4 comments
Closed

[cdata re] halt with CPU 100% on some html #267

puzrin opened this issue Jan 3, 2015 · 4 comments

Comments

@puzrin
Copy link
Contributor

puzrin commented Jan 3, 2015

Put this into dingus:

foo <![CDATA[ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ]>

Similar to #263, found by @rlidwka .

Seems we should seriously revisit all attempts to parse HTML with regexp.

@puzrin
Copy link
Contributor Author

puzrin commented Jan 3, 2015

markdown-it/markdown-it@89c8620

/<!\[CDATA\[[\s\S]*?\]\]>/ - this one works. Should satisfy HTML5 spec conditions. I don't know what were cutted conditions for.

@jgm
Copy link
Member

jgm commented Jan 3, 2015

A CDATA section cannot contain the string ]]>. The complex regex in the source was meant to rule that out. Your regex should work fine -- it uses non-greedy matching to the same effect. The one I used was designed for cmark and re2c, which doesn't have a non-greedy matching operator. Best solution is probably to use your regex for the js and the original one in cmark.

@puzrin
Copy link
Contributor Author

puzrin commented Jan 4, 2015

Thanks for explanation. I'm not very strong in regexps and not familiar at all with implementation differences. Didn't know that re2c does not support non-gready matches.

Please, take a look if other JS regexps are ddos-able. @rlidwka did not found anything else, but it worth to duplucate this check for sure.

@rlidwka
Copy link
Contributor

rlidwka commented Jan 4, 2015

Just for the reference:

https://en.wikipedia.org/wiki/ReDoS
https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS

I didn't find anything obvious, but a few other regexps are kinda fishy, worth checking out.

@jgm jgm closed this as completed in 918867a Jan 4, 2015
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

No branches or pull requests

3 participants