All vulnerabilities

npm

CVE-2026-140010

HTML Minifier Next: Regular expressions in `minify()` cause O(n²) backtracking on ignored and custom-fragment content

Severity
High
Published
1 Dec 2026
Last changed
1 Dec 2026
Added to UpHeron
1 Dec 2026
Fixed in
5.0.1, 9.1.2
Exploit chance
0.5% in the next 30 daysHigher than 43% of CVEs. EPSS by FIRST, 1 Dec 2026
Weakness
Regular expression denial of service (ReDoS) (CWE-1333)
Also known as
GHSA-9wmg-23wv-h297
Sources
OSV.dev and GitHub

Description

html-minifier-next finds the last HTML tag inside htmlmin:ignore blocks with the expression /[\s\S]<(\/?[a-zA-Z][\w:-])/. A large ignore block without a matching tag makes the greedy prefix rescan the content, so the public minify() API takes about 89 seconds for 256 KB.

A second expression with the same flaw, /^(\s*)[\s\S]?(\s)$/, splits whitespace off matches of ignoreCustomFragments. A long whitespace run inside such a fragment triggers it with default options, since the default fragments cover <? … ?> and <% … %> (64 KB: about 3.3 s).

A modest attacker-controlled input drives superlinear or unbounded regular-expression backtracking (or recursive stack exhaustion), occupying a CPU core for seconds to minutes and enabling denial of service against the affected service or library consumer.

From the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
html-minifiernpm · osv:npm:html-minifier
  • From 3.1.1 before 5.0.1
html-minifier-nextnpm · osv:npm:html-minifier-next
  • Every version before 9.1.2

About html-minifier

Weekly downloads (npm)
3,061,978npm, 1 Dec 2026

This is the only vulnerability in html-minifier in our list.

About html-minifier-next

Weekly downloads (npm)
86,813npm, 1 Dec 2026

This is the only vulnerability in html-minifier-next in our list.

References