Vite Vulnerable to Path Traversal in Optimized Deps `.map` Handling
Affected releases · vite
- 8.x8.0.0 – 8.0.4Fixed in 8.0.5
- 7.x7.0.0 – 7.3.1Fixed in 7.3.2
- 6.x6.0.0 – 6.4.1Fixed in 6.4.2
- 5.x and older0.1.0 – 5.4.21No fix, no longer updated
On 8.x, the newest line:
npm install vite@8.0.5Affected
8.0.0 – 8.0.4
5 releases
Fixed
8.0.5 – 8.3.5
29 releases, latest
Affected
7.0.0 – 7.3.1
31 releases
Fixed
7.3.2 – 7.3.7
5 releases
Affected
6.0.0 – 6.4.1
41 releases
Fixed
6.4.2 – 6.4.5
4 releases
Affected
5.0.0 – 5.4.21
67 releases
Affected
4.0.0 – 4.5.14
53 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
Any files ending with .map even out side the project can be returned to the browser.
Impact
Only apps that match the following conditions are affected:
explicitly exposes the Vite dev server to the network (using
--hostorserver.hostconfig option)have a sensitive content in files ending with
.mapand the path is predictable
Details
In Vite v7.3.1, the dev server’s handling of .map requests for optimized dependencies resolves file paths and calls readFile without restricting ../ segments in the URL. As a result, it is possible to bypass the server.fs.strict allow list and retrieve .map files located outside the project root, provided they can be parsed as valid source map JSON.
PoC
Create a minimal PoC sourcemap outside the project root
cat > /tmp/poc.map <<'EOF' {"version":3,"file":"x.js","sources":[],"names":[],"mappings":""} EOFStart the Vite dev server (example)
pnpm -C playground/fs-serve dev --host 127.0.0.1 --port 18080
Confirm that direct
/@fsaccess is blocked bystrict(returns 403)Inject
../segments under the optimized deps.mapURL prefix to reach/tmp/poc.map