Regex Timeout are too short, not consistent, and not configurable in RewriteMiddleware
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
Regex timeouts that are used across [UrlRewrite](https://github.com/aspnet/BasicMiddleware/blob/dev/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteRuleBuilder.cs#L13), ApacheModRewrite, and [code rules](https://github.com/aspnet/BasicMiddleware/blob/03b63e2c2a5ec27deef4be692ff2119188b67d73/src/Microsoft.AspNetCore.Rewrite/Internal/RewriteRule.cs) are not consistent. The are set at 1 second or 1 millisecond in different places. Secondly, 1 millisecond is too short for a regex expression; it should be 1 second as the timeout is mostly for making sure your server isn't locked. Also if the expression timeouts, it returns a 500 server error as the exception is unhandled. Thirdly, the timeout should be configurable in RewriteOptions.
Plan of action:
- Timeouts should be increased to 1 second across the board.
- For 2.1, we should make Regex timeouts configurable a
- The timeouts should be backported to 2.0 and 1.1
@Eilon @muratg this is a patch candidate. Workarounds are very difficult.
Contributor guide
Assessment
This issue has not been assessed yet.