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

> Attackers can inject arbitrary HTML via malicious URLs in Vite dev servers using custom app types, potentially executing code in the browser.

- **Severity:** Medium 6.1 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 4 Dec 2023
- **Updated:** 29 May 2025
- **Also known as:** GHSA-92r3-m2mg-pj97, MINI-8wm3-55cx-v9c3

## What is CVE-2023-49293?

CVE-2023-49293 is a medium-severity cross-site scripting vulnerability in vitejs vite, published on 4 Dec 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### 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.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2023-49293?

6 open source packages ship an affected version, including vite. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `vite` | npm | From 4.4.0 | 4.4.12 |
| `vite` | npm | From 4.4.0 | 4.4.12 |
| `vite` | npm | From 4.5.0 | 4.5.1 |
| `vite` | npm | From 4.5.0 | 4.5.1 |
| `vite` | npm | From 5.0.0 | 5.0.5 |
| `vite` | npm | From 5.0.0 | 5.0.5 |

Products: Vitejs Vite.

## How do I fix CVE-2023-49293?

Upgrade vite to a fixed version for your release line: 4.4.12, 4.5.1 or 5.0.5.

## Is CVE-2023-49293 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-49293 exists.

Public exploit code:

- Vite dev server - Cross-Site Scripting (nuclei): http/cves/2023/CVE-2023-49293.yaml

## Other vulnerabilities in vitejs vite

- [CVE-2025-31125](https://insights.sbomify.com/CVE-2025-31125/): Vite Vitejs Improper Access Control (medium 5.3, exploited in the wild)
- [CVE-2026-53571](https://insights.sbomify.com/CVE-2026-53571/): Vite: `server.fs.deny` bypass on Windows alternate paths (high 8.2)
- [CVE-2026-39363](https://insights.sbomify.com/CVE-2026-39363/): Vite Affected by Arbitrary File Read via Vite Dev Server WebSocket (high 8.2)
- [CVE-2026-39364](https://insights.sbomify.com/CVE-2026-39364/): Vite has a `server.fs.deny` bypass with queries (high 8.2)
- [CVE-2024-23331](https://insights.sbomify.com/CVE-2024-23331/): Vite dev server option `server.fs.deny` can be bypassed when hosted on case-insensitive filesystem (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-49293 and fix it if it is affected.

What it is: CVE-2023-49293 is a medium-severity cross-site scripting vulnerability in vitejs vite, published on 4 Dec 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-49293 exists.

Affected packages and fixed versions:
- vite (npm): affected from 4.4.0; fixed in 4.4.12
- vite (npm): affected from 4.4.0; fixed in 4.4.12
- vite (npm): affected from 4.5.0; fixed in 4.5.1
- vite (npm): affected from 4.5.0; fixed in 4.5.1
- vite (npm): affected from 5.0.0; fixed in 5.0.5
- vite (npm): affected from 5.0.0; fixed in 5.0.5

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-49293/ (Markdown: https://insights.sbomify.com/CVE-2023-49293/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-49293
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-49293
- OSV: https://osv.dev/vulnerability/CVE-2023-49293

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-49293/
Summaries are generated and may contain mistakes; the official description above is the record.
