vite allows server.fs.deny bypass via backslash on Windows
Affected releases · vite
- 7.x7.0.0 – 7.1.10Fixed in 7.1.11
- 6.x6.0.0 – 6.4.0Fixed in 6.4.1
- 5.x5.0.0 – 5.4.20Fixed in 5.4.21
- 4.x and older2.9.18 – 4.5.14No fix, no longer updated
On 7.x, the newest line:
npm install vite@7.1.11Not affected
8.0.0 – 8.3.5
34 releases, latest
Affected
7.0.0 – 7.0.7
8 releases
Fixed
7.0.8
1 release
Affected
7.1.0 – 7.1.10
11 releases
Fixed
7.1.11 – 7.3.7
16 releases
Affected
6.0.0 – 6.4.0
40 releases
Fixed
6.4.1 – 6.4.5
5 releases
Affected
5.0.0 – 5.4.20
66 releases
Fixed
5.4.21
1 release
Affected
4.0.0 – 4.5.14
53 releases
Affected
3.0.0 – 3.2.11
30 releases
Not affected
2.0.0 – 2.9.17
96 releases
Affected
2.9.18
1 release
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
Files denied by server.fs.deny were sent if the URL ended with \ when the dev server is running on Windows.
Impact
Only apps that match the following conditions are affected:
explicitly exposes the Vite dev server to the network (using --host or
server.hostconfig option)running the dev server on Windows
Details
server.fs.deny can contain patterns matching against files (by default it includes .env, .env.*, *.{crt,pem} as such patterns). These patterns were able to bypass by using a back slash(\). The root cause is that fs.readFile('/foo.png/') loads /foo.png.
PoC
npm create vite@latest cd vite-project/ cat "secret" > .env npm install npm run dev curl --request-target /.env\ http://localhost:5173