Skip to main content

CVE-2026-112949: CWE-94: Improper Control of Generation of Code ('Code Injection') in vitest-dev vitest

0
Medium
VulnerabilityCVE-2026-112949cvecve-2026-112949cwe-94cwe-116cwe-306
Published: 10/20/2026 (10/20/2026, 15:19:03 UTC)
Source: CVE Database V5
Vendor/Project: vitest-dev
Product: 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

Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N

Affected software

vitest-dev

vitest

Affected versions
>=2.1.0-beta.7 <4.1.12>=5.0.0 <5.0.3

@vitest

mocker

Affected versions
>=2.1.0-beta.7 <4.1.12>=5.0.0 <5.0.3
vitest-dev/vitest
pkg:npm/vitest-dev/vitest
Affected versions
>=2.1.0-beta.7 <4.1.12>=5.0.0 <5.0.3

Run 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

AILast updated: 10/20/2026, 15:49:01 UTC

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.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

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 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

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

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses