CVE-2026-112949: @vitest/mocker Code Injection Vulnerability via Unauthenticated Manual Mock Registration

@vitest/mocker Updated 21 Oct 2026

Summary

21/10/2026
Yes i
Moderate
4.7

CVE-2026-112949: Vitest: Code injection via unauthenticated manual mock registration. Affects @vitest/mocker across 2 version ranges.

>= 2.1.0-beta.7, < 4.1.12 >= 5.0.0-beta.1, < 5.0.3

Fixed in 4.1.12 or 5.0.3, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Vitest is a modern testing framework designed for Vite applications, providing developers with tools to create and run tests efficiently. The @vitest/mocker package allows for mocking modules during testing, enabling developers to simulate various scenarios without relying on actual implementations. However, a vulnerability exists in the way this package handles mock registrations, specifically through its interceptorPlugin, which can be exploited by unauthenticated clients.

Vulnerability Detail

The vulnerability arises from the @vitest/mocker's interceptorPlugin, which accepts mock registrations over Vite's dev-server WebSocket without any authentication. This allows an attacker with access to the dev server to inject arbitrary JavaScript into the module source by manipulating the mock's URL. The lack of escaping for the interpolated URL means that malicious code can be executed in the developer's browser, leading to potential data theft, unauthorized actions, and other security risks. The vulnerability is classified under CWE-94 (Code Injection) and has a CVSS score of 4.7, indicating a moderate severity level.

How To Fix

Latest published version: 5.0.5 as of 22 Oct 2026

npm install @vitest/mocker@5.0.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 2.1.0-beta.7, < 4.1.12 4.1.12
    npm install @vitest/mocker@4.1.12
  • >= 5.0.0-beta.1, < 5.0.3 5.0.3
    npm install @vitest/mocker@5.0.3

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a temporary workaround, avoid using the interceptorPlugin or mockerPlugin directly until you can update to the patched version. Additionally, ensure that your development environment is not exposed to untrusted clients who could exploit this vulnerability.

Conclusion

The CVE-2026-112949 vulnerability in the @vitest/mocker package poses a significant risk to developers by allowing code injection through unauthenticated mock registrations. It is crucial to update to the patched versions to mitigate this risk and ensure the security of your development environment.

See every vulnerability recorded for @vitest/mocker →

Share this vulnerability

FAQ

The vulnerability allows unauthenticated clients to inject arbitrary JavaScript into modules served by the dev server, which can then execute in the developer's browser.

Developers using the @vitest/mocker package in their projects are at risk, particularly those who utilize the interceptorPlugin or mockerPlugin APIs.

You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. By analyzing your package-lock.json, Vulert can identify if your application is affected by this vulnerability.

Exploitation of this vulnerability can lead to code execution in the developer's browser, allowing attackers to access sensitive data, manipulate application behavior, and perform unauthorized actions.

Yes, avoid using the vulnerable plugins and restrict access to your development server to trusted clients only until the package is updated.

Related vulnerabilities

Recent vulnerabilities recorded for @vitest/mocker.

How To Fix

Latest published version: 5.0.5 as of 22 Oct 2026

npm install @vitest/mocker@5.0.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • >= 2.1.0-beta.7, < 4.1.12 4.1.12
    npm install @vitest/mocker@4.1.12
  • >= 5.0.0-beta.1, < 5.0.3 5.0.3
    npm install @vitest/mocker@5.0.3

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback