NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · npm

CVE-2026-72925: SWC HTML minifier may allow script element breakout when minifying embedded JSON

mediumCVSS 3.1 6.1GHSA-5qr2-v392-m9g8

Impact @swc/html minifies JSON contained in script elements such as application/json and application/ld+json by parsing and serializing the JSON value. Before the patched versions, JSON serialization could convert escaped less-than signs such as \u003C into literal sequence, the generated HTML could terminate the containing script element early because HTML tokenization occurs before the JSON is consumed.

Published Sep 8, 2026

Affected packages

@swc/html

Ecosystem
npm
Affected
< 1.15.47-nightly-20260729.1
Fixed in
1.15.47-nightly-20260729.1
Check
npm ls @swc/html

swc_html_minifier

Ecosystem
Rust (crates.io)
Affected
< 59.0.0
Fixed in
59.0.0
Check
cargo tree -i swc_html_minifier

Advisory details

From the GitHub Advisory Database (CC BY 4.0).

Impact

@swc/html minifies JSON contained in script elements such as application/json and application/ld+json by parsing and serializing the JSON value.

Before the patched versions, JSON serialization could convert escaped less-than signs such as \u003C into literal < characters. If the JSON contained an escaped </script> sequence, the generated HTML could terminate the containing script element early because HTML tokenization occurs before the JSON is consumed.

Applications that minify HTML containing attacker-controlled JSON data could therefore transform inert data into active markup. A crafted payload could execute script in the origin of the generated page.

Patches

The issue is fixed in:

  • @swc/html 1.15.47
  • swc_html_minifier 59.0.0

The minifier now re-escapes less-than signs after JSON serialization, preserving the script element boundary.

Workarounds

Users who cannot upgrade can disable JSON minification with:

await minify(html, {
  minifyJson: false,
});

Credited to j9t.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology