Vulnerabilities in pkg:npm/html-minifier-next
PACKAGECVE-2026-140010 is a HIGH regular expressions vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting HTML Minifier Next libraries in the npm ecosystem. The issue involves regular expressions in `minify()` cause o(n²) backtracking on ignored and custom-fragment content. Remediation is available by upgrading affected packages to version 9.1.2, 5.0.1.
pkg:npm/html-minifier-next
Vulnerability advisories affecting package pkg:npm/html-minifier-next. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-9wmg-23wv-h297 | CVE-2026-140010 | HIGH | HTML Minifier Next: Regular expressions in `minify()` cause O(n²) backtracking on ignored and custom-fragment content |
CVE-2026-140010 at a Glance
How to Fix CVE-2026-140010
To remediate this vulnerability, upgrade all affected HTML Minifier Next dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install html-minifier-next@9.1.2
npm install html-minifier@5.0.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls html-minifier-next
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-140010, inspect your project dependencies using npm:
npm ls html-minifier-next
Analyze the terminal output to locate any version of HTML Minifier Next in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.1.2), your application is affected.
Note: The npm ls html-minifier-next command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In HTML Minifier Next, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-140010 Affected HTML Minifier Next Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
html-minifier-next
|
npm |
< 9.1.2
|
9.1.2
|
|
html-minifier
|
npm |
≥ 3.1.1
< 5.0.1
|
5.0.1
|
References
Frequently Asked Questions
What is CVE-2026-140010?
Which HTML Minifier Next versions are affected?
What version fixes CVE-2026-140010?
Is html-minifier-next affected?
Is html-minifier affected?
What CWE is associated with CVE-2026-140010?
How can I check npm dependencies for CVE-2026-140010?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-9wmg-23wv-h297",
"modified" : "2026-12-01T17:56:57Z",
"published" : "2026-12-01T17:56:57Z",
"aliases" : [ "CVE-2026-140010" ],
"summary" : "HTML Minifier Next: Regular expressions in `minify()` cause O(n²) backtracking on ignored and custom-fragment content",
"details" : "## Summary\n\nhtml-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.\n\nA 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).\n\n## Affected component and version\n\n- Repository: `j9t/html-minifier-next`\n- Affected version(s): Affected version(s): all releases up to and including 9.1.1\n- Component: src/htmlminifier.js:691 (`RE_LAST_HTML_TAG`), :1795 (exec on `htmlmin:ignore` content, requires `collapseWhitespace`); src/htmlminifier.js:1279 (whitespace split of `ignoreCustomFragments` matches, default options)\n- Status: the vulnerable expression is present at the referenced revision; no fix was identified at the time of reporting.\n\nhtml-minifier is affected as well: The custom-fragment issue dates back to html-minifier 3.1.1, and 5.0.0, rebuilt on HTML Minifier Next 9.1.1, carries both.\n\n## Reproduction input\n\nminify() on a document containing a large htmlmin:ignore block whose content is plain text with no '<tag' terminator (N=256000 characters).\n\n## Measured timings\n\nThe following values were measured against the real code path described above. Times are wall-clock milliseconds.\n\n```\nnode e2e_htmlmin2.mjs → \"n=4000 len=4021 ms=5.8 / n=8000 len=8021 ms=20.8 / n=16000 len=16021 ms=92.7 / n=32000 len=32021 ms=333.0\";node -e(64000/128000/256000)→ 1461 / 16511 / 89226 ms。源码 src/htmlminifier.js:691 `const RE_LAST_HTML_TAG = /[\\s\\S]*<(\\/?[a-zA-Z][\\w:-]*)/;`,使用点 :1795 `RE_LAST_HTML_TAG.exec(content)`;公开入口 :2997 `export const minify = async function (value, options)`。control(短 ignore 块)ms<1。\n```\n\nAdditional finding (maintainer)\n\nInput: `<p><?php a' + ' '.repeat(n) + 'a ?></p>`, minify() with default options.\n\nn=8000: 67 ms · n=16000: 206 ms · n=32000: 840 ms · n=64000: 3332 ms\n\nThe lazy `[\\s\\S]?` retries `(\\s)$` across the whole whitespace run at each step.\n\n## Impact\n\nA 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.\n\n## Suggested fix\n\nReplace the ambiguous expression with an unambiguous, linear-time equivalent (bounded character classes, possessive or atomic groups, or an index-based scanner), enforce a length limit at the entry point, and add a regression test using the adversarial input above.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "html-minifier-next"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "9.1.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 9.1.1"
}
}, {
"package" : {
"ecosystem" : "npm",
"name" : "html-minifier"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.1.1"
}, {
"fixed" : "5.0.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/j9t/html-minifier-next/security/advisories/GHSA-9wmg-23wv-h297"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-140010"
}, {
"type" : "WEB",
"url" : "https://github.com/j9t/html-minifier-next/commit/28417322a9b0291de8b0d1c0694e09855d925545"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/j9t/html-minifier-next"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1333" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-01T17:56:57Z",
"nvd_published_at" : "2026-11-30T22:17:30Z"
}
}