This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Description
The following regular expressions used for parsing the user agent are vulnerable to ReDoS:
/(?: BePC|[ .]*fc[ \d.]+)$/i
/^ +| +$/g
The slowdown is moderate (for 50,000 characters around 4 seconds matching time). However an attacker can easily control the value of the headers he sends. I would suggest one of the following:
- remove the regex,
- anchor the regex,
- limit the number of characters that can be matched by the repetition,
- limit the input size.
If needed, I can provide an actual example showing the slowdown.