cve.bz

CVE-2024-45812 vitejs vite: Cross-site Scripting

6.4 mediumEPSS 0.6%Fix available

Medium (6.4) in vitejs vite. EPSS 0.6% estimated probability of exploitation activity in the next 30 days. Fixed in vite 3.2.11, 4.5.4, 5.1.8.

On this page
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.

Severity

CVSS 3.1

6.4 medium
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H
EPSS
0.6% (unchanged from 0.6% a week ago; 0.6% 30 days ago) estimated probability of exploitation activity in the next 30 days; 51st percentile. Scored 2026-11-22. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: PoC · Automatable: no · Technical impact: partial, assessed 2024-09-18. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWE
CWE-79 Improper Neutralization of Input During Web Page Generation (Cross-site Scripting)
OWASP Top 10
A05:2025 Injection
Published
Modified
NVD analysis
Deferred: the NVD does not plan to analyze it
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2024-45812 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2024-45812?via=ask-ai-copy and https://cve.bz/cve/CVE-2024-45812?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2024-45812 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the CNA's record in the CVE List.

ProductAffected
vitejs vite>= 5.4.0, < 5.4.6
vitejs vite>= 5.3.0, < 5.3.6
vitejs vite>= 5.0.0, < 5.2.14
vitejs vite>= 4.0.0, < 4.5.5
vitejs vite< 3.2.11

Packages (OSV)

AdvisoryEcosystemPackageAffectedFixed in
GHSA-64vr-g452-qvp3npmvite>=5.4.0 <5.4.65.4.6
GHSA-64vr-g452-qvp3npmvite>=5.3.0 <5.3.65.3.6
GHSA-64vr-g452-qvp3npmvite>=5.2.0 <5.2.145.2.14
GHSA-64vr-g452-qvp3npmvite>=4.0.0 <4.5.44.5.4
GHSA-64vr-g452-qvp3npmvite<3.2.113.2.11
GHSA-64vr-g452-qvp3npmvite>=5.0.0 <5.1.85.1.8

Linux distributions

DistributionReleasePackageFixed inAdvisory
openSUSETumbleweedvelociraptor0.7.0.4.git142.862ef23-1.1openSUSE-SU-2025:14663-1

From the distributions' data via OSV.dev: SUSE security data, CC BY 4.0. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: openSUSE.

Red Hat

Red Hat rates this Moderate.

Red Hat's statement

This issue is classified as moderate severity rather than important due to the specific conditions required to exploit the vulnerability. While DOM Clobbering can lead to Cross-Site Scripting (XSS), the attack surface is relatively limited. Exploitation is contingent on the presence of unsanitized user-supplied HTML with certain scriptless attributes (`name`, `id`) and the use of particular Vite build outputs (`cjs`, `iife`, `umd`). In environments following proper input sanitization practices, the risk is significantly mitigated. Moreover, the vulnerability does not enable direct code injection or compromise by default but rather leverages existing script elements, reducing the likelihood of widespread exploitation compared to higher severity issues.

Red Hat's mitigation

Mitigation for this issue is either not available or the currently available options do not meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.

ProductPackageStateAdvisory
Red Hat OpenShift distributed tracing 3.4rhosdt/jaeger-query-rhel8:rhosdt-3.4Fixed 2024-12-10RHSA-2024:10917
Red Hat OpenShift distributed tracing 3.4rhosdt/jaeger-query-rhel8:rhosdt-3.4Fixed 2024-12-11RHSA-2024:10962
Red Hat Ansible Automation Platform 2automation-controllerAffected
Red Hat Ansible Automation Platform 2automation-eda-controllerNot affected
Red Hat JBoss Enterprise Application Platform 8viteNot affected
Red Hat OpenShift distributed tracing 3rhosdt/jaeger-agent-rhel8Not affected
Red Hat OpenShift distributed tracing 3rhosdt/jaeger-collector-rhel8Not affected
Red Hat OpenShift distributed tracing 3rhosdt/jaeger-es-index-cleaner-rhel8Not affected
Red Hat OpenShift distributed tracing 3rhosdt/jaeger-es-rollover-rhel8Not affected
Red Hat OpenShift distributed tracing 3rhosdt/jaeger-ingester-rhel8Not affected
Red Hat OpenShift distributed tracing 3rhosdt/jaeger-query-rhel8Affected

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2024-45812.

Attack patterns (CAPEC)

  • CAPEC-63 Cross-Site Scripting (XSS) Likelihood: High · Severity: Very High
  • CAPEC-85 AJAX Footprinting Likelihood: High · Severity: Low
  • CAPEC-209 XSS Using MIME Type Mismatch Severity: Medium
  • CAPEC-588 DOM-Based XSS Likelihood: High · Severity: Very High
  • CAPEC-591 Reflected XSS Likelihood: High · Severity: Very High
  • CAPEC-592 Stored XSS Likelihood: High · Severity: Very High

The attack patterns MITRE's CAPEC relates to this record's weaknesses, as MITRE names them. Credits.

References

Check your stackJSON