# CVE-2024-45812: DOM Clobbering gadget found in vite bundled scripts that leads to XSS in Vite

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 6.4
- **CVSS:** 6.4 (v3.1, CNA) `CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: High; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: Low; Integrity impact: Low; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, login needed
- **EPSS:** 0.91% (percentile 58, 2026-11-26)
- **CWE:** CWE-79
- **Aliases:** GHSA-64vr-g452-qvp3
- **Published:** 2024-09-17T19:28:01.000Z
- **Modified:** 2026-09-10T03:50:18.740Z

## Who should check

- Projects that depend on npm package vite (\>= 5.4.0, \< 5.4.6)
- Anyone running vitejs vite \>= 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

## 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 and fixed versions

- npm `vite`: affected \>= 5.4.0, \< 5.4.6; fixed 5.4.6, 5.3.6, 5.2.14, 4.5.4, 3.2.11, 5.1.8 (osv)
- vitejs vite: \>= 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 (cvelist)

## Mitigation

- Upgrade vite to one of 5.4.6, 5.3.6, 5.2.14, 4.5.4, 3.2.11, 5.1.8 (or later in the same release line).

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-45812. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-45812.md
Affected: vite >= 5.4.0, < 5.4.6
Fixed in: 5.4.6, 5.3.6, 5.2.14, 4.5.4, 3.2.11, 5.1.8

Steps:
1. Search this machine and project for vite (npm), vitejs vite: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-45812 being exploited?

There is no confirmed exploitation: CVE-2024-45812 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.91% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2024-45812?

Medium: CVSS 6.4 (v3.1, scored by CNA). Remote, login needed. The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2024-45812?

vite \>= 5.4.0, \< 5.4.6.

### Is there a fix for CVE-2024-45812?

Yes. Fixed in 5.4.6, 5.3.6, 5.2.14, 4.5.4, 3.2.11, 5.1.8. Upgrade vite to one of 5.4.6, 5.3.6, 5.2.14, 4.5.4, 3.2.11, 5.1.8 (or later in the same release line).

### How do I check if I'm affected by CVE-2024-45812?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/vitejs/vite/security/advisories/GHSA-64vr-g452-qvp3>
- vendor: <https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2024-45812>
- patch: <https://github.com/vitejs/vite/commit/ade1d89660e17eedfd35652165b0c26905259fad>
- patch: <https://github.com/vitejs/vite/commit/179b17773cf35c73ddb041f9e6c703fd9f3126af>
- patch: <https://github.com/vitejs/vite/commit/2691bb3ff6b073b41fb9046909e1e03a74e36675>
- patch: <https://github.com/vitejs/vite/commit/2ddd8541ec3b2d2e5b698749e0f2362ef28056bd>
- patch: <https://github.com/vitejs/vite/commit/e8127166979e7ace6eeaa2c3b733c8994caa31f3>
- patch: <https://github.com/vitejs/vite/commit/ebb94c5b3bf41950f45562595adec117a4d0ba5e>
- other: <https://research.securitum.com/xss-in-amp4email-dom-clobbering>
- other: <https://scnps.co/papers/sp23_domclob.pdf>
- other: <https://github.com/vitejs/vite>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-45812>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-64vr-g452-qvp3> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2024-45812> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-45812>
