Description
Vitest is a Vite-native testing framework for JavaScript and TypeScript projects. From 2.1.0-beta.7 until 4.1.12 and 5.0.3, an unauthenticated non-browser WebSocket client that can reach a development server using interceptorPlugin can register a manual mock whose attacker-controlled url createManualModuleSource inserts unescaped into generated module source. When the developer browser loads the affected module, attacker-controlled JavaScript executes on the development-server origin. This issue is fixed in versions 4.1.12 and 5.0.3.
Published: 2026-10-20
Score: 4.7 Medium
EPSS: < 1% Very Low
KEV: No
Impact: Code Injection leading to arbitrary JavaScript execution in the developer’s browser context
Action: Immediate Patch
AI Analysis

Impact

The vulnerability resides in Vitest’s interceptorPlugin during manual mock registration. An unauthenticated non‑browser WebSocket client that can connect to the development server may supply an arbitrary URL to createManualModuleSource. The framework fails to escape this URL before inserting it into a generated module source. Consequently, when the developer’s browser loads the affected module, the attacker’s JavaScript runs in the context of the development‑server origin. This code injection flaw corresponds to CWE‑94, is compounded by improper encoding (CWE‑116), lack of authentication (CWE‑306), and also represents a cross‑site scripting vulnerability (CWE‑79), allowing an attacker to execute arbitrary code within the browser environment that has the same privileges as the developer user.

Affected Systems

Affected vendors are @vitest:mocker and vitest-dev:vitest. The security issue exists in all releases from 2.1.0‑beta.7 up through 4.1.12 and 5.0.3, inclusive. The vulnerability is fixed starting with Vitest version 4.1.12 and 5.0.3. Projects using older or unpatched versions of Vitest in a development environment are susceptible.

Risk and Exploitability

The CVSS v3.1 score of 4.7 indicates a moderate severity when viewed in isolation. The EPSS is not available, and the vulnerability is not currently listed in the CISA KEV catalog, suggesting no known exploit kits but not dismissing the risk. Likely exploitation requires the development server to be reachable over a WebSocket interface that permits unauthenticated clients. An attacker could craft a malicious URL, connect through a WebSocket, trigger the mock registration, and cause arbitrary JavaScript to execute when a developer loads the module in the browser. While this does not affect the production runtime, it presents a significant risk during development, especially if the dev server is exposed to untrusted networks.

Generated by OpenCVE AI on October 22, 2026 at 19:58 UTC.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply the latest Vitest release (v4.1.12 or newer), or v5.0.3, to eliminate the vulnerability.
  • Update or replace the interceptorPlugin logic to validate and sanitize URLs before injecting them into generated module sources.
  • Restrict access to the development server’s WebSocket interface to trusted users or internal networks to prevent unauthorized clients from registering manual mocks.

Generated by OpenCVE AI on October 22, 2026 at 19:58 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-qxg6-89mg-rqv8 Vitest: Code injection via unauthenticated manual mock registration
History

Fri, 23 Oct 2026 02:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Wed, 21 Oct 2026 00:30:00 +0000

Type Values Removed Values Added
Weaknesses CWE-79
References
Metrics threat_severity

None

threat_severity

Moderate


Tue, 20 Oct 2026 20:30:00 +0000

Type Values Removed Values Added
First Time appeared Vitest.dev
Vitest.dev mocker
Vitest.dev vitest
Vendors & Products Vitest.dev
Vitest.dev mocker
Vitest.dev vitest

Tue, 20 Oct 2026 15:30:00 +0000

Type Values Removed Values Added
Description Vitest is a Vite-native testing framework for JavaScript and TypeScript projects. From 2.1.0-beta.7 until 4.1.12 and 5.0.3, an unauthenticated non-browser WebSocket client that can reach a development server using interceptorPlugin can register a manual mock whose attacker-controlled url createManualModuleSource inserts unescaped into generated module source. When the developer browser loads the affected module, attacker-controlled JavaScript executes on the development-server origin. This issue is fixed in versions 4.1.12 and 5.0.3.
Title Vitest: Code injection via unauthenticated manual mock registration
Weaknesses CWE-116
CWE-306
CWE-94
References
Metrics cvssV3_1

{'score': 4.7, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N'}


Subscriptions

Vitest.dev Mocker Vitest
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-10-23T01:42:51.858Z

Reserved: 2026-10-19T21:30:47.245Z

Link: CVE-2026-112949

cve-icon Vulnrichment

Updated: 2026-10-23T01:42:37.180Z

cve-icon NVD

Status : Awaiting Analysis

Published: 2026-10-20T16:17:05.660

Modified: 2026-10-23T02:16:54.907

Link: CVE-2026-112949

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-10-20T15:19:03Z

Links: CVE-2026-112949 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-10-22T20:00:12Z

Weaknesses
  • CWE-116

    Improper Encoding or Escaping of Output

  • CWE-306

    Missing Authentication for Critical Function

  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

  • CWE-94

    Improper Control of Generation of Code ('Code Injection')