String::Util versions before 1.36 for Perl are susceptible to a regular expression denial of service
BAKERSCOT String::Util
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| BAKERSCOT String::Util |
| No fix yet |
Original description
String::Util versions before 1.36 for Perl are susceptible to a regular expression denial of service.
The trim and rtrim functions stripped trailing whitespace with s/\s*$//u. Because \s* matches greedily and the $ anchor fails whenever a non-whitespace character follows the whitespace, the regex engine retries the match at each offset of a long whitespace run, producing quadratic backtracking. The fix replaces \s*$ with \s+$.
Any caller that passes untrusted input to trim or rtrim can trigger CPU exhaustion with a string containing a long run of whitespace.
From the CVE record · CPANSec