chore(deps): update dependency vitest to v3 [security]#2
Conversation
|
Reviewer's Guide by SourceryThis PR updates the vitest dependency from version 1.6.0 to 1.6.1 to address a security vulnerability (CVE-2025-24964) that allows for arbitrary remote code execution. The vulnerability stems from a cross-site WebSocket hijacking (CSWSH) attack when the Sequence diagram showing the security vulnerability in Vitest API serversequenceDiagram
actor Attacker
participant MW as Malicious Website
participant VS as Vitest API Server
participant FS as File System
Note over VS: API option enabled
Note over VS: No Origin header check
Note over VS: No authorization
Attacker->>MW: Visits malicious website
MW->>VS: WebSocket connection (ws://localhost:51204/__vitest_api__)
VS-->>MW: Connection accepted (vulnerable)
MW->>VS: getFiles request
VS-->>MW: Test file paths
MW->>VS: saveTestFile (inject malicious code)
VS->>FS: Write malicious code to test file
MW->>VS: rerun command
VS->>FS: Execute modified test file
Note over FS: Arbitrary code execution
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
ce53e26 to
cce14a4
Compare
cce14a4 to
9827024
Compare
3e7fbfc to
ab89306
Compare
ab89306 to
9334502
Compare
9334502 to
42a7508
Compare
42a7508 to
c08b5b4
Compare
c08b5b4 to
d075100
Compare
ae3483b to
2599cdd
Compare
2599cdd to
3fe7303
Compare
e3d2a29 to
375bb55
Compare
375bb55 to
b1e831b
Compare
b1e831b to
b32ef06
Compare
b32ef06 to
622d572
Compare
622d572 to
bbfdf05
Compare
04609a7 to
dea32c0
Compare
dea32c0 to
305fe42
Compare
305fe42 to
075f603
Compare
075f603 to
4ccb3fc
Compare
3a06c12 to
ad9c549
Compare
ad9c549 to
bb6fc4a
Compare
bb6fc4a to
73c445a
Compare
832729b to
b841ffa
Compare
b841ffa to
8244856
Compare
8244856 to
1fc298a
Compare
1fc298a to
505db21
Compare
505db21 to
20d6be2
Compare
abcfb2c to
763f88a
Compare
763f88a to
e9ebbb3
Compare
This PR contains the following updates:
^1.6.0→^3.0.0Vitest allows Remote Code Execution when accessing a malicious website while Vitest API server is listening
CVE-2025-24964 / GHSA-9crc-q9x8-hgqq
More information
Details
Summary
Arbitrary remote Code Execution when accessing a malicious website while Vitest API server is listening by Cross-site WebSocket hijacking (CSWSH) attacks.
Details
When
apioption is enabled (Vitest UI enables it), Vitest starts a WebSocket server. This WebSocket server did not check Origin header and did not have any authorization mechanism and was vulnerable to CSWSH attacks.https://github.com/vitest-dev/vitest/blob/9a581e1c43e5c02b11e2a8026a55ce6a8cb35114/packages/vitest/src/api/setup.ts#L32-L46
This WebSocket server has
saveTestFileAPI that can edit a test file andrerunAPI that can rerun the tests. An attacker can execute arbitrary code by injecting a code in a test file by thesaveTestFileAPI and then running that file by calling thererunAPI.https://github.com/vitest-dev/vitest/blob/9a581e1c43e5c02b11e2a8026a55ce6a8cb35114/packages/vitest/src/api/setup.ts#L66-L76
PoC
calcexecutable inPATHenv var (you'll likely have it if you are running on Windows), that application will be executed.Impact
This vulnerability can result in remote code execution for users that are using Vitest serve API.
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
When Vitest UI server is listening, arbitrary file can be read and executed
CVE-2026-47429 / GHSA-5xrq-8626-4rwp
More information
Details
Summary
Arbitrary file can be read on Windows when Vitest UI server is listening, especially when exposed to the network.
Impact
Only users that match either of the following conditions are affected:
--api.hostorapi.hostconfig option)Details
The API handler for
/__vitest_attachment__uses the deprecatedisFileServingAllowedincorrectly.https://github.com/vitest-dev/vitest/blob/eb1abf08573032a532015b999ad3501c5e89e3bb/packages/ui/node/index.ts#L77
The function expects the passed value to use
cleanUrlafter the check before file system related operation.Because of this, it is possible to bypass the check by
\\?\\..\\. This is not possible on Linux as Linux errors if a directory named?does not exist.A similar problem exists in other places as well.
That said, this
isFileServingAllowedcheck does not actually prevent the API to be abused. Since the API has rerun feature and file write feature, it's possible to run arbitrary script by writing a script as a test file usingsaveTestFileand running it usingrerun. This means exposing the API / Vitest UI is equivalent to giving script execution access.On the browser mode side, there're
readFile/writeFile/saveSnapshotFile. So exposing the browser mode is equivalent to giving file read / write access.PoC
curl http://localhost:51204/__vitest__/curl "http://localhost:51204/__vitest_attachment__?path=C:\\path\\to\\project\\?\\..\\..\\secret.txt&contentType=text/plain&token=$TOKEN"(TOKEN is the API token)secret.txtthat is outside the project directoryMitigations
Vitest now ships two configuration flags,
allowWriteandallowExec, that gate the privileged operations exploited by this vulnerability. Both are disabled by default whenever the API server is bound to a non-localhosthost, ensuring that exposing the server to the network no longer implicitly grants write or execute capabilities to remote clients.When these flags are disabled, the UI also enters a read-only mode: in-browser code editing and test file execution are turned off, removing the attack surface that allowed remote code execution. Many Browser Mode features are also disabled, like attachments, artifacts or snapshots. See
browser.api.Users who require the full interactive UI on a networked host must explicitly opt in by setting
allowWriteand/orallowExectotrue.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
vitest-dev/vitest (vitest)
v3.2.6Compare Source
v3.2.5Compare Source
v3.2.4Compare Source
🐞 Bug Fixes
vitest run --watchshould be watch-mode - by @AriPerkkio in #8128 (657e8)--shard x/<count>exceeds count of test files - by @AriPerkkio in #8112 (8a18c)minWorkerswhen onlymaxWorkersspecified - by @AriPerkkio in #8110 (14dc0)task.metashould be available in custom reporter's errors - by @AriPerkkio in #8115 (27df6)View changes on GitHub
v3.2.3Compare Source
🚀 Features
🐞 Bug Fixes
expect.anyreturn type - by @sheremet-va in #8129 (47514)process.send()- by @AriPerkkio in #8125 (dfe81)View changes on GitHub
v3.2.2Compare Source
🚀 Features
🐞 Bug Fixes
createTesterscall on the main thread - by @sheremet-va in #8101 (142c7)vitest-browser-*packages - by @sheremet-va in #8103 (247ef)toEqual- by @dubzzz in #8094 (02ec8)dotreporter to work in non interactive terminals - by @bstephen1 and @AriPerkkio in #7994 (6db9f)View changes on GitHub
v3.2.1Compare Source
🐞 Bug Fixes
DeeplyAllowMatchers- by @sheremet-va in #8078 (30ab4)View changes on GitHub
v3.2.0Compare Source
🚀 Features
ctx.signal- by @sheremet-va in #7878 (e761f)test.name- by @AriPerkkio in #7809 (4af5d)vi.mockObjectto automock any object - by @hi-ogawa and @sheremet-va in #7761 (465bd)watchTriggerPatternsoption - by @sheremet-va in #7778 (a0675)workspacein favor ofprojects- by @sheremet-va and @AriPerkkio in #7923 (41beb)sequence.groupOrderoption - by @sheremet-va in #7852 (d1a1d)connectoption forplaywrightbrowser provider - by @egfx-notifications and @sheremet-va in #7915 (029c0)screenshot.saveoption - by @sheremet-va in #7777 (d9f51)onWritePathoption togithub-actions- by @nwalters512 and @AriPerkkio in #8015 (abd3b)🐞 Bug Fixes
micromatchwithpicomatch- by @sapphi-red in #7951 (df076)anytypes toAsymmetricMatcher<unknown>, withDeeplyAllowMatchers<T>- by @JoshuaKGoldberg in #7016 (8ec44)stackproperties - by @sheremet-va in #7995 (330f9)toJSONserialisation - by @sheremet-va in #8053 (3bdf0)uploadfiles relative to the project root - by @sheremet-va in #8042 (b9a31)thistype tolocators.extend- by @sheremet-va in #8069 (70fb0)--silentvalues properly - by @AriPerkkio in #8055 (8fad7)@types/chai- by @hi-ogawa in #7937 (525f5)vitest listcommand - by @sheremet-va in #7933 (ba6da)__vite_ssr_exportName__- by @hi-ogawa in #7925 (76091)getWorkerMemoryLimitpriority for vmForks - by @pengooseDev in #7960 (5a91e)View changes on GitHub
v3.1.4Compare Source
🐞 Bug Fixes
View changes on GitHub
v3.1.3Compare Source
🐞 Bug Fixes
inline: trueis set - by @sheremet-va in #7856 (a83f3)--merge-reportsto show each total run times - by @AriPerkkio in #7877 (d613b)View changes on GitHub
v3.1.2Compare Source
🐞 Bug Fixes
chaivariable invitest/globals(fix: #7474) - by @Jay-Karia in #7771 and #7474 (d9297)test.excludewhen same object passed incoverage.exclude- by @AriPerkkio in #7774 (c3751)envionmentOptions- by @hi-ogawa in #7795 (67430)awaitprofiler calls - by @AriPerkkio in #7763 (795a6)🏎 Performance
View changes on GitHub
v3.1.1Compare Source
🐞 Bug Fixes
View changes on GitHub
v3.1.0Compare Source
🚀 Features
%$option to add number of the test to its title - by @kemuridama in #7412 (df347)diff.maxDepthoption and set non-Infinityvalue as a default to reduce crash - by @hi-ogawa in #7481 (eacab)test.each/fortitle formatting - by @hi-ogawa in #7522 (ea3d6)--configLoaderCLI option - by @Carnageous and @hi-ogawa in #7574 (2a852)vitest-browser-littovitest init browserand docs - by @EskiMojo14 and @hi-ogawa in #7705 (5659a)and,orandfilterlocators - by @sheremet-va and @AriPerkkio in #7463 (63949)--silent=passed-onlyto log failed tasks only - by @AriPerkkio in #7530 (f9e1c)test.scopedto overridetest.extendfixtures per-suite - by @sheremet-va in #7233 (e5851)context.skip(boolean)- by @sheremet-va and @AriPerkkio in #7659 (6adec)🐞 Bug Fixes
diff.expand: falseas default - by @hi-ogawa in #7697 (f3420)--hideSkippedTestsshould hide suites too - by @AriPerkkio in #7695 (ba9b5)🏎 Performance
View changes on GitHub
v3.0.9Compare Source
🐞 Bug Fixes
ctx.skip()asnever- by @sirlancelot in #7608 (09f35)resolveConfigAPI - by @hi-ogawa in #7623 (db14a)toHaveBeenCalledWith(asymmetricMatcher)withundefinedarguments - by @hi-ogawa in #7624 (0fb21)getState().testPathduring collection with no isolation - by @hi-ogawa in #7640 (3fb3f)Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.