Debian Codegraph @

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

raw
1 From: CPANSec Security Scanner Bot <[email protected]>
2 Subject: [PATCH] Date::Manip: restrict numeric date fields to ASCII digits
3
4 CVE-2026-60074. The parse regexes capture year, month and day with the
5 \d shorthand, which on a character string matches the whole Unicode
6 decimal digit property \p{Nd} and not just [0-9].
7 Date::Manip::Base::check validates the captured fields with numeric
8 comparisons alone, and _parse_check stores the numified fields, so a
9 field whose leading characters are ASCII digits numifies to an in-range
10 prefix and satisfies every test. With U+0664 ARABIC-INDIC DIGIT FOUR as
11 the final character of the year, ParseDate("202\x{664}-03-08") returns
12 0202030800:00:00; a non-ASCII digit in the month or day field shifts
13 those fields the same way ("2026-1\x{662}-08" returns January,
14 "2026-03-1\x{665}" returns the 1st), and one in a fractional minute
15 field drops the fraction.
16
17 Fix: spell every numeric field capture in the date and time parsers as
18 [0-9] rather than \d, so a field holding a non-ASCII digit fails to
19 match and the string does not parse. Both validators are hardened as
20 well, since Date::Manip::Date's set() passes caller supplied values
21 straight to them: check() requires the year, month and day to be ASCII
22 digit strings before range testing them, and check_time() uses [0-9] in
23 its format test.
24
25 Every date string in a 42 entry corpus of legitimate formats (ISO 8601
26 basic and extended, ordinal and week dates, m/d/y, RFC 2822 with a
27 numeric offset, ctime, named months and zones, "1st Sunday in March
28 2026", "in 3 days", "noon", 24:00 times, fractional hours and minutes)
29 parses to the same value before and after.
30
31 Origin: https://security.metacpan.org/patches/D/Date-Manip/6.99/CVE-2026-60074-r1.patch
32 Bug-Debian: https://bugs.debian.org/1143125
33 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2026-60074
34
35 diff --git a/lib/Date/Manip/Base.pm b/lib/Date/Manip/Base.pm
36 index 4195056..5de1637 100644
37 --- a/lib/Date/Manip/Base.pm
38 +++ b/lib/Date/Manip/Base.pm
39 @@ -603,6 +603,15 @@ sub check {
40 my($self,$date) = @_;
41 my($y,$m,$d,$h,$mn,$s) = @$date;
42
43 + # The range tests below numify each field, and numifying truncates a
44 + # string at the first character which is not an ASCII digit, so a
45 + # field such as "202\x{664}" would pass them as 202. Require ASCII
46 + # digits.
47 +
48 + foreach my $val ($y,$m,$d) {
49 + return 0 if (! defined($val) || $val !~ /^[0-9]+$/);
50 + }
51 +
52 return 0 if (! $self->check_time([$h,$mn,$s]) ||
53 $y<1 || $y>9999 ||
54 $m<1 || $m>12);
55 @@ -617,7 +626,7 @@ sub check_time {
56 my($self,$hms) = @_;
57 my($h,$mn,$s) = @$hms;
58
59 - return 0 if ("$h:$mn:$s" !~ /^\d\d?:\d\d?:\d\d?$/o ||
60 + return 0 if ("$h:$mn:$s" !~ /^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/o ||
61 $h > 24 || $mn > 59 || $s > 59 ||
62 ($h == 24 && ($mn || $s)));
63 return 1;
64 diff --git a/lib/Date/Manip/Date.pm b/lib/Date/Manip/Date.pm
65 index 7699921..ead5e11 100644
66 --- a/lib/Date/Manip/Date.pm
67 +++ b/lib/Date/Manip/Date.pm
68 @@ -837,16 +837,16 @@ BEGIN {
69 ###
70
71 if ($f eq 'Y') {
72 - $re .= '(?<y>\d\d\d\d)';
73 + $re .= '(?<y>[0-9]{4})';
74
75 } elsif ($f eq 'y') {
76 - $re .= '(?<y>\d\d)';
77 + $re .= '(?<y>[0-9]{2})';
78
79 } elsif ($f eq 'm') {
80 - $re .= '(?<m>\d\d)';
81 + $re .= '(?<m>[0-9]{2})';
82
83 } elsif ($f eq 'f') {
84 - $re .= '(?:(?<m>\d\d)| ?(?<m>\d))';
85 + $re .= '(?:(?<m>[0-9]{2})| ?(?<m>[0-9]))';
86
87 } elsif (exists $mon_form{$f}) {
88 my $abb = $$dmb{'data'}{'rx'}{'month_abb'}[0];
89 @@ -854,13 +854,13 @@ BEGIN {
90 $re .= "(?:(?<mon_name>$nam)|(?<mon_abb>$abb))";
91
92 } elsif ($f eq 'j') {
93 - $re .= '(?<doy>\d\d\d)';
94 + $re .= '(?<doy>[0-9]{3})';
95
96 } elsif ($f eq 'd') {
97 - $re .= '(?<d>\d\d)';
98 + $re .= '(?<d>[0-9]{2})';
99
100 } elsif ($f eq 'e') {
101 - $re .= '(?:(?<d>\d\d)| ?(?<d>\d))';
102 + $re .= '(?:(?<d>[0-9]{2})| ?(?<d>[0-9]))';
103
104 } elsif (exists $day_form{$f}) {
105 my $abb = $$dmb{'data'}{'rx'}{'day_abb'}[0];
106 @@ -876,41 +876,41 @@ BEGIN {
107 $re .= "(?<nth>$nth)"
108
109 } elsif ($f eq 'H' || $f eq 'I') {
110 - $re .= '(?<h>\d\d)';
111 + $re .= '(?<h>[0-9]{2})';
112
113 } elsif ($f eq 'k' || $f eq 'i') {
114 - $re .= '(?:(?<h>\d\d)| ?(?<h>\d))';
115 + $re .= '(?:(?<h>[0-9]{2})| ?(?<h>[0-9]))';
116
117 } elsif ($f eq 'p') {
118 my $ampm = $$dmb{data}{rx}{ampm}[0];
119 $re .= "(?<ampm>$ampm)";
120
121 } elsif ($f eq 'M') {
122 - $re .= '(?<mn>\d\d)';
123 + $re .= '(?<mn>[0-9]{2})';
124
125 } elsif ($f eq 'S') {
126 - $re .= '(?<s>\d\d)';
127 + $re .= '(?<s>[0-9]{2})';
128
129 } elsif (exists $z_form{$f}) {
130 $re .= $dmt->_zrx('zrx');
131
132 } elsif ($f eq 's') {
133 - $re .= '(?<epochs>\d+)';
134 + $re .= '(?<epochs>[0-9]+)';
135
136 } elsif ($f eq 'o') {
137 - $re .= '(?<epocho>\d+)';
138 + $re .= '(?<epocho>[0-9]+)';
139
140 } elsif ($f eq 'G') {
141 - $re .= '(?<g>\d\d\d\d)';
142 + $re .= '(?<g>[0-9]{4})';
143
144 } elsif ($f eq 'W') {
145 - $re .= '(?<w>\d\d)';
146 + $re .= '(?<w>[0-9]{2})';
147
148 } elsif ($f eq 'L') {
149 - $re .= '(?<l>\d\d\d\d)';
150 + $re .= '(?<l>[0-9]{4})';
151
152 } elsif ($f eq 'U') {
153 - $re .= '(?<u>\d\d)';
154 + $re .= '(?<u>[0-9]{2})';
155
156 } elsif ($f eq 'c') {
157 $format = '%a %b %e %H:%M:%S %Y' . $format;
158 @@ -1168,15 +1168,15 @@ sub _iso8601_rx {
159
160 if ($rx eq 'cdate' || $rx eq 'tdate') {
161
162 - my $y4 = '(?<y>\d\d\d\d)';
163 - my $y2 = '(?<y>\d\d)';
164 + my $y4 = '(?<y>[0-9]{4})';
165 + my $y2 = '(?<y>[0-9]{2})';
166 my $m = '(?<m>0[1-9]|1[0-2])';
167 my $d = '(?<d>0[1-9]|[12][0-9]|3[01])';
168 my $doy = '(?<doy>00[1-9]|0[1-9][0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-6])';
169 my $w = '(?<w>0[1-9]|[1-4][0-9]|5[0-3])';
170 my $dow = '(?<dow>[1-7])';
171 - my $yod = '(?<yod>\d)';
172 - my $cc = '(?<c>\d\d)';
173 + my $yod = '(?<yod>[0-9])';
174 + my $cc = '(?<c>[0-9]{2})';
175
176 my @cdaterx =
177 (
178 @@ -1238,9 +1238,9 @@ sub _iso8601_rx {
179 my $h24b = '(?<h24>24(?:00){0,2})';
180 my $h = '(?<h>[0-9])';
181
182 - my $fh = '(?:[\.,](?<fh>\d*))'; # fractional hours (keep)
183 - my $fm = '(?:[\.,](?<fm>\d*))'; # fractional seconds (keep)
184 - my $fs = '(?:[\.,]\d*)'; # fractional hours (discard)
185 + my $fh = '(?:[\.,](?<fh>[0-9]*))'; # fractional hours (keep)
186 + my $fm = '(?:[\.,](?<fm>[0-9]*))'; # fractional seconds (keep)
187 + my $fs = '(?:[\.,][0-9]*)'; # fractional hours (discard)
188
189 my $zrx = $dmt->_zrx('zrx');
190
191 @@ -1445,9 +1445,9 @@ sub _other_rx {
192 $f1 = "[.,]";
193 $f2 = "[.,:]";
194 }
195 - my $fh = "(?:$f1(?<fh>\\d*))"; # fractional hours (keep)
196 - my $fm = "(?:$f1(?<fm>\\d*))"; # fractional minutes (keep)
197 - my $fs = "(?:$f2\\d*)"; # fractional seconds
198 + my $fh = "(?:$f1(?<fh>[0-9]*))"; # fractional hours (keep)
199 + my $fm = "(?:$f1(?<fm>[0-9]*))"; # fractional minutes (keep)
200 + my $fs = "(?:${f2}[0-9]*)"; # fractional seconds
201
202 # AM/PM
203
204 @@ -1533,10 +1533,10 @@ sub _other_rx {
205
206 # Do NOT replace <m> and <d> with a regular expression to
207 # match 1-12 since the DateFormat config may reverse the two.
208 - my $y4 = '(?<y>\d\d\d\d)';
209 - my $y2 = '(?<y>\d\d)';
210 - my $m = '(?<m>\d\d?)';
211 - my $d = '(?<d>\d\d?)';
212 + my $y4 = '(?<y>[0-9]{4})';
213 + my $y2 = '(?<y>[0-9]{2})';
214 + my $m = '(?<m>[0-9]{1,2})';
215 + my $d = '(?<d>[0-9]{1,2})';
216 my $sep = '(?<sep>[\s\.\/\-])';
217
218 my @daterx =
219 @@ -1555,11 +1555,11 @@ sub _other_rx {
220 my $abb = $$dmb{'data'}{'rx'}{'month_abb'}[0];
221 my $nam = $$dmb{'data'}{'rx'}{'month_name'}[0];
222
223 - my $y4 = '(?<y>\d\d\d\d)';
224 - my $y2 = '(?<y>\d\d)';
225 - my $m = '(?<m>\d\d?)';
226 - my $d = '(?<d>\d\d?)';
227 - my $dd = '(?<d>\d\d)';
228 + my $y4 = '(?<y>[0-9]{4})';
229 + my $y2 = '(?<y>[0-9]{2})';
230 + my $m = '(?<m>[0-9]{1,2})';
231 + my $d = '(?<d>[0-9]{1,2})';
232 + my $dd = '(?<d>[0-9]{2})';
233 my $mmm = "(?:(?<mmm>$abb)|(?<month>$nam))";
234 my $sep = '(?<sep>[\s\.\/\-])';
235
236 @@ -1610,7 +1610,7 @@ sub _other_rx {
237 my $abb = $$dmb{'data'}{'rx'}{'month_abb'}[0];
238 my $nam = $$dmb{'data'}{'rx'}{'month_name'}[0];
239
240 - my $y4 = '(?<y>\d\d\d\d)';
241 + my $y4 = '(?<y>[0-9]{4})';
242 my $mmm = "(?:(?<mmm>$abb)|(?<month>$nam))";
243 my $sep = '(?<sep>[\s\.\/\-])';
244
245 @@ -1656,11 +1656,11 @@ sub _other_rx {
246 my $special = $$dmb{'data'}{'rx'}{'offset_time'}[0];
247
248 $special = "(?<special>$special)";
249 - my $secs = "(?<epoch>[-+]?\\d+)";
250 + my $secs = "(?<epoch>[-+]?[0-9]+)";
251 my $abb = $$dmb{'data'}{'rx'}{'month_abb'}[0];
252 my $mmm = "(?<mmm>$abb)";
253 - my $y4 = '(?<y>\d\d\d\d)';
254 - my $dd = '(?<d>\d\d)';
255 + my $y4 = '(?<y>[0-9]{4})';
256 + my $dd = '(?<d>[0-9]{2})';
257 my $h24 = '(?<h>2[0-3]|[01][0-9])'; # 00-23
258 my $mn = '(?<mn>[0-5][0-9])'; # 00-59
259 my $ss = '(?<s>[0-5][0-9])'; # 00-59
260 @@ -1697,7 +1697,7 @@ sub _other_rx {
261 my $nth_wom = $$dmb{'data'}{'rx'}{'nth_wom'}[0];
262 my $special = $$dmb{'data'}{'rx'}{'offset_date'}[0];
263
264 - my $y = '(?:(?<y>\d\d\d\d)|(?<y>\d\d))';
265 + my $y = '(?:(?<y>[0-9]{4})|(?<y>[0-9]{2}))';
266 my $mmm = "(?:(?<mmm>$abb)|(?<month>$nam))";
267 $next = "(?<next>$next)";
268 $last = "(?<last>$last)";
269 @@ -1732,7 +1732,7 @@ sub _other_rx {
270 # nth day in MMM [YYYY]
271
272 "${nth}\\s+${wf}\\s*$y?", # DoW Nth week [YYYY]
273 - "${wf}\\s+(?<n>\\d+)\\s*$y?", # DoW week N [YYYY]
274 + "${wf}\\s+(?<n>[0-9]+)\\s*$y?", # DoW week N [YYYY]
275
276 "${special}", # today, tomorrow
277 "${special}\\s+${wf}", # today week