Regular Expressions: Excessive backtracking can get yourself in trouble

Updated . Posted . Visible to the public.

Two weeks ago, Cloudflare was struck by a global outage that lasted ~30 minutes. The incident was rooted on a CPU exhaustion caused by a single regular expression containing some catastrophic backtracking Show archive.org snapshot :

.*(?:.*=.*)

This is a small reminder do keep using the lazy operator ? whenever possible and furthermore be aware that regular expressions should not only be unit-tested but also evaluated in terms of performance. See https://makandracards.com/makandra/494822-regular-expressions-quantifier-modes for more details.

Michael Leimstädtner
Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Michael Leimstädtner to makandra dev (2019-07-14 08:15)