Re:Python, Catastrophic Regular Expressions and the GIL (2013)
by Alex3917 on Monday November 14, 2022 @07:17AM
(#33592958)
While atomic grouping can prevent this from happening again once you've already found the problem, the real solution is just making sure there is a timeout on your web process. That way even if you hit catastrophic backtracking, your servers aren't going to be unavailable unless someone is purposely reDOSing them.
Re:Python, Catastrophic Regular Expressions and the GIL (2013)
by tyingq on Monday November 14, 2022 @08:23AM
(#33593535)
This paper goes over the Cloudflare outage, and other runaway regex CVEs with MediaWiki, Stackoverflow, and the Atom editor:
https://vtechworks.lib.vt.edu/bitstream/handle/10919/98593/D...
Re:Python, Catastrophic Regular Expressions and the GIL (2013)
by execveat on Monday November 14, 2022 @09:13AM
(#33594144)
There's a cool tool to detect regexes like these in your code: https://github.com/doyensec/regexploit
(disclosure: I work for Doyensec)
Python `re` module now supports possessive quantifiers and atomic grouping (I wrote a blog post here [2]). So, for example, `(a+|\w+)*+:` instead of `(a+|\w+)*:` will avoid such catastrophic behavior.
[1] https://blog.cloudflare.com/details-of-the-cloudflare-outage...
[2] https://learnbyexample.github.io/python-regex-possessive-qua...