DOM Clobbering gadget found in vite bundled scripts that leads to XSS in Vite
CVE-2024-45812Published 17 Sep 2024, 20:08 UTC
Real-world risk
1.0/ 10Low
Routine
PreliminaryFrom the CVSS vector only · confidence low
CVSS
6.4
scored by the vendor (CNA), CVSS 3.1
In plain words
No plain-language summary yet. The original description is below.
Original description (from GitHub_M)
Vite a frontend build tooling framework for javascript. Affected versions of vite were discovered to contain a DOM Clobbering vulnerability when building scripts to `cjs`/`iife`/`umd` output format. The DOM Clobbering gadget in the module can lead to cross-site scripting (XSS) in web pages where scriptless attacker-controlled HTML elements (e.g., an img tag with an unsanitized name attribute) are present. DOM Clobbering is a type of code-reuse attack where the attacker first embeds a piece of non-script, seemingly benign HTML markups in the webpage (e.g. through a post or comment) and leverages the gadgets (pieces of js code) living in the existing javascript code to transform it into executable code. We have identified a DOM Clobbering vulnerability in Vite bundled scripts, particularly when the scripts dynamically import other scripts from the assets folder and the developer sets the build output format to `cjs`, `iife`, or `umd`. In such cases, Vite replaces relative paths starting with `__VITE_ASSET__` using the URL retrieved from `document.currentScript`. However, this implementation is vulnerable to a DOM Clobbering attack. The `document.currentScript` lookup can be shadowed by an attacker via the browser's named DOM tree element access mechanism. This manipulation allows an attacker to replace the intended script element with a malicious HTML element. When this happens, the src attribute of the attacker-controlled element is used as the URL for importing scripts, potentially leading to the dynamic loading of scripts from an attacker-controlled server. This vulnerability can result in cross-site scripting (XSS) attacks on websites that include Vite-bundled files (configured with an output format of `cjs`, `iife`, or `umd`) and allow users to inject certain scriptless HTML tags without properly sanitizing the name or id attributes. This issue has been patched in versions 5.4.6, 5.3.6, 5.2.14, 4.5.5, and 3.2.11. Users are advised to upgrade. There are no known workarounds for this vulnerability.
Am I affected?
| Product | Affected versions (from the sources) | Fixed in |
|---|---|---|
| ViteUbiquitous | >= 5.4.0, < 5.4.6; >= 5.3.0, < 5.3.6; >= 5.0.0, < 5.2.14; >= 4.0.0, < 4.5.5; < 3.2.11 | 5.4.6, 5.3.6, 5.2.14, 4.5.5, 3.2.11 |
What to do
Update to a fixed version: 5.4.6, 5.3.6, 5.2.14, 4.5.5, 3.2.11.
Why this score
| Factor | Value | Evidence | × |
|---|---|---|---|
| Impact | Denial of serviceCrash or resource exhaustion only | From the CVSS vector | 0.40 |
| Attacker position | InternetAnyone on the Internet can reach a typical deployment | From the CVSS vector | 1.00 |
| Privileges needed | LowA real low-privileged account | From the CVSS vector | 0.60 |
| Victim interaction | NoneNothing | From the CVSS vector | 1.00 |
| Configuration | DefaultOut-of-the-box installs are vulnerable | From the CVSS vector | 1.00 |
| Reliability | HardNarrow race, needs an extra info leak, needs a man-in-the-middle position, or must be chained with another bug | From the CVSS vector | 0.45 |
Threat level T3: Public proof of concept (× 0.95)
A qualifying GitHub proof of concept, an unverified Exploit-DB entry, CISA's SSVC says PoC, or a reference tagged as an exploit
- CISA SSVC: proof of concept
EPSS 0.6% chance of exploitation in 30 days (percentile 52), as of 2026-12-02.
The arithmetic
- Prerequisites multiplied together0.270
- Threat T3: Public proof of concept0.950
- 10 × impact 0.4 × prerequisites 0.27 × threat 0.951.026
- Rounded to one decimal between 0.1 and 101.0
Exploitation and evidence timeline
- 17 Sep 2024 Published
- 3 Dec 2026 CISA SSVC: proof of concept first seen
- 3 Dec 2026 Risk 1.0 (cvss fallback)
Weakness
CWE-79
References
- https://github.com/vitejs/vite/security/advisories/GHSA-64vr-g452-qvp3vendor-advisory
- https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986misc
- https://github.com/vitejs/vite/commit/ade1d89660e17eedfd35652165b0c26905259fadmisc
- https://research.securitum.com/xss-in-amp4email-dom-clobberingmisc
- https://scnps.co/papers/sp23_domclob.pdfmisc
- CVE-2024-45812 on CVE.org