Dart's built-in regex engine vulnerable to ReDoS; RE2 FFI binding offers linear-time fix
Dart's default RegExp engine uses backtracking, which can cause catastrophic slowdowns on certain inputs — a vulnerability known as ReDoS. A 31-character crafted string takes over 5 seconds to reject against a common word-list validator pattern, and some patterns never finish at all. Google's RE2 library, now available as a Dart FFI package, matches in linear time regardless of input, processing the same 31-character case in about 25 microseconds. Unlike dart:core's RegExp, RE2 rejects unsafe patterns such as backreferences at construction time rather than failing silently under load. The package also provides utilities like Re2.escape() and a compiled program size cap to further protect against untrusted input.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in