$ ./guess_the_languageCybersecurity
Cybersecurity · hard · #317

Why can this regex freeze a server on that input?

^(a+)+$   tested against  "aaaaaaaaaaaaaaaaaaaaaaaa!"
  1. It allocates a huge capture
  2. Nested quantifiers backtrack exponentially
  3. Anchors force a full rescan of each line
  4. The long input string overflows a fixed buffer
When the match fails at the end, the engine tries every way to split the a's between the inner and outer groups: a regular-expression denial of service (ReDoS).
Play Cybersecurity ▸