79% vs 51%: independent neobanks lag on app security. Read the report

Deep Dive

Deep Dive

Vite Dev Server RCE on Network-Exposed Hosts (CVE-2026-140097)

A crafted request to a network-exposed Vite dev server can read files or run code via an injected virtual module; fixed in 6.4.6, 7.3.8, 8.1.7, 8.2.5 or 8.3.7.

TL;DR

  • A request to a Vite dev server can place code inside a virtual module that Vite generates and trusts. The Vite team disclosed the flaw on 2026-11-10.
  • Affected releases span Vite 4.0.0 through 8.3.6, all published before their fixed counterparts. vite-plus up to 1.5.0 is also affected. Only dev servers exposed to the network are vulnerable.
  • GitHub's advisory and NVD both rate it Critical, CVSS v4.0 9.1. No exploitation in the wild is known, and it is not in CISA KEV as of 2026-12-01.
  • Upgrade to 6.4.6, 7.3.8, 8.1.7, 8.2.5 or 8.3.7, and to vite-plus 1.5.1. See "How do I fix it?" for the temporary network restriction.

Am I affected?

You are exposed when a vulnerable Vite release runs a development server that the attacker can reach on the network. All of these conditions must hold:

  • The installed vite release is in one of the affected ranges, or vite-plus is 1.5.0 or earlier.
  • The process is the Vite development server, not a build and not a vite preview static server.
  • The server is reachable over the network. Vite binds to loopback by default, so the exposure comes from --host, a server.host value, or a proxy in front of the server.
  • The attacker can send HTTP requests to the dev server. A browser page that the attacker controls can also send them when the attacker can reach the host.

The flaw is in the resolver plugin that runs while the dev server serves modules. A production build does not run that code path, so a dist/ directory served by a normal web server is not affected by this issue.

Vite is widely used: npm counted 268,461,666 downloads of the vite package in the week of 2026-11-23 to 2026-11-29 (npm). Most of those installs never share a dev server, but the ones that do are the exposure this flaw targets.

Branch Affected versions Fixed version
Vite 4 to 6 4.0.0 to 6.4.5 6.4.6
Vite 7 7.0.0 to 7.3.7 7.3.8
Vite 8.0 and 8.1 8.0.0 to 8.1.6 8.1.7
Vite 8.2 8.2.0 to 8.2.4 8.2.5
Vite 8.3 8.3.0 to 8.3.6 8.3.7
vite-plus 1.5.0 and earlier 1.5.1

Check the version in the project and in the lockfile:

npm ls vite vite-plus
grep -A2 '"node_modules/vite"' package-lock.json

With pnpm or Yarn, ask the package manager why it installed Vite:

pnpm why vite
yarn why vite

Check whether the dev server listens beyond loopback. A local address such as 127.0.0.1 or ::1 is not exposed. A 0.0.0.0, a ::, or a concrete interface address is exposed:

ss -ltnp | grep -E ':(5173|4173)\b'

The default Vite port is 5173. The grep matches only 5173 and 4173, so if the start command sets a custom port, substitute that port in the pattern before running it.

How do I fix it?

Upgrade to the fixed release for your branch, then restart the development server. The advisory lists 6.4.6, 7.3.8, 8.1.7, 8.2.5 and 8.3.7 for Vite, and 1.5.1 for vite-plus.

  1. Install the fixed Vite release for the major line you already run:
npm install -D vite@6.4.6

Use vite@7.3.8 on the 7 line, and vite@8.1.7, vite@8.2.5 or vite@8.3.7 on the matching 8 line. Do not jump a major version just to patch.

  1. If the project uses vite-plus, upgrade it too:
npm install -D vite-plus@1.5.1
  1. Restart the dev server. An old process keeps the vulnerable resolver loaded until it is replaced.

If you cannot upgrade yet, stop exposing the dev server. Remove --host from the start command and set server.host to 127.0.0.1 or localhost. Bind only to a private interface when a container or a teammate must reach it, and put an authenticating proxy in front of any shared instance.

A firewall rule that allows only the developer subnet is a second barrier, not a fix. The vulnerable code path is still reachable from every host the rule allows. Never expose a Vite dev server to the public internet, even after patching.

What is the root cause?

Vite builds two kinds of virtual module from a request-derived identifier and writes that identifier into JavaScript without escaping it. A resolver turns a crafted module id into executable code that Vite then trusts.

Vite has a resolver plugin that handles imports of packages it externalizes for the browser. When client code imports a Node.js built-in, Vite returns a stub module named __vite-browser-external:<suffix>. When it cannot resolve an optional peer dependency, it returns __vite-optional-peer-dep:<suffix>. Both stubs are generated as source text with the suffix embedded in an error message.

This is packages/vite/src/node/plugins/resolve.ts at the last affected release, before the fix:

id = id.slice(browserExternalId.length + 1)
return `\
  export default new Proxy({}, {
    get(_, key) {
      throw new Error(\`Module "${id}" has been externalized for browser compatibility. Cannot access "${id}.\${key}" in client code.  See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`)
    }
  })`

The variable id is the module id from the request. The code inserts it inside a template literal and inside a nested template literal. A " in the suffix closes the error string, and a backtick closes the template literal. Whatever follows becomes JavaScript in the generated module.

The optional peer dependency branch has the same pattern in the same file:

const [, peerDep, parentDep] = id.split(':')
return `throw new Error(\`Could not resolve "${peerDep}" imported by "${parentDep}". Is it installed?\`)`

The dependency optimizer keeps a second copy of the pattern in packages/vite/src/node/optimizer/esbuildDepPlugin.ts:

contents: `throw new Error(\`Could not resolve "${peerDep}" imported by "${parentDep}". Is it installed?\`)`,

Vite treats its own generated modules as trusted input. That trust is what turns the string breakout into two concrete problems.

First, the resolver records the modules that a generated module imports. Vite uses that graph for the server.fs allow-list check. An injected import '/path/to/file' adds the file to the module graph, and a later request for /@fs/path/to/file returns it even when the file sits outside the project.

Second, Vite runs eval on module code to extract values for new Worker and import.meta.glob handling. Vite blocks some globals such as exports and require, but the advisory calls those blocks a bug guard, not a security boundary. The public proof of concept reaches the Node.js process through globalThis.process.getBuiltinModule.

The advisory credits g2hsec, spansh, martinpriest and zooyeon for the report.

How is it exploited?

An unauthenticated attacker sends a crafted URL to the dev server, then fetches the file or triggers the evaluation that the injected module made reachable. The advisory publishes a proof of concept that reads a file outside the project.

  1. The attacker sends a request for a virtual module id under /@id/. The id starts with __vite-browser-external: and continues with JavaScript that closes the generated stub and adds an import of the target file.
  2. The resolver builds the stub with the raw id. The injected import is parsed as part of the module, so Vite adds the target file to the module graph and to the server.fs allow list.
  3. The attacker requests the same file through /@fs/. Vite now serves it, even though a request for the same path before the injection returned 403.
  4. For code execution, the attacker uses the same injection with new Worker or import.meta.glob. Vite evaluates the module text to extract the worker or glob value, and the injected globalThis.process.getBuiltinModule call runs in the dev-server process.

The advisory's proof of concept creates a decoy file outside the project and sends this request, shown decoded (the wire form percent-encodes quotes, backticks and newlines):

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

A later GET /@fs/tmp/decoy-secret.txt returns the file body. The same request is publicly documented, so this is a proof of concept rather than a weaponized exploit. No exploitation in the wild has been reported.

How does the attack flow?

A crafted virtual module id escapes the generated JavaScript string. The injected import then pulls an outside file into Vite's module graph, which makes the file readable or evaluates the module on the server.

flowchart LR A["GET /@id/__vite-browser-external: crafted id"] --> B["Resolver interpolates the raw id"] B --> C["No escaping of the module id"] C --> D["Injected import enters the module graph"] D --> E["Target file joins the server.fs allow list"] E --> F["GET /@fs/ returns the file"] C --> G["Worker or import.meta.glob evaluation runs injected code"]

What can an attacker do?

An attacker who reaches a vulnerable dev server can read files outside the project allow list and can run code in the dev-server process. The advisory demonstrates both outcomes.

The file read exposes anything the Vite process can open. That includes .env files, SSH keys, cloud credentials and source outside the project root. A development machine often holds production secrets that the build does not need.

The code execution runs as the user that started Vite. On a developer laptop that is the developer account. On a shared CI runner or a container it can be a service account with repository or registry access. The advisory calls the result arbitrary code execution in the development-server process.

The conditions are strict. The attacker needs network access to the dev server, and the server must run the dev command. A static production build does not include the resolver plugin, so a normal deployment is not exposed by this flaw.

Why does the fix work?

The fix serializes the module identifier with JSON.stringify before it is placed in generated code, so quotes, backticks and newlines become string data instead of syntax. It changes every copy of the pattern.

This is the diff in packages/vite/src/node/plugins/resolve.ts:

-            id = id.slice(browserExternalId.length + 1)
+            const modulePath = JSON.stringify(
+              id.slice(browserExternalId.length + 1),
+            )
             return `\
-  export default new Proxy({}, {
-    get(_, key) {
-      throw new Error(\`Module "${id}" has been externalized ...
+export default new Proxy({}, {
+  get(_, key) {
+    const path = ${modulePath}
+    throw new Error(\`Module "\${path}" has been externalized ...

The optional peer dependency branch gets the same treatment:

-            const [, peerDep, parentDep] = id.split(':')
-            return `throw new Error(\`Could not resolve "${peerDep}" imported by "${parentDep}". Is it installed?\`)`
+            const peerDepString = JSON.stringify(peerDep)
+            const parentDepString = JSON.stringify(parentDep)
+            return (
+              `const peerDep = ${peerDepString};const parentDep = ${parentDepString};` +
+              `throw new Error(\`Could not resolve "\${peerDep}" imported by "\${parentDep}".${isProduction ? '' : ' Is it installed?'}\`)`
+            )

JSON.stringify wraps the value in a double-quoted JavaScript string and escapes the characters that would end it. The generated module now contains the attacker text as a string constant, so the import and the evaluation never see executable code.

The same escaping is added to the optimizer stub in esbuildDepPlugin.ts. The advisory notes that in Vite 8 the vulnerable copy also exists in the Rolldown binary. Vite 8.3.7 and 8.2.5 rely on the fix in Rolldown 1.2.17, and Vite 8.1.7 relies on Rolldown 1.1.7. Upgrading Vite alone does not change a pinned Rolldown; the fixed Vite release has to bring the fixed Rolldown version with it.

The patch closes the string breakout in the JavaScript resolver and in the optimizer. It does not make a dev server safe to expose. Vite's documentation already asks developers to keep the dev server on loopback.

How do I check if I was compromised?

Look in the dev-server access log for requests that use the virtual module prefixes with encoded payload characters. No vendor indicator set has been published, so these are leads rather than proof:

grep -Ei '__vite-browser-external|__vite-optional-peer-dep' /var/log/nginx/access.log

Decode percent-encoded paths before you read them, because the proof of concept sends newlines and quotes encoded on the wire. A request whose suffix contains %22, %60, %3B or %0A is a strong lead.

Look for /@fs/ requests for paths outside the project root. A request that succeeds for a path the server rejected earlier is the signature of the allow-list extension:

grep -E 'GET /@fs/' /var/log/nginx/access.log | grep -v '/@fs/<your-project-root>'

If the dev server runs behind no proxy, check its own terminal output and any process log. Vite prints resolved module errors, and the advisory's payload triggers an error inside the injected code. An empty log does not prove that no attempt happened, because a successful read can leave no error.

Check the files the dev server can read for unexpected access. On a shared host, compare the process start time with file access times for .env files and cloud credential files. That is a lead only when the host records access times.

Timeline

  • 2026-11-09: Vite publishes the fixed releases, including 6.4.6 and 8.3.7.
  • 2026-11-10: Vite publishes advisory GHSA-p4f5-76q4-ffq7.
  • 2026-11-30: NVD publishes CVE-2026-140097.

From fixed releases to the public advisory and the NVD record in three weeks
Figure 1: Vite released the fixes on 2026-11-09, published the advisory on 2026-11-10, and NVD published the CVE record on 2026-11-30. Source: Vite GitHub releases, GHSA-p4f5-76q4-ffq7 and NVD, checked December 1, 2026

FAQ

Is a production Vite build affected?

No. The vulnerable resolver and optimizer stubs run while the development server serves modules. A vite build output served by a static web server does not include this code path.

Does the attacker need an account on the dev server?

No. The advisory describes the attack as unauthenticated. The attacker only needs to reach the HTTP port that the dev server listens on.

Is vite preview affected?

No. vite preview serves an already built dist/ directory and does not run the module resolver that generates the virtual modules. The affected command is vite, the development server.

Which fixed version should I install?

Install the fixed release for the major line you already use: 6.4.6, 7.3.8, 8.1.7, 8.2.5 or 8.3.7. Projects on vite-plus need 1.5.1. Do not skip a major version only to patch.

Is there a public proof of concept?

Yes. The advisory includes request-level steps that read a decoy file outside the project and describes the evaluation path for code execution. No exploitation in the wild has been reported.

Why does binding to localhost help?

A dev server on 127.0.0.1 or ::1 accepts only connections from the same host. The crafted request never arrives from the network, so the resolver never processes the malicious module id.

Find exposed development servers with Ostorlab

Ostorlab's web agentic deep scan maps the web applications and APIs you expose and tests them from an attacker's point of view. Use it to inventory development and preview hosts that should never be reachable from the internet, then remove them before a dev-server flaw like this one becomes reachable.

References

  • Vite, advisory GHSA-p4f5-76q4-ffq7, "Remote code execution using __vite-browser-external virtual module", published 2026-11-10 (checked December 1, 2026): https://github.com/vitejs/vite/security/advisories/GHSA-p4f5-76q4-ffq7
  • NVD, CVE-2026-140097 record (checked December 1, 2026): https://nvd.nist.gov/vuln/detail/CVE-2026-140097
  • Vite, fix commit 4b4291018a34d1591a6a18ab5c406d5b6a7a4ea1 (checked December 1, 2026): https://github.com/vitejs/vite/commit/4b4291018a34d1591a6a18ab5c406d5b6a7a4ea1
  • Vite, pull request 24043 (checked December 1, 2026): https://github.com/vitejs/vite/pull/24043
  • Vite, release v6.4.6, published 2026-11-09 (checked December 1, 2026): https://github.com/vitejs/vite/releases/tag/v6.4.6
  • Vite, release v8.3.7, published 2026-11-09 (checked December 1, 2026): https://github.com/vitejs/vite/releases/tag/v8.3.7
  • Vite source at the last affected release, packages/vite/src/node/plugins/resolve.ts (checked December 1, 2026): https://github.com/vitejs/vite/blob/v6.4.5/packages/vite/src/node/plugins/resolve.ts
  • Vite source at the last affected release, packages/vite/src/node/optimizer/esbuildDepPlugin.ts (checked December 1, 2026): https://github.com/vitejs/vite/blob/v6.4.5/packages/vite/src/node/optimizer/esbuildDepPlugin.ts
  • npm, vite package page, 268,461,666 downloads in the week of 2026-11-23 to 2026-11-29 (checked December 1, 2026): https://www.npmjs.com/package/vite
  • CISA, Known Exploited Vulnerabilities Catalog, catalog version 2026.11.30 (checked December 1, 2026): https://www.cisa.gov/known-exploited-vulnerabilities-catalog

Free scan

Scan your own app for free

or book a demo

Keep reading

Related articles

Browse the blog