Read more

Regular Expressions: Excessive backtracking can get yourself in trouble

Michael Leimstädtner
July 14, 2019Software engineer at makandra GmbH

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 :

.*(?:.*=.*)
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more 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.

Posted by Michael Leimstädtner to makandra dev (2019-07-14 10:15)