GHSA-5qr2-v392-m9g8: XSS

Published Sep 8, 2026
·
Updated

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 - swchtmlminifier 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:

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

Affected Software

2 affected componentsFixes available
rust/swc_html_minifier<59.0.0
59.0.0
npm/@swc/html<1.15.47-nightly-20260729.1
1.15.47-nightly-20260729.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rust/swc_html_minifier to a version that resolves this vulnerability.

    Fixed in 59.0.0
  2. Upgrade

    Upgrade npm/@swc/html to a version that resolves this vulnerability.

    Fixed in 1.15.47-nightly-20260729.1
  3. Upgrade

    Upgrade @swc/html to a version that resolves this vulnerability.

    Fixed in 1.15.47
  4. Upgrade

    Upgrade swc_html_minifier to a version that resolves this vulnerability.

    Fixed in 59.0.0
  5. Configuration

    Disable JSON minification by setting `minifyJson: false` in the `@swc/html` `minify(html, { ... })` options.

    @swc/html minifyJson = false

Event History

Sep 8, 2026
Advisory Published
via GitHub·05:58 PM
Data Sourced
via GitHub·05:58 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which applications are exposed to this issue?

Applications are exposed when they minify HTML containing attacker-controlled JSON inside script elements, including application/json or application/ld+json. The risk is that inert JSON data can be transformed into active markup in the generated page.

2

What must an attacker control to exploit the issue?

An attacker needs to influence JSON embedded in the HTML being minified and supply a crafted value containing an escaped </script> sequence. During JSON serialization, escaped less-than signs can become literal < characters, allowing the script element to be terminated early.

3

How can this be mitigated if an upgrade is not immediately possible?

Disable JSON minification by setting minifyJson: false in the minifier options. This prevents the vulnerable JSON parsing and serialization path from being used.

4

What versions contain the fix?

The issue is fixed in @swc/html 1.15.47 and swc_html_minifier 59.0.0. The fix re-escapes less-than signs after JSON serialization to preserve the script element boundary.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203