Junglewise Threat Intelligence

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

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

Technologies: Vitest. Vendors: Vitest.

Executive brief

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.

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

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