Skip to main content

SWC HTML Minifier CVE-2026-72925

| EUVDEUVD-2026-56179 MEDIUM
Cross-site Scripting (XSS) (CWE-79)
2026-08-11 GitHub_M GHSA-5qr2-v392-m9g8
6.1
CVSS 3.1 · Vendor: GitHub_M
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Attacker injects crafted JSON payload via user input channel
  2. Delivery
    Server embeds payload in script type=application/json block
  3. Exploit
    SWC minifier parses JSON unescaping \u003C to literal <
  4. Install
    Serialization writes unescaped < to output without calling escape_json_for_html_script
  5. C2
    Closing script tag appears literally in minified HTML
  6. Execute
    Victim browses page and browser tokenizer splits script element
  7. Impact
    Injected JavaScript executes in page origin

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Three concurrent conditions must be present: (1) the application uses swc_html_minifier or @swc/html to minify HTML at build time or per-request; (2) the HTML being minified contains at least one <script type='application/json'> or <script type='application/ld+json'> element whose content includes attacker-influenced data with a < character - typically data that was originally unicode-escaped as \u003C in JSON storage but gets unescaped during the parse/serialize cycle; and (3) a victim end user must load or navigate to the page containing the malicious minified output (CVSS UI:R). Applications serving only static, developer-authored JSON in script blocks with no user-supplied values are not exposed. The CVSS PR:N metric confirms no attacker authentication is required against the target application, but the attacker must have a channel - form submission, API call, URL parameter, or indirect data injection - to influence the JSON content that the minifier processes.

Impact

The vendor-assigned CVSS 3.1 score of 6.1 (AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N) is consistent with a classic reflected or stored XSS with cross-origin scope change: modest per-instance confidentiality and integrity impact but no availability impact. No EPSS data was provided; exploitation probability must be inferred from CVSS metrics alone. This vulnerability is not in the CISA KEV catalog at time of analysis, and no public exploit code has been identified. The real-world risk is conditional on deployment pattern: only applications that (1) actively use SWC's HTML minifier, (2) embed untrusted or attacker-influenced data inside JSON script blocks, and (3) serve the minified output to end users are exposed. Frameworks using SWC for SSR with dynamic structured-data injection (e.g., ld+json SEO blocks populated from user-controlled content) represent the highest-risk deployment scenario. The attack technique is trivially understood by any XSS researcher once the codepath is known, meaning dwell time between disclosure and exploitation attempts is likely short for affected applications.

Exploit ScenarioDerived

An attacker submits a user profile field or API parameter containing the value \u003C/script>\u003Cscript>alert(document.cookie)\u003C/script> - a valid unicode-escaped string in JSON. The application stores this and later renders it into a <script type='application/json'> block in a server-generated page. When SWC HTML minifier processes the page, it parses the JSON (unescaping \u003C to literal <), then re-serializes and writes the result back to the DOM node without escaping, producing a literal </script><script>alert(document.cookie)</script> sequence in the output HTML. Any victim who loads the minified page triggers the injected script, which executes in the page's full origin context.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Aug 11, 2026

Cross-site scripting in SWC's HTML minifier allows attacker-controlled JSON data embedded in application/json and application/ld+json script elements to break out of those elements and execute arbitrary JavaScript in the rendered page's origin. Applications that use swc_html_minifier or @swc/html to minify server-rendered HTML containing dynamic JSON script blocks are vulnerable - the minifier parsed JSON (unescaping unicode-escaped less-than signs) then re-serialized without re-escaping them, letting a crafted closing sequence terminate the script element prematurely. No public exploit has been identified at time of analysis, but the attack technique is a well-understood HTML parser quirk and the fix commit provides a clear reproduction case.

RemediationAI

Upgrade @swc/html to version 1.15.47-nightly-20260729.1 or later and swc_html_minifier to version 59.0.0 or later; these are the vendor-confirmed fixed releases documented at https://github.com/swc-project/swc/releases/tag/v1.15.47-nightly-20260729.1 and the security advisory GHSA-5qr2-v392-m9g8. If an immediate upgrade is not feasible, apply a compensating control by pre-escaping all < characters to \u003C in any JSON values destined for <script type='application/json'> or <script type='application/ld+json'> elements before they are passed to the SWC minifier; this prevents the HTML tokenizer from misinterpreting the serialized output. The trade-off of this workaround is that it introduces a bespoke encoding step that must be applied consistently across every code path that populates JSON script blocks - any gap reinstates the vulnerability. Restricting HTML minification to pages that contain only static, trusted JSON content (no user-supplied values) is an additional risk-reduction measure but is difficult to enforce reliably in dynamic SSR pipelines.

Affected VersionsENISA

html < 1.15.47-nightly-20260729.1
swc_html_minifier < 59.0.0
swc < 1.15.47

Affected Packages

cargo @swc/html fix: 1.15.47-nightly-20260729.1
cargo swc_html_minifier fix: 59.0.0
npm @swc/html fix: 1.15.47-nightly-20260729.1
npm swc_html_minifier fix: 59.0.0
euvd html fix: 1.15.47-nightly-20260729.1
euvd swc fix: 1.15.47
euvd swc_html_minifier fix: 59.0.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 4 packages in cargo, npm, euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

SWC is a Rust-based TypeScript/JavaScript compiler toolchain (CPE: cpe:2.3:a:swc-project:swc, cpe:2.3:a:swc-project:swc_html_minifier) that includes an HTML minifier in crates/swc_html_minifier/src/lib.rs. The vulnerable codepath, minifyJson, handled content inside <script type='application/json'> and <script type='application/ld+json'> elements by parsing the JSON (which unescapes unicode sequences such as \u003C back to literal <) and then re-serializing it without applying any HTML-safe escaping. The root cause maps to CWE-79 (Improper Neutralization of Input During Web Page Generation): HTML tokenizers process raw bytes and recognize </script as a closing tag before any JSON semantics apply, so a literal < character in serialized JSON can smuggle a closing sequence that the browser HTML parser acts on. The fix introduces escape_json_for_html_script, which replaces all < with \u003C after JSON serialization before the content is written back into the DOM node.

Know when Swc gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (GitHub_M) PRIMARY 6.1 MEDIUM
AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
vuln.today AI 6.1 MEDIUM

Network-delivered XSS requiring victim page load; no attacker auth needed; scope changes to victim browser origin; no availability impact.

3.1 AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
4.0 AV:N/AC:L/AT:P/PR:N/UI:A/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

Primary rating from Vendor (GitHub_M).

CVSS VectorVendor: GitHub_M

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

Lifecycle Timeline

1
Patch available
Aug 11, 2026 - 16:17 EUVD

DescriptionCVE.org

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.

Threat Intelligence Overview

EPSS Score
0.2%
Top 91% exploitable
Prevalence
Medium
widely used JS/TS build tool, but HTML minification is an optional feature
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
EUVD NVD CVE.org EPSS Vulnrichment GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
None
System Exposure· derived
Open
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

30
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +30
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy