Skip to content

Vite

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?

ProductAffected 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.115.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

FactorValueEvidence×
ImpactDenial of serviceCrash or resource exhaustion onlyFrom the CVSS vector0.40
Attacker positionInternetAnyone on the Internet can reach a typical deploymentFrom the CVSS vector1.00
Privileges neededLowA real low-privileged accountFrom the CVSS vector0.60
Victim interactionNoneNothingFrom the CVSS vector1.00
ConfigurationDefaultOut-of-the-box installs are vulnerableFrom the CVSS vector1.00
ReliabilityHardNarrow race, needs an extra info leak, needs a man-in-the-middle position, or must be chained with another bugFrom the CVSS vector0.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
  1. Prerequisites multiplied together0.270
  2. Threat T3: Public proof of concept0.950
  3. 10 × impact 0.4 × prerequisites 0.27 × threat 0.951.026
  4. Rounded to one decimal between 0.1 and 101.0

How the score works

Exploitation and evidence timeline

  1. 17 Sep 2024 Published
  2. 3 Dec 2026 CISA SSVC: proof of concept first seen
  3. 3 Dec 2026 Risk 1.0 (cvss fallback)

Weakness

CWE-79

References

Get alerts for Vite

Free email or text alerts when a vulnerability in Vite reaches risk 8 or higher. Nothing else.