CVE-2026-112949: CWE-94: Improper Control of Generation of Code ('Code Injection') in vitest-dev vitest
Description
Vitest versions from 2.1.0-beta.7 up to but not including 4.1.12, and from 5.0.0 up to but not including 5.0.3, contain a code injection vulnerability. An unauthenticated non-browser WebSocket client can register a manual mock with attacker-controlled input that is inserted unescaped into generated module source code. This leads to execution of attacker-controlled JavaScript in the developer's browser context on the development-server origin. The issue is fixed in versions 4.1.12 and 5.0.3.
CVSS v3.1
Score 4.7medium
Affected software
vitest-dev
vitest
@vitest
mocker
pkg:npm/vitest-dev/vitestRun on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
Vitest, a Vite-native testing framework for JavaScript and TypeScript, suffers from a CWE-94 code injection vulnerability in versions >=2.1.0-beta.7 <4.1.12 and >=5.0.0 <5.0.3. An unauthenticated non-browser WebSocket client able to reach a development server using interceptorPlugin can register a manual mock whose attacker-controlled URL is inserted unescaped into the generated module source. When the developer's browser loads this module, the attacker-controlled JavaScript executes with the development-server origin privileges. This vulnerability allows partial code injection leading to confidentiality and integrity impacts. The vulnerability has a CVSS 3.1 score of 4.7 (medium severity) and is fixed in versions 4.1.12 and 5.0.3.
Potential Impact
The vulnerability allows an unauthenticated attacker with network access to the development server to inject and execute arbitrary JavaScript code in the developer's browser context on the development-server origin. This can lead to partial confidentiality and integrity loss of the development environment. There is no indication of availability impact. No known exploits are reported in the wild.
Mitigation Recommendations
Upgrade Vitest to version 4.1.12 or later, or 5.0.3 or later, where this vulnerability is fixed. No other mitigations are indicated by the vendor advisory.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-10-19T21:30:47.245Z
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 6ad789f62cdf04f6563b8497
Added to database: 10/20/2026, 15:34:14 UTC
Last enriched: 10/20/2026, 15:49:01 UTC
Last updated: 10/20/2026, 19:06:08 UTC
Views: 5
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.