5.3medium
Vite allows server.fs.deny to be bypassed with .svg or relative paths
- Severity
- 5.3medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 1.74% (higher than 78% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-xcj6-pq6g-qj4x
Description
Vite is a frontend tooling framework for javascript. The contents of arbitrary files can be returned to the browser. By adding ?.svg with ?.wasm?init or with sec-fetch-dest: script header, the server.fs.deny 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+. Only apps explicitly exposing the Vite dev server to the network (using --host or server.host config option) are affected. This vulnerability is fixed in 4.5.12, 5.4.17, 6.0.14, 6.1.4, and 6.2.5.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| vitejs vite | < 4.5.12, >=5.0.0, < 5.4.17, >=6.0.0, < 6.0.14, >=6.1.0, < 6.1.4, >=6.2.0, < 6.2.5 | CVE List |
| vite (npm) | from 6.2.0 before 6.2.5, from 6.1.0 before 6.1.4, from 6.0.0 before 6.0.14, from 5.0.0 before 5.4.17, before 4.5.12 | GitHub Advisory Database |
All scores
| GitHub_M | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N |
| GitHub | 5.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N |
Classification
What each source says
CVE List
Vite is a frontend tooling framework for javascript. The contents of arbitrary files can be returned to the browser. By adding ?.svg with ?.wasm?init or with sec-fetch-dest: script header, the server.fs.deny 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+. Only apps explicitly exposing the Vite dev server to the network (using --host or server.host config option) are affected. This vulnerability is fixed in 4.5.12, 5.4.17, 6.0.14, 6.1.4, and 6.2.5.
GitHub Advisory Database
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.
https://github.com/vitejs/vite/blob/037f801075ec35bb6e52145d659f71a23813c48f/packages/vite/src/node/plugins/asset.ts#L285-L290
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'
NVD (es)
Vite es un framework de herramientas frontend para JavaScript. El contenido de archivos arbitrarios se puede devolver al navegador. Al añadir ?.svg con ?.wasm?init o con el encabezado de script sec-fetch-dest:, se pudo omitir la restricción server.fs.deny. Esta omisión solo es posible si el archivo es menor que build.assetsInlineLimit (valor predeterminado: 4 KB) y al usar Vite 6.0 o posterior. Solo se ven afectadas las aplicaciones que exponen explícitamente el servidor de desarrollo de Vite a la red (mediante la opción de configuración --host o server.host). Esta vulnerabilidad se corrigió en las versiones 4.5.12, 5.4.17, 6.0.14, 6.1.4 y 6.2.5.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-31486 changed 2025-04-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-xcj6-pq6g-qj4x changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2025-31486 changed 2026-06-17 | Public domain |