CVE-2025-24964
CVE-2025-24964
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- Required
- Scope
- Changed
- Confidentiality
- High
- Integrity
- High
- Availability
- High
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.
Comprehensive Technical Analysis of CVE-2025-24964
1. Vulnerability Assessment and Severity Evaluation
CVE ID: CVE-2025-24964
Description:
Vitest, a testing framework powered by Vite, is vulnerable to arbitrary remote code execution (RCE) through Cross-site WebSocket Hijacking (CSWSH) attacks. The vulnerability arises when the api option is enabled, which starts a WebSocket server without proper Origin header checks or authorization mechanisms. This allows an attacker to exploit the saveTestFile and rerun APIs to inject and execute arbitrary code.
CVSS Score: 9.6
Severity Evaluation: The CVSS score of 9.6 indicates a critical vulnerability. This high score is due to the potential for remote code execution, which can lead to complete system compromise. The lack of proper Origin header checks and authorization mechanisms exacerbates the risk.
2. Potential Attack Vectors and Exploitation Methods
Attack Vectors:
- Cross-site WebSocket Hijacking (CSWSH): An attacker can exploit the WebSocket server by hijacking the connection and sending malicious requests.
- Malicious Website Access: Users accessing a malicious website while the Vitest API server is listening can be targeted.
Exploitation Methods:
- WebSocket Server Exploitation: The attacker can send requests to the
saveTestFileAPI to inject malicious code into a test file. - Code Execution: After injecting the code, the attacker can call the
rerunAPI to execute the malicious code, leading to arbitrary code execution.
3. Affected Systems and Software Versions
Affected Versions:
- Vitest versions prior to 1.6.1, 2.1.9, and 3.0.5.
Affected Systems:
- Any system running Vitest with the
apioption enabled. - Systems where users might access malicious websites while the Vitest API server is active.
4. Recommended Mitigation Strategies
Immediate Actions:
- Upgrade Vitest: Upgrade to versions 1.6.1, 2.1.9, or 3.0.5, which include the patch for this vulnerability.
- Disable
apiOption: If upgrading is not immediately possible, disable theapioption to prevent the WebSocket server from starting.
Long-term Strategies:
- Regular Patch Management: Implement a robust patch management process to ensure timely updates of all software components.
- Network Segmentation: Segregate development and testing environments from production environments to limit the impact of potential exploits.
- Security Awareness Training: Educate users about the risks of accessing untrusted websites, especially while development tools are active.
5. Impact on Cybersecurity Landscape
Broader Implications:
- Supply Chain Security: This vulnerability highlights the importance of securing development and testing tools, which are often overlooked in the supply chain security context.
- WebSocket Security: The lack of proper Origin header checks and authorization mechanisms in WebSocket servers is a recurring issue that needs broader attention.
- Remote Code Execution Risks: The potential for RCE underscores the critical need for robust security measures in all software components, including testing frameworks.
6. Technical Details for Security Professionals
Vulnerability Details:
- WebSocket Server: The WebSocket server in Vitest does not check the Origin header and lacks authorization mechanisms, making it susceptible to CSWSH attacks.
- APIs Involved:
saveTestFile: Allows editing of test files.rerun: Allows rerunning of tests.
Exploitation Steps:
- Access Malicious Website: The attacker lures the user to access a malicious website.
- WebSocket Hijacking: The attacker hijacks the WebSocket connection to the Vitest API server.
- Code Injection: The attacker uses the
saveTestFileAPI to inject malicious code into a test file. - Code Execution: The attacker calls the
rerunAPI to execute the injected code, leading to arbitrary code execution.
References:
- Vitest API Setup Code
- Vitest API Setup Code
- GitHub Security Advisory
- Vitest Configuration Documentation
Conclusion: CVE-2025-24964 is a critical vulnerability that underscores the need for robust security measures in development tools. Immediate mitigation through upgrading Vitest and long-term strategies such as regular patch management and network segmentation are essential to protect against such threats.