CVE-2024-45812

DOM Clobbering gadget found in vite bundled scripts that leads to XSS in Vite

MEDIUM
6.4
CVSS Score
Published: September 17, 2024 at 08:08 PM UTC
Updated: June 17, 2026 at 07:54 AM UTC
1 product affected across 1 vendorVite

Using vite by vitejs?

Get instant alerts when new vulnerabilities affect vite - before attackers find them.

Real-time alertsTrack your software stackFree plan available
Severity
MEDIUM6.4
Exploit prediction
EPSS 0.6%
SSVC
PoC

Description

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.

Affected

Our own answer: ranges merged, affected separated from platform-only, with confidence and review flags.

v < 3.2.11v < 4.5.5v < 5.2.14v < 5.3.6v < 5.4.64.0.0 ≤ v < 4.5.55.0.0 ≤ v < 5.2.145.3.0 ≤ v < 5.3.65.4.0 ≤ v < 5.4.64.0.05.0.05.3.05.4.0
Affected range stops below 3.2.11, so it looks safe — our inference, not a vendor statement
Affected range stops below 4.5.5, so it looks safe — our inference, not a vendor statement
Affected range stops below 5.2.14, so it looks safe — our inference, not a vendor statement
Affected range stops below 5.3.6, so it looks safe — our inference, not a vendor statement
Affected range stops below 5.4.6, so it looks safe — our inference, not a vendor statement

Remediation

No guide yet

No remediation guidance has been written for this CVE yet, and no fixed version or vendor advisory is recorded against it.

SSVC — Action Prioritization

SSVCPoCNot automatablePartial impact

SSVC signals action urgency (what to patch first), separate from CVSS which measures severity.

CVSS

6.4MEDIUMGitHub_M
Attack Vector
NETWORK
Complexity
HIGH
Privileges
LOW
User Interaction
NONE
Scope
UNCHANGED
Confidentiality
LOW
Integrity
LOW
Availability
HIGH
Vector?

Quick Info

StatusDEFERRED
CWE
CWE-79

Get alerted

Stop reading CVE feeds looking for your own stack

Track the products you run and VulnTracker tells you when a new CVE affects them — with what is known about fixing it, and nothing about the rest.

Free plan, no card