Description
Vitest is a testing framework powered by Vite. From 2.1.0 until 4.1.11 and 5.0.0-rc.2, the public mockerPlugin and standalone interceptorPlugin exports in packages/mocker/src/node/interceptorPlugin.ts register the vitest:interceptor:register handler on Vite's unauthenticated HMR WebSocket without validating redirect targets against the file-serving allowlist. The implementation processes event.redirect without enforcing server.fs.allow and server.fs.deny through isFileLoadingAllowed. A remote client that can reach an exposed development server can submit an opaque URL scheme preserving .. segments, causing join(server.config.root, redirectUrl.pathname) to resolve outside the project root. The plugin's load hook then returns readFile(mock.redirect, 'utf-8') as module source, disclosing local files readable by the dev-server process. Vitest browser mode uses a token-authenticated RPC and is not remotely unauthenticated by default, although the same boundary check was missing on that path. This issue is fixed in versions 4.1.11 and 5.0.0-rc.2.
Published: 2026-09-01
Score: 5.9 Medium
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

A path traversal flaw was discovered in the Vitest mocker and interceptor plugins. The code registers an HMR WebSocket handler that does not validate redirect URLs against the server’s file‑serving allowlist. When a remote client submits a URL containing ".." path components, the server resolves the redirect outside the project root and the plugin loads the file content as module source. The result is that an attacker can read any file readable by the dev‑server process, compromising confidentiality of local source code and configuration. The vulnerability is classified as CWE-22 and results in moderate impact denoted by a CVSS score of 5.9.

Affected Systems

The issue affects Vitest releases from version 2.1.0 through 4.1.11 and 5.0.0-rc.2. The affected packages are the @vitest/mocker and vitest-dev:vitest repositories. Versions prior to 4.1.11 and 5.0.0-rc.2 are impacted; the problem is present in the public mockerPlugin and interceptorPlugin exports in the packages/mocker/src/node/interceptorPlugin.ts file.

Risk and Exploitability

The vulnerability is remotely exploitable as an unauthenticated client can connect to an exposed development server via the Vite HMR WebSocket. The attack path relies on sending a specially crafted redirect URL; no additional authentication is required. The CVSS score of 5.9 indicates moderate severity, and the EPSS score is not available, so the exploitation probability is uncertain. The vulnerability is not listed in the CISA KEV catalog. Because Vitest’s browser mode employs token‑authenticated RPC and is not remotely unauthenticated by default, it mitigates the effect for users running Vitest in browser mode, but the development‑server exposure still presents a risk for typical Vite‑powered test runs.

Generated by OpenCVE AI on September 1, 2026 at 23:24 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Vitest to version 4.1.11 or later (or 5.0.0‑rc.2 or later) where the redirect validation bug is fixed
  • If immediate upgrade is not possible, restrict the Vitest dev server to a local network only and protect it behind a firewall or VPN to prevent unauthenticated remote access
  • Disable or remove the @vitest/mocker and interceptorPlugin exports until a fix is applied, or configure the HMR WebSocket to reject redirects containing ".." path segments so that the server does not resolve paths outside the root

Generated by OpenCVE AI on September 1, 2026 at 23:24 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Wed, 02 Sep 2026 00:15:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

threat_severity

Moderate


Tue, 01 Sep 2026 22:00:00 +0000

Type Values Removed Values Added
Description Vitest is a testing framework powered by Vite. From 2.1.0 until 4.1.11 and 5.0.0-rc.2, the public mockerPlugin and standalone interceptorPlugin exports in packages/mocker/src/node/interceptorPlugin.ts register the vitest:interceptor:register handler on Vite's unauthenticated HMR WebSocket without validating redirect targets against the file-serving allowlist. The implementation processes event.redirect without enforcing server.fs.allow and server.fs.deny through isFileLoadingAllowed. A remote client that can reach an exposed development server can submit an opaque URL scheme preserving .. segments, causing join(server.config.root, redirectUrl.pathname) to resolve outside the project root. The plugin's load hook then returns readFile(mock.redirect, 'utf-8') as module source, disclosing local files readable by the dev-server process. Vitest browser mode uses a token-authenticated RPC and is not remotely unauthenticated by default, although the same boundary check was missing on that path. This issue is fixed in versions 4.1.11 and 5.0.0-rc.2.
Title Vitest: Path Traversal / Arbitrary File Read via @vitest/mocker Redirect Mock
Weaknesses CWE-22
References
Metrics cvssV3_1

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


Subscriptions

No data.

cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-09-01T21:26:26.110Z

Reserved: 2026-09-01T16:27:58.129Z

Link: CVE-2026-84373

cve-icon Vulnrichment

No data.

cve-icon NVD

Status : Received

Published: 2026-09-01T22:17:19.143

Modified: 2026-09-01T22:17:19.143

Link: CVE-2026-84373

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-09-01T21:26:26Z

Links: CVE-2026-84373 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-09-01T23:30:05Z

Weaknesses
  • CWE-22

    Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')