# CVE-2025-24964: Vitest remote code execution via CSWSH in WebSocket API

Source: https://junglewise.ai/threats/cve-2025-24964-vitest-remote-code-execution-via-cswsh-in-websocket-api  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2025-02-04. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2025-24964 · Severity: low · CVSS 3.1 · Published 2025-02-04

Vitest is a testing framework used by developers to run test suites. When the optional API server is enabled (which powers the Vitest UI), an attacker can visit a malicious website and exploit a lack of origin verification on the WebSocket connection to inject and execute arbitrary code on the developer's machine. This affects developers actively using Vitest with the API/UI enabled.

Technologies: [Vitest](https://junglewise.ai/threats/technologies/npm-vitest).

## Quick answers

**Is CVE-2025-24964 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2025-24964 being exploited in the wild.

**How severe is CVE-2025-24964?** Low severity, with a CVSS score of 3.1, published 4 February 2025.

**Which products and versions are affected?** Vitest SEMVER:introduced=1.0.0,fixed=1.6.1.

**Is there a fix for CVE-2025-24964?** Yes. Vitest: upgrade to 1.6.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2025-24964 attacked?** It is attacked over the network.

**Am I affected by CVE-2025-24964?** Check whether you run Vitest at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Vitest: upgrade to 1.6.1 or later

## Technical details

The vulnerability is a Cross-site WebSocket Hijacking (CSWSH) attack affecting Vitest's API server. When the API option is enabled (including automatically when using Vitest UI), a WebSocket server is started but fails to validate the Origin header or implement authorization checks. An attacker can craft a malicious website that, when visited by a developer running Vitest, establishes a WebSocket connection to the local Vitest server and calls the saveTestFile API to inject arbitrary code into a test file, followed by calling the rerun API to execute it. No user action beyond visiting a website is required beyond having Vitest running with API enabled. Patches are available in versions 1.6.1+, 2.1.9+, and 3.0.5+.

## Affected products

- Vitest Vitest >=1.0.0, <1.6.1; >=2.0.0, <2.1.9; >=3.0.0, <3.0.5

## Identifiers

- CVE-2025-24964
- GHSA-9crc-q9x8-hgqq

## Timeline

- 2025-02-04: disclosed: Advisory published
- 2025-02-04: patched: Fixes released for versions 1.6.1, 2.1.9, and 3.0.5

## References

- [https://github.com/vitest-dev/vitest/security/advisories/GHSA-9crc-q9x8-hgqq](https://github.com/vitest-dev/vitest/security/advisories/GHSA-9crc-q9x8-hgqq)

## Related threats

- [Vitest @vitest/mocker path traversal in redirect mock](https://junglewise.ai/threats/cve-2026-84373-vitest-vitest-mocker-path-traversal-in-redirect-mock)
- [Vitest path traversal and remote code execution in UI/API server](https://junglewise.ai/threats/cve-2026-47429-vitest-path-traversal-and-remote-code-execution-in-ui-api-server)
