Arbitrary Code Injection Affecting @vitest/mocker package, versions >=2.1.0-beta.7 <4.1.12


Severity

Recommended
0.0
low
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.24% (15th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary Code Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-VITESTMOCKER-21347792
  • published21 Oct 2026
  • disclosed20 Oct 2026
  • creditThai Son Dinh

Introduced: 20 Oct 2026

NewCVE-2026-112949  (opens in a new tab)
CWE-94  (opens in a new tab)

How to fix?

Upgrade @vitest/mocker to version 4.1.12 or higher.

Overview

@vitest/mocker is a Vitest module mocker implementation

Affected versions of this package are vulnerable to Arbitrary Code Injection via the redirect mock handling in interceptorPlugin.ts and insufficient escaping in createManualModuleSource in utils.ts. In the redirect path, a URL pathname containing backslashes can escape the server root via path traversal, allowing an attacker to cause the server to serve files outside the intended root directory. In the manual mock source generation, module URLs and export names are interpolated directly into generated JavaScript without JSON serialization, allowing injection of arbitrary code into the generated module source.

CVSS Base Scores

version 4.0
version 3.1