SWC HTML minifier may allow script element breakout when minifying embedded JSON
swc-project swc · @swc html · swc-project swc_html_minifier
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| @swc/html npm |
|
|
| swc_html_minifier crates.io |
|
|
swc-project swc · @swc html · swc-project swc_html_minifier
| Product | Affected | Fixed in |
|---|---|---|
| @swc/html npm |
|
|
| swc_html_minifier crates.io |
|
|
SWC is a TypeScript / JavaScript compiler written in Rust. Prior to @swc/html 1.15.47-nightly-20260729.1 and swc_html_minifier 59.0.0, the minifyJson processing in crates/swc_html_minifier/src/lib.rs parsed and serialized attacker-controlled JSON in application/json and application/ld+json script elements without the escape_json_for_html_script behavior to re-escape less-than signs, allowing a closing script sequence to terminate the element early and execute script in the generated page's origin. This issue is fixed in @swc/html 1.15.47-nightly-20260729.1 and swc_html_minifier 59.0.0.
From the CVE record · GitHub_M
SWC HTML minification processes attacker-controlled JSON in application/json and application/ld+json script elements without re-escaping less-than signs. A closing script sequence can terminate the element early and execute script in the generated page's origin when that page is viewed.
Check applications using npm @swc/html before 1.15.47-nightly-20260729.1 or crates.io swc_html_minifier before 59.0.0.