Vite DOM Clobbering gadget found in vite bundled scripts that leads to XSS (CVE-2024-45812)
A DOM Clobbering vulnerability (CVE-2024-45812) exists in Vite when building scripts with output formats cjs, iife, or umd. This flaw allows an attacker to manipulate the document.currentScript property via a named HTML element, causing the dynamic import of scripts from attacker-controlled URLs. This can lead to cross-site scripting (XSS) in web pages that include Vite-bundled scripts and allow injection of scriptless attacker-controlled HTML elements. The vulnerability affects Vite versions from 2.5.1 up to but not including 5.4.6. A patch is available to address this issue.
AI Analysis
Technical Summary
Vite's bundling process for cjs, iife, and umd output formats replaces relative asset paths using the URL from document.currentScript. However, document.currentScript can be shadowed by an attacker-controlled HTML element named 'currentScript', enabling the attacker to control the script URL used for dynamic imports. This DOM Clobbering gadget can be exploited by injecting scriptless HTML elements (e.g., an img tag with name='currentScript') into the page, leading to loading malicious scripts from attacker-controlled servers and resulting in cross-site scripting (XSS). The vulnerability is demonstrated with a proof-of-concept where an attacker injects an img element named 'currentScript' to hijack script loading.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary scripts in the context of the vulnerable web page, resulting in cross-site scripting (XSS). This can lead to data theft, session hijacking, or other malicious actions depending on the attacker's payload. The impact is limited to web pages that include Vite-bundled scripts configured with the vulnerable output formats and that allow injection of scriptless attacker-controlled HTML elements.
Mitigation Recommendations
A patch is available for this vulnerability. Users should upgrade Vite to a fixed version at or above 5.4.6. Until patched, avoid using the cjs, iife, or umd output formats if possible, and ensure that user input is properly sanitized to prevent injection of attacker-controlled HTML elements with names that could shadow document.currentScript. Review the vendor advisory for detailed patch and mitigation instructions.
Vite DOM Clobbering gadget found in vite bundled scripts that leads to XSS (CVE-2024-45812)
Description
A DOM Clobbering vulnerability (CVE-2024-45812) exists in Vite when building scripts with output formats cjs, iife, or umd. This flaw allows an attacker to manipulate the document.currentScript property via a named HTML element, causing the dynamic import of scripts from attacker-controlled URLs. This can lead to cross-site scripting (XSS) in web pages that include Vite-bundled scripts and allow injection of scriptless attacker-controlled HTML elements. The vulnerability affects Vite versions from 2.5.1 up to but not including 5.4.6. A patch is available to address this issue.
CVSS v3.1
Score 6.4medium
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Vite's bundling process for cjs, iife, and umd output formats replaces relative asset paths using the URL from document.currentScript. However, document.currentScript can be shadowed by an attacker-controlled HTML element named 'currentScript', enabling the attacker to control the script URL used for dynamic imports. This DOM Clobbering gadget can be exploited by injecting scriptless HTML elements (e.g., an img tag with name='currentScript') into the page, leading to loading malicious scripts from attacker-controlled servers and resulting in cross-site scripting (XSS). The vulnerability is demonstrated with a proof-of-concept where an attacker injects an img element named 'currentScript' to hijack script loading.
Potential Impact
Successful exploitation allows an attacker to execute arbitrary scripts in the context of the vulnerable web page, resulting in cross-site scripting (XSS). This can lead to data theft, session hijacking, or other malicious actions depending on the attacker's payload. The impact is limited to web pages that include Vite-bundled scripts configured with the vulnerable output formats and that allow injection of scriptless attacker-controlled HTML elements.
Mitigation Recommendations
A patch is available for this vulnerability. Users should upgrade Vite to a fixed version at or above 5.4.6. Until patched, avoid using the cjs, iife, or umd output formats if possible, and ensure that user input is properly sanitized to prevent injection of attacker-controlled HTML elements with names that could shadow document.currentScript. Review the vendor advisory for detailed patch and mitigation instructions.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- BREW-vite-CVE-2024-45812
- Osv Schema Version
- 1.7.3
- Ecosystems
- ["Homebrew"]
- Cvss Version
- 3.1
Threat ID: 6abb419cf7a7c54106cc387a
Added to database: 09/29/2026, 04:42:04 UTC
Last enriched: 09/29/2026, 04:55:01 UTC
Last updated: 09/29/2026, 18:11:13 UTC
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.