News for hackers. Stuff that matters.
Re:Python, Catastrophic Regular Expressions and the GIL (2013) by asicsp on Monday November 14, 2022 @05:47AM (#33592336)
For another real-world example, see "Details of the Cloudflare outage on July 2, 2019" [1]

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...

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)

Re:Python, Catastrophic Regular Expressions and the GIL (2013) by kh1 on Monday November 14, 2022 @09:41AM (#33594580)
The gif showing the backtracking is cool. I wonder if there's similar tool for python.