html-minifier icon indicating copy to clipboard operation
html-minifier copied to clipboard

CVE-2022-37620/ ReDoS found in htmlminifier.js

Open secdevlpr26 opened this issue 3 years ago • 29 comments

A Regular Expression Denial of Service (ReDoS) flaw was found in kangax html-minifier 4.0.0 via the candidate variable in htmlminifier.js. The ReDoS vulnerability can be mitigated with several best practices described here: [https://snyk.io/blog/redos-and-catastrophic-backtracking/]

secdevlpr26 avatar Oct 27 '22 18:10 secdevlpr26

Is anyone willing to work on this?

michaeljauk avatar Nov 18 '22 20:11 michaeljauk

Any update on this?

blv-raulcatalan avatar Mar 14 '23 16:03 blv-raulcatalan

One of the lines referred to be the CVE has the following regex \s+([1-9][0-9]*w|[0-9]+(?:\.[0-9]+)?x)$

Would changing it to \s+([1-9][0-9]*w|[0-9]+(?:\.[0-9]+|)x)$ be enough?

\s+([1-9][0-9]*w|[0-9]+(?=(\.[0-9]+|))\2x)$ is another way that should stop the backtracking (based this upon https://snyk.io/blog/redos-and-catastrophic-backtracking/.

rquadling avatar Mar 22 '23 12:03 rquadling

I stumbled upon a fork of this maintained by terser: https://www.npmjs.com/package/html-minifier-terser

Probably the way to go.

timbomckay avatar Apr 10 '23 17:04 timbomckay

any updates?

littleblack111 avatar May 14 '24 05:05 littleblack111

any updates?

@littleblack111 as mentioned above, along with the slew of references to others switching, html-minifier-terser is probably the best solution. Aside from some repo adjustments this solution appears to be fairly abandoned, especially since the package hasn't been updated in 5 years, while html-minified-terser is maintained by Terser.

timbomckay avatar May 14 '24 15:05 timbomckay

Now I've just got to remember what project I'm involved in that has this one as an issue!

rquadling avatar May 14 '24 17:05 rquadling

any update on this issue?

Hessah95 avatar May 15 '24 11:05 Hessah95

any update on this issue?

@Hessah95 The comments in this thread point to another solution that's maintained.

timbomckay avatar May 15 '24 13:05 timbomckay