Packages / @vitest/browser / Security
Vitest browser mode serves arbitrary files
Affected releases · @vitest/browser
- 3.x3.0.0 – 3.0.3Fixed in 3.0.4
- 2.x2.0.4 – 2.1.8Fixed in 2.1.9
On 3.x, the newest line:
npm install @vitest/browser@3.0.4Not affected
5.0.0 – 5.0.5
6 releases, latest
Affected
3.0.0 – 3.0.3
4 releases
Fixed
3.0.4 – 3.2.7
19 releases
Not affected
2.0.0 – 2.0.3
4 releases
Affected
2.0.4 – 2.1.8
11 releases
Fixed
2.1.9
1 release
Is your project affected?
Paste your package.json, or type the range you declare for @vitest/browser. It is read in your browser and sent nowhere.
What happens
Summary
__screenshot-error handler on the browser mode HTTP server that responds any file on the file system. Especially if the server is exposed on the network by browser.api.host: true, an attacker can send a request to that handler from remote to get the content of arbitrary files.
Details
This __screenshot-error handler on the browser mode HTTP server responds any file on the file system.
github.com/vitest-dev/vitest/blob/f17918a79969d…
This code was added by 2d62051.
PoC
Create a directory and change the current directory to that directory
Run
npx vitest init browserRun
npm run test:browserRun
curl http://localhost:63315/__screenshot-error?file=/path/to/any/file
Impact
Users explicitly exposing the browser mode server to the network by browser.api.host: true may get any files exposed.