vitest: Missing Origin Validation in WebSockets
CVE-2025-24964 is a high-severity missing origin validation in websockets vulnerability in vitest from Vitest-dev, with a CVSS 3.1 base score of 8.8 out of 10. It can be exploited remotely over the network by an unauthenticated attacker, but only if a user takes part, for example by opening a link or file. Affected vitest versions: <= 0.0.125; >= 1.0.0, < 1.6.1; >= 2.0.0, < 2.1.9, and others listed below. The record does not name a fixed version, so check the vendor advisory. There is no confirmed exploitation so far. EPSS estimates a 0.68% chance of exploitation within 30 days, higher than 53% of scored CVEs.
High severity with no evidence of exploitation so far.
What to do
- Check which version of vitest you run against the affected versions below, and install the vendor's latest release.
- Read the advisory on github.com for workarounds and exact fixed builds.
- Until you can update, restrict network access to the affected service so it is not reachable from untrusted networks.
- Because the attack needs a user to take part, warn users about unexpected links and files related to this product until it is patched.
Affected products and versions
| Vendor | Product | Affected versions | Fixed in |
|---|---|---|---|
| Vitest-dev | vitest | <= 0.0.125; >= 1.0.0, < 1.6.1; >= 2.0.0, < 2.1.9; >= 3.0.0, < 3.0.5 | Not stated |
Version data comes from the organisation that assigned the CVE. Confirm against the vendor advisory before deciding you are unaffected.
How the severity score breaks down
- Attack vector
- NetworkCan be exploited remotely over a network, including the internet.
- Attack complexity
- LowNo special conditions are needed; the attack works reliably.
- Privileges required
- NoneNo account or login is needed.
- User interaction
- RequiredA user must take an action such as opening a file or link.
- Scope
- UnchangedImpact stays within the vulnerable component.
- Confidentiality
- HighAll data handled by the component can be read.
- Integrity
- HighData or code can be modified at will.
- Availability
- HighThe component can be taken down completely.
Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H. Scored by NVD.
| Scoring system | Score | Severity | Scored by |
|---|---|---|---|
| CVSS 3.1 | 9.6 | Critical | CNA (github.com) |
| CVSS 3.1 | 8.8 | High | NVD |
Official 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.
Source: the CVE record as published by its numbering authority, via NVD and CVE.org.
The underlying weakness: Missing Origin Validation in WebSockets
The product uses a WebSocket, but it does not properly verify that the source of data or communication is valid.
How developers prevent this class of flaw
- Enable CORS-like access restrictions by verifying the 'Origin' header during the WebSocket handshake.
- Use a randomized CSRF token to verify requests.
- Use TLS to securely communicate using 'wss' (WebSocket Secure) instead of 'ws'.
More Missing Origin Validation in WebSockets vulnerabilities (CWE-1385)
Timeline
- CVE record published.
- CISA published its SSVC assessment (exploitation: poc, automatable: no, technical impact: total).
- Record last changed materially (score, affected products, status or references).
References
Advisories
Other references
Other vulnerabilities in vitest
- 9.4 Critical severity
- 9.8 Critical severity
- 9.6 Critical severity
- 7.5 High severity
Recent Missing Origin Validation in WebSockets vulnerabilities
- 9.4 Critical severity
- 9.8 Critical severity
Spotted an error? Tell us.