File: CVE-2021-29060.patch

package info (click to toggle)
node-color-string 1.5.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 152 kB
  • sloc: javascript: 304; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,936 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Description: fix ReDos in hwb() parser (low-severity)
 .
 Discovered by Yeting Li, c/o Colin Ife via Snyk.io.
 .
 A ReDos (Regular Expression Denial of Service) vulnerability
 was responsibly disclosed to me via email by Colin on
 Mar 5 2021 regarding an exponential time complexity for
 linearly increasing input lengths for `hwb()` color strings.
 .
 Strings reaching more than 5000 characters would see several
 milliseconds of processing time; strings reaching more than
 50,000 characters began seeing 1500ms (1.5s) of processing time.
 .
 The cause was due to a the regular expression that parses
 hwb() strings - specifically, the hue value - where
 the integer portion of the hue value used a 0-or-more quantifier
 shortly thereafter followed by a 1-or-more quantifier.
 .
 This caused excessive backtracking and a cartesian scan,
 resulting in exponential time complexity given a linear
 increase in input length.
Author: Josh Junon <junon@wavetilt.com>
Origin: upstream, https://github.com/Qix-/color-string/commit/0789e212
Bug: https://github.com/yetingli/PoCs/blob/main/CVE-2021-29060/Color-String.md
Forwarded: not-needed
Reviewed-By: Yadd <yadd@debian.org>
Last-Update: 2021-06-27

--- a/index.js
+++ b/index.js
@@ -129,7 +129,7 @@
 		return null;
 	}
 
-	var hsl = /^hsla?\(\s*([+-]?(?:\d*\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
+	var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
 	var match = string.match(hsl);
 
 	if (match) {
@@ -150,7 +150,7 @@
 		return null;
 	}
 
-	var hwb = /^hwb\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
+	var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
 	var match = string.match(hwb);
 
 	if (match) {