Vulnerability GHSA-vfpm-58rq-9qcg
Summary
Vite: First 4 bytes of files outside of `server.fs` setting is exposed by `?vite-wasm-instance`
Details
Summary
The first 4 bytes of files outside of server.fs setting can be returned to the browser by a request containing ?vite-wasm-instance.
Impact
Only apps that match one of the following conditions are affected:
- explicitly expose the Vite dev server to the network using
--hostor theserver.hostoption - there's a file that has a sensitive information in the first 4 bytes
- uses Node.js or Deno to run Vite (if Bun is used, it is not affected)
Details
Requests containing the ?vite-wasm-instance query are handled by the internal Wasm plugin's load hook. The hook removes the query and reads the resulting path directly from disk, but the server.fs checks were not applied.
After reading the file, Vite attempts to parse it as WebAssembly. When that parse fails, Node and deno throws an error that contains the first 4 bytes of the file.
PoC
Create a denied file and start an affected Vite dev server:
echo 'SECRET_KEY=abc123\n' > .env
npm run dev
curl 'http://localhost:5173/.env?vite-wasm-instance'
This will show
Failed to parse WASM file "<root>/.env": WebAssembly.compile(): expected magic word 00 61 73 6d, found 53 45 43 52 @+0
Related Vulnerabilities
Other vulnerabilities affecting the same packages