Vite has a `server.fs.deny` bypassed for `inline` and `raw` with `?import` query
Affected releases · vite
- 6.x6.0.0 – 6.2.3Fixed in 6.2.4
- 5.x5.0.0 – 5.4.15Fixed in 5.4.16
- 4.x4.0.0 – 4.5.10Fixed in 4.5.11
- 3.x and older0.1.0 – 3.2.11No fix, no longer updated
On 6.x, the newest line:
npm install vite@6.2.4Not affected
8.0.0 – 8.3.5
34 releases, latest
Affected
6.0.0 – 6.0.12
13 releases
Fixed
6.0.13 – 6.0.15
3 releases
Affected
6.1.0 – 6.1.2
3 releases
Fixed
6.1.3 – 6.1.6
4 releases
Affected
6.2.0 – 6.2.3
4 releases
Fixed
6.2.4 – 6.4.5
18 releases
Affected
5.0.0 – 5.4.15
61 releases
Fixed
5.4.16 – 5.4.21
6 releases
Affected
4.0.0 – 4.5.10
49 releases
Fixed
4.5.11 – 4.5.14
4 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
base64 encoded content of non-allowed files is exposed using
?inline&import(originally reported as?import&?inline=1.wasm?init)content of non-allowed files is exposed using
?raw?import
/@fs/ isn't needed to reproduce the issue for files inside the project root.
PoC
Original report (check details above for simplified cases):
The ?import&?inline=1.wasm?init ending allows attackers to read arbitrary files and returns the file content if it exists. Base64 decoding needs to be performed twice
$ npm create vite@latest $ cd vite-project/ $ npm install $ npm run dev
Example full URL http://localhost:5173/@fs/C:/windows/win.ini?import&?inline=1.wasm?init