# Vite Remote Code Execution

> Source: <https://github.com/vitejs/vite/security/advisories/GHSA-p4f5-76q4-ffq7>
> Published: 2026-11-19 07:23:41+00:00

**Recommendation:** Upgrade to Vite 8.3.7, 8.2.5 or 8.1.7 and stop exposing the dev server via `--host`; the PoC read a file outside the allow list through an injected virtual-module import.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

## Repository navigation

# Remote code execution using `__vite-browser-external` virtual module

This report was submitted with AI assistance

## Description

### Summary

By sending an HTTP request to the dev server, a arbitrary code execution was possible.

### Impact

Only apps that match the following condition are affected:

- explicitly exposes the Vite dev server to the network (using `--host` or[`server.host` config option](https://vitejs.dev/config/server-options.html#server-host) )

### Details

Vite's resolver plugin has `__vite-browser-external:<suffix>` virtual module and `__vite-optional-peer-dep:<suffix>` virtual module. These modules embedded the module ID, which is derived from the URL, without escaping. The `<suffix>` can be any value, so any code was able to be injected in those modules.

Since Vite trusts the module code, there was two problems with this injection.

First, the modules referenced by a module are allowed for the `server.fs` check. For example, if the attacker injects `import '/path/to/some-secret-file.txt'`, `/path/to/some-secret-file.txt` can be fetched.

Second, Vite uses `eval` to extract the value in the module code for `new Worker` and `import.meta.glob`. By using that functionality, the attacker can make Vite evaluate the injected code on the server. Vite prevents some module / global variables like `exports`, `require` to avoid bugs, but because this is not a security boundary, there's a bypass like `globalThis.process.getBuiltinModule`.

### PoC

```
printf 'CANARY-SECRET-not-valid-js\n' > /tmp/decoy-secret.txt   # outside the project
vite
```

`/tmp/decoy-secret.txt` stands in for any sensitive file outside the allow list.

1. Check that the target is correctly blocked. `GET /@fs/tmp/decoy-secret.txt` returns 403 Restricted ("outside of Vite serving allow list").
2. Perform the injection. Send a request carrying the crafted id (it is shown decoded. \n are real newlines in the sent URL, percent-encoded on the wire):
This pulls

```
GET /@id/__vite-browser-external:`);}});
import '/@fs/tmp/decoy-secret.txt';
var z=new Proxy({}, {get(_, key) {throw new Error(`?import
```

 `/tmp/decoy-secret.txt` into the module graph.
3. Extract the file. `GET /@fs/tmp/decoy-secret.txt` returns the content in the body (`CANARY-SECRET-not-valid-js` ).

### Notes on the fixes

The vulnerable code in v8 lives in the Rolldown binary. The code is only meant to be used by Vite and thus the report is not linked to Rolldown. Vite 8.3.7 and Vite 8.2.5 relies on the fix in Rolldown 1.2.17. Vite 8.1.7 relies on the fix in Rolldown 1.1.7.
