Description
RE2 (https://github.com/google/re2) is a regular expression engine written in C++ and developed by Google.
Unlike libpcre, RE2 runtime is always linear to the size of the input. It comes at some cost: the engine inherently doesn't support certain features, like backreferences and lookaround assertions.
Still, even the CRS has some regular expressions in its rules that run very slowly (minutes) on certain inputs, but are supported by RE2 and run much faster (seconds) on the same inputs.
The idea of adding RE2 support to ModSecurity has been floating around for a while, and there's quite a few mentions of people working on things related to it:
- Mark patterns not supported by re2 SpiderLabs/owasp-modsecurity-crs#1255
- Regex: Only escape characters when necessary SpiderLabs/owasp-modsecurity-crs#1130
I have been unable to find neither issue nor public pull request/fork/branch of ModSecurity with RE2 support.
I have a more-or-less working proof-of-concept patch for ModSecurity with optional RE2 support (with fallback to libpcre if the regexp fails to compile on RE2).
Is someone else working on this? Because if yes, it's probably not worth it to duplicate efforts. If not, I think I can clean up my patch a bit and submit it here as a PR.