SWC HTML minifier may allow script element breakout when minifying embedded JSONGHSA-5qr2-v392-m9g8
MEDIUMFix: swc-project/swc#12080GHSA-5qr2-v392-m9g8 is a medium-severity (CVSS 6.1) Cross-site Scripting (XSS) vulnerability in swc_html_minifier. A fix is available for swc_html_minifier — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-5qr2-v392-m9g8.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
GHSA-5qr2-v392-m9g8 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 394,803 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
@swc/htmlnpmDescription
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/html1.15.47swc_html_minifier59.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,
});
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🦀crates.io | swc_html_minifier | all versions | 59.0.0cargo update -p swc_html_minifier --precise 59.0.0 |
| 📦npm | @swc/html | all versions | 1.15.47-nightly-20260729.1npm install @swc/html@1.15.47-nightly-20260729.1 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for swc_html_minifier, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update swc_html_minifier to 59.0.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-5qr2-v392-m9g8 is resolved across your whole dependency graph.
Workarounds
Escape or sanitise the affected output on the server side rather than relying on client-side filtering, and add a Content-Security-Policy that blocks inline script execution so injected markup cannot run even if it reaches the page.
Frequently Asked Questions
Is GHSA-5qr2-v392-m9g8 in your dependencies?
Find it across crates.io, npm, including transitive dependencies.