ReDoS in Node.js and Next.js: Catastrophic Backtracking, Event Loop Stalls, and User-Supplied Patterns [2026]
ReDoS is the cheapest denial of service there is: one 40-character string against a single regex can pin a Node.js process at 100% CPU and take down every request behind it, because regex evaluation is synchronous and cannot be cancelled. This guide traces how V8's backtracking engine turns `^(a+)+$` into 2^n work, shows the five regex shapes that blow up, and gives the layered fix — enumerate the filter language instead of accepting patterns, compile untrusted patterns with RE2, bound pattern and input length, budget every user regex in a terminating worker, and lint the codebase for super-linear backtracking.