Skip to content

fix(deps): update dependency html-minifier to v5 [security] - #895

Closed
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-html-minifier-vulnerability
Closed

renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-html-minifier-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
html-minifier (source) ^4.0.0 → ^5.0.0 age confidence

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

CVE-2026-140010 / GHSA-9wmg-23wv-h297

More information

Details

Summary

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).

Affected component and version
  • Repository: j9t/html-minifier-next
  • Affected version(s): Affected version(s): all releases up to and including 9.1.1
  • 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)
  • Status: the vulnerable expression is present at the referenced revision; no fix was identified at the time of reporting.

html-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.

Reproduction input

minify() on a document containing a large htmlmin:ignore block whose content is plain text with no '<tag' terminator (N=256000 characters).

Measured timings

The following values were measured against the real code path described above. Times are wall-clock milliseconds.

node 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。

Additional finding (maintainer)

Input: <p><?php a' + ' '.repeat(n) + 'a ?></p>, minify() with default options.

n=8000: 67 ms · n=16000: 206 ms · n=32000: 840 ms · n=64000: 3332 ms

The lazy [\s\S]? retries (\s)$ across the whole whitespace run at each step.

Impact

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.

Suggested fix

Replace 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

  • CVSS Score: 8.7 / 10 (High)
  • Vector String: 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

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

j9t/html-minifier (html-minifier)

v5.0.1

Compare Source

Fixed
  • Fixed two regular expression denial-of-service (ReDoS) issues (GHSA-9wmg-23wv-h297—thanks @​aweiaaaaa), each causing quadratic (O(n²)) backtracking on the minify() path, now replaced by linear-time scans:
    • A long htmlmin:ignore block without tags, with collapseWhitespace enabled
    • A long whitespace run inside an ignoreCustomFragments match, with default options

v5.0.0

Compare Source

Fixed
  • Fixed decodeEntities (and minifyJS, in event handler attributes) turning an escaped ampersand into one that starts a character reference, which changed the value browsers read (e.g., title="&amp;copy b" → title="&copy b", read as “© b,” now kept; and in text, &amp;#&#8203;169 → &#&#8203;169, now &amp#169)
  • Fixed decodeEntities (and minifyJS, in event handler attributes) leaving character references without a semicolon in attributes undecoded where browsers decode them (e.g., title="&copy b", now title="© b")
Changed

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot added the dependencies Pull requests that update a dependency file label Dec 1, 2026
@leomp12

leomp12 commented Dec 1, 2026

Copy link
Copy Markdown
Member

Substituído pelo #896, que remove o html-minifier do SSR em vez de subir para a v5 (detalhes no PR).

@leomp12 leomp12 closed this Dec 1, 2026
@renovate

renovate Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 5.x releases. But if you manually upgrade to 5.x then Renovate will re-enable minor and patch updates automatically.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

@renovate
renovate Bot deleted the renovate/npm-html-minifier-vulnerability branch December 1, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant