ReDoS occurs when an attacker supplies input that causes a non-deterministic regular expression engine to perform an excessive amount of work. Backtracking engines can take exponentially longer on carefully constructed near-matches.
The purpose is to consume CPU resources, tie up application workers, delay requests, or make a service unavailable.
Nested repetition can cause the regex engine to explore many alternative ways to match the same input.
(a+)+$
(.*)*
([a-zA-Z]+)+$
Example near-match input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
Alternatives that share prefixes can cause extensive backtracking when repeated.
(a|aa)+$
(a|a?)+$
(ab|a)+$
Example near-match input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac
Repeated wildcards and optional groups can create many possible matching paths.
(.*a){10}$
(.+)*END$
(a.*a)+$
Even without catastrophic backtracking, extremely large patterns and log lines can consume excessive memory and CPU.
Pattern length: 100000 characters
Log line length: 10000000 characters
https://www.imperva.com/learn/ddos/regular-expression-denial-of-service-redos/