Vite allows server.fs.deny to be bypassed with .svg or relative paths
Affected releases · vite
- 6.x6.0.0 – 6.2.4Fixed in 6.2.5
- 5.x5.0.0 – 5.4.16Fixed in 5.4.17
- 4.x4.0.0 – 4.5.11Fixed in 4.5.12
- 3.x and older0.1.0 – 3.2.11No fix, no longer updated
On 6.x, the newest line:
npm install vite@6.2.5Not affected
8.0.0 – 8.3.5
34 releases, latest
Affected
6.0.0 – 6.0.13
14 releases
Fixed
6.0.14 – 6.0.15
2 releases
Affected
6.1.0 – 6.1.3
4 releases
Fixed
6.1.4 – 6.1.6
3 releases
Affected
6.2.0 – 6.2.4
5 releases
Fixed
6.2.5 – 6.4.5
17 releases
Affected
5.0.0 – 5.4.16
62 releases
Fixed
5.4.17 – 5.4.21
5 releases
Affected
4.0.0 – 4.5.11
50 releases
Fixed
4.5.12 – 4.5.14
3 releases
Affected
3.0.0 – 3.2.11
30 releases
Affected
2.0.0 – 2.9.18
97 releases
Affected
0.1.0 – 0.20.10
78 releases
Is your project affected?
Paste your package.json, or type the range you declare for vite. It is read in your browser and sent nowhere.
What happens
Summary
The contents of arbitrary files can be returned to the browser.
Impact
Only apps explicitly exposing the Vite dev server to the network (using --host or server.host config option) are affected.
Details
.svg
Requests ending with .svg are loaded at this line.
github.com/vitejs/vite/blob/037f801075ec35bb6e5…
By adding ?.svg with ?.wasm?init or with sec-fetch-dest: script header, the restriction was able to bypass.
This bypass is only possible if the file is smaller than build.assetsInlineLimit (default: 4kB) and when using Vite 6.0+.
relative paths
The check was applied before the id normalization. This allowed requests to bypass with relative paths (e.g. ../../).
PoC
npm create vite@latest cd vite-project/ npm install npm run dev
send request to read etc/passwd
curl 'http://127.0.0.1:5173/etc/passwd?.svg?.wasm?init'
curl 'http://127.0.0.1:5173/@fs/x/x/x/vite-project/?/../../../../../etc/passwd?import&?raw'