Vulnerability · Published Dec 4, 2023 · Assigned by GitHub_M

CVE-2023-49293Cross-site Scripting in `server.transformIndexHtml` via URL payload in vite

Medium 6.1

In plain English

A medium-severity cross-site scripting in vite from vitejs. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 1.0% (higher than 63% of all known vulnerabilities). Ready-made attack tooling exists: Nuclei. Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)6.1Medium
Exploit odds (30 days)1.0%top 37.1% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack tooling1Nuclei

Official description

Vite is a website frontend framework. When Vite's HTML transformation is invoked manually via `server.transformIndexHtml`, the original request URL is passed in unmodified, and the `html` being transformed contains inline module scripts (`<script type="module">...</script>`), it is possible to inject arbitrary HTML into the transformed output by supplying a malicious URL query string to `server.transformIndexHtml`. Only apps using `appType: 'custom'` and using the default Vite HTML middleware are affected. The HTML entry must also contain an inline script. The attack requires a user to click on a malicious URL while running the dev server. Restricted files aren't exposed to the attacker. This issue has been addressed in vite@5.0.5, vite@4.5.1, and vite@4.4.12. There are no known workarounds for this vulnerability.

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
npmvite4.4.12GHSA-92r3-m2mg-pj97
npmvite4.5.1GHSA-92r3-m2mg-pj97
npmvite5.0.5GHSA-92r3-m2mg-pj97

Affected products (as reported)

VendorProductVersions
vitejs vite >=4.4.0, < 4.4.12= 4.5.0>=5.0.0, < 5.0.5

Weakness: CWE-79 · Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

References