Security News

Vite 8.4 can stop your dev server serving files nobody imported. The default still hands them out

A new allow-list mode for server.fs takes one config line to turn on. Here's what the default serves, what the strict mode refuses, and what to check before you point an agent's preview at a network.

A row of sealed concrete doorways in a dark hall, with one open doorway at the centre spilling warm light across the floor.

Vite 8.4, released on 26 November 2026, adds an allow-list mode for the dev server’s file serving. Until now the default let anything under the project root be fetched by absolute path, imported or not. The new mode serves only files that the page you opened actually references.

That matters more than it used to, because dev servers now get pointed at things other than your own browser: a phone on the same Wi-Fi, a container with a published port, a cloud agent that shows you a preview. In each case --host is one flag away, and Vite’s own advisories show what has gone wrong when the server is reachable.

What the default serves

Vite has a route, /@fs/, that serves files by absolute path. The check behind it is server.fs.strict, which has defaulted to true since Vite 2.7. Files outside server.fs.allow return 403 unless they’re imported from an allowed file, and allow defaults to the workspace root (the project root when there’s no workspace).

So the boundary is the project, not the import graph. Take a small app with an entry that imports one JSON file, a .env.local, and a notes file nobody imports:

app/
  index.html
  src/main.ts          imports ./data.json
  src/data.json
  internal/draft.md    "internal draft: pricing"
  .env.local           API_KEY=abc
../vt-outside/notes.txt

A short probe requests five paths against the running server:

R=$(pwd)/app
for p in "/src/main.ts" "/@fs$R/src/data.json" "/@fs$R/internal/draft.md" \
         "/@fs$R/.env.local" "/@fs$(pwd)/../vt-outside/notes.txt"; do
  printf '%-48s %s\n' "$p" "$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:5199$p")"
done

With a default config on Vite 8.4.0, it prints:

/src/main.ts                                     200
/@fs/tmp/claude-0/vt/app/src/data.json           200
/@fs/tmp/claude-0/vt/app/internal/draft.md       200
/@fs/tmp/claude-0/vt/app/.env.local              403
/@fs/tmp/claude-0/vt/../vt-outside/notes.txt     403

Two of those are the protections doing their job. The file outside the root is refused, and .env.local is refused because .env.* is on the default server.fs.deny list. That list is a short one: .env, .env.*, key and certificate extensions, .npmrc, .yarnrc.yml and anything under .git.

The third line is the one to look at. internal/draft.md is inside the project, nothing imports it, and it comes back with a 200. The same is true of a credentials.json someone saved in the repo root, a database dump, a notes/ folder of incident write-ups, or a .pem that was renamed. If it isn’t on the deny list and it’s under the root, the server will hand it over to whoever can reach the port and knows the path.

What the new mode refuses

Vite 8.4’s allow-list is opt-in. Two settings turn it on:

// vite.config.ts
import { defineConfig } from 'vite';

export default defineConfig({
  server: {
    fs: { strict: 'extended', allow: [] },
  },
});

According to the release post, strict: 'extended' applies the same checks to modules that plugins load, and an empty allow list means only files referenced from the entrypoint, including transitive references, are served. Vite registers modules pulled in through import and through CSS url().

Same probe, same app, with that config:

/src/main.ts                                     200
/@fs/tmp/claude-0/vt/app/src/data.json           200
/@fs/tmp/claude-0/vt/app/internal/draft.md       403
/@fs/tmp/claude-0/vt/app/.env.local              403
/@fs/tmp/claude-0/vt/../vt-outside/notes.txt     403

data.json is still served because main.ts imports it. draft.md is now refused. The page works the same, and the file nobody asked for stays put.

One behaviour to know about. The allow-list is built from what the server has already seen, so a request for a module before the page that references it gets a 403. Fetching /src/main.ts first, with no earlier request for index.html, returned 403 for everything in a run with this config. In a browser the page loads first, so nothing breaks. In a script or a test that hits module URLs directly, request the page first.

Vite says it intends to make the allow-list the default in the next major version. Turning it on now is how you find the files your project reads without importing, before the default changes under you.

The network side

All of the above assumes the attacker can reach the server. By default they can’t: server.host defaults to localhost. The docs say setting it to 0.0.0.0 or true listens on all addresses, “including LAN and public addresses”.

Run with --host and the default config, and a request by the machine’s non-loopback address behaves the same as on localhost. Repeating the probe against that address, the default config served internal/draft.md with a 200, and the extended config refused it with a 403.

Vite has had to patch this exact boundary this year. GHSA-p9ff-h696-f583 (CVE-2026-39363, published 6 April 2026, rated High at CVSS v4 8.2) describes a WebSocket path where the server.fs check wasn’t enforced, so a client could read arbitrary files. It required the server to be exposed with --host or server.host and the WebSocket left on. GHSA-4w7w-66w2-5vf9 (CVE-2026-39365, Moderate) was a ../ bypass in the handling of .map files for optimised dependencies. Both are fixed in Vite 8.0.5, 7.3.2 and 6.4.2, so anything on 8.0.4 or earlier needs the upgrade regardless of config.

The allow-list doesn’t replace patching. It narrows what a future bypass could reach, because the files an attacker can ask for shrinks from the whole project to the import graph.

A related setting deserves a look at the same time. The docs say server.allowedHosts: true allows any website to send requests to the dev server through DNS rebinding, and recommend an explicit list instead. An agent asked to make the preview reachable from a phone can satisfy that request with host: true, and when a host is rejected, with allowedHosts: true. Both are one-line changes that remove a protection, so they’re worth a look in any diff that touches the Vite config.

What it can break

Anything the browser fetches that Vite didn’t see referenced will start returning 403. The usual candidates:

  • Assets loaded by string-built URLs, such as `/images/${name}.png`, when the files live outside public/.
  • Fonts or data files fetched at runtime from a path under the repo root.
  • A plugin that generates a module pointing at an asset with no import. The release post says such plugins can call this.environment.addSafeModule so users don’t have to widen allow, so a plugin that fails under the new mode is a bug report for the plugin author.
  • Monorepo packages outside the app folder. Setting allow replaces the workspace-root detection, so list those directories explicitly instead of leaving the array empty.

The probe above didn’t cover HMR, a plugin pipeline or a monorepo, so a real project may surface more cases. The failure is loud (a 403, and a line in the server’s terminal output naming the file), which makes it a cheap thing to trial.

Try it this week

Two steps, and the second matters more than the first. Add fs: { strict: 'extended', allow: [] } to the config and click through the app once, watching the terminal for messages that say a request id is outside the serving allow list. Each one is either a file the page should have imported or one that never needed to be reachable.

Then search the repo for host: true, --host and allowedHosts in config, scripts and agent instruction files. Any dev server that has to be reachable by something other than your own machine should be on 8.0.5 or later and in the allow-list mode, and the rest should stay on localhost.