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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)