Debian Codegraph @

debian/patches/CVE-2026-60075-r1.patch.patch

raw
1 From: CPANSec Security Scanner Bot <[email protected]>
2 Subject: [PATCH] Date::Manip: cap the length of a string handed to the parsers
3
4 CVE-2026-60075. _parse_time removes a time from anywhere in the string
5 with the unanchored substitution s/$timerx/ /, where $timerx is an
6 auto-generated alternation of time patterns reached through a leading
7 (?:$atrx|^|\s+). The engine retries the match at every position of an
8 interior whitespace run: at each start position the leading \s+ consumes
9 the rest of the run greedily, the time alternation fails because the run
10 holds no digits, and the engine backtracks a space at a time across the
11 run before advancing the start position. The cost is quadratic in the
12 length of the run, and no time need be present in the string. On the
13 machine this patch was tested on, parsing "x" . (" " x 2000) . "x" took
14 1.7 seconds of CPU and "x" . (" " x 16000) . "x" took 107 seconds,
15 rising about fourfold for each doubling of the run.
16
17 Fix: reject a string longer than $MAXLENGTH (256) at the parse and
18 parse_time entries, before any regex runs, which is the shape of the fix
19 libwww-perl shipped in HTTP::Date 6.08 for the same weakness class.
20 Legitimate date strings are well under 100 characters, and a 42 entry
21 corpus of legitimate formats parses to the same value before and after.
22
23 Origin: https://security.metacpan.org/patches/D/Date-Manip/6.99/CVE-2026-60075-r1.patch
24 Bug-Debian: https://bugs.debian.org/1143125
25 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2026-60075
26
27 diff --git a/lib/Date/Manip/Date.pm b/lib/Date/Manip/Date.pm
28 index 7699921..859cef5 100644
29 --- a/lib/Date/Manip/Date.pm
30 +++ b/lib/Date/Manip/Date.pm
31 @@ -94,6 +94,13 @@ sub input {
32 # DATE PARSING
33 ########################################################################
34
35 +# The longest string the parsers will look at. The time matching
36 +# regexp is applied unanchored, so the cost of failing to match grows
37 +# with the square of the length of an interior whitespace run. Real
38 +# date strings are well under 100 characters.
39 +
40 +our $MAXLENGTH = 256;
41 +
42 sub parse {
43 my($self,$instring,@opts) = @_;
44 $self->_init();
45 @@ -104,6 +111,11 @@ sub parse {
46 return 1;
47 }
48
49 + if (length($instring) > $MAXLENGTH) {
50 + $$self{'err'} = '[parse] Date string too long';
51 + return 1;
52 + }
53 +
54 my %opts = map { $_,1 } @opts;
55
56 my $dmt = $$self{'tz'};
57 @@ -382,6 +394,11 @@ sub parse_time {
58 return 1;
59 }
60
61 + if (length($string) > $MAXLENGTH) {
62 + $$self{'err'} = '[parse_time] Time string too long';
63 + return 1;
64 + }
65 +
66 my($y,$m,$d,$h,$mn,$s);
67
68 if ($$self{'err'}) {