Intel

AIKIDO-2026-751689

@swc/html is vulnerable to Cross-Site Scripting (XSS)

Cross-Site Scripting (XSS)GHSA-5qr2-v392-m9g8 Published 2 days ago

61

Medium Risk

This Affects:

JS@swc/html
0.0.5 - 1.15.46
Fixed in 1.15.47
Are you affected? Scan for Free

TL;DR

The HTML minifier in @swc/html compresses JSON embedded in script elements such as application/json and application/ld+json by parsing and re-serializing the JSON value. During serialization it can turn escaped less-than sequences like \u003C back into literal < characters, so a script-closing sequence inside the JSON can terminate the containing script element early because HTML tokenization runs before the JSON is consumed. When the minified HTML embeds user-controlled JSON data, inert data can become active markup and execute script in the origin of the generated page. The fix re-escapes less-than signs after JSON serialization so the script element boundary is preserved.

Who does this affect?

You are affected if you are using a version that falls within the vulnerable range and you minify HTML that embeds user-controlled JSON inside a script element such as application/json or application/ld+json.

Background info

@swc/html is vulnerable to Cross-Site Scripting (XSS) in versions 0.0.5 - 1.15.46.

How to fix this

Upgrade the @swc/html library to the patch version.