Vulnerabilities in pkg:npm/vitest
PACKAGECVE-2026-84373 is a MODERATE (CVSS 5.9) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Vitest libraries in the npm ecosystem. The issue involves path traversal / arbitrary file read via @vitest/mocker redirect mock. Remediation is available by upgrading affected packages to version 4.1.11, 5.0.0-rc.2.
pkg:npm/vitest
Vulnerability advisories affecting package pkg:npm/vitest. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-82fw-gwwq-j7x9 | CVE-2026-84373 | MODERATE | Vitest: Path Traversal / Arbitrary File Read via @vitest/mocker Redirect Mock |
| GHSA-5xrq-8626-4rwp | CVE-2026-47429 | CRITICAL | When Vitest UI server is listening, arbitrary file can be read and executed |
| GHSA-9crc-q9x8-hgqq | CVE-2025-24964 | CRITICAL | Vitest allows Remote Code Execution when accessing a malicious website while Vitest API server is listening |
CVE-2026-84373 at a Glance
Security Impact
CVSS: 5.9
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N).
How to Fix CVE-2026-84373
To remediate this vulnerability, upgrade all affected Vitest dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install @vitest/mocker@4.1.11
npm install vitest@4.1.11
npm install vitest@5.0.0-rc.2
npm install @vitest/mocker@5.0.0-rc.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @vitest/mocker
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-84373, inspect your project dependencies using npm:
npm ls @vitest/mocker
Analyze the terminal output to locate any version of Vitest in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.1.11), your application is affected.
Note: The npm ls @vitest/mocker command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Vitest, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-84373 Affected Vitest Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@vitest/mocker
|
npm |
≥ 2.1.0
< 4.1.11
|
4.1.11
|
|
vitest
|
npm |
≥ 2.1.0
< 4.1.11
|
4.1.11
|
|
vitest
|
npm |
≥ 5.0.0-beta.1
< 5.0.0-rc.2
|
5.0.0-rc.2
|
|
@vitest/mocker
|
npm |
≥ 5.0.0-beta.1
< 5.0.0-rc.2
|
5.0.0-rc.2
|
References
Frequently Asked Questions
What is CVE-2026-84373?
Which Vitest versions are affected?
What version fixes CVE-2026-84373?
Is @vitest/mocker affected?
Is vitest affected?
What is the CVSS score of CVE-2026-84373?
What CWE is associated with CVE-2026-84373?
How can I check npm dependencies for CVE-2026-84373?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-82fw-gwwq-j7x9",
"modified" : "2026-09-08T20:46:45Z",
"published" : "2026-09-08T20:46:45Z",
"aliases" : [ "CVE-2026-84373" ],
"summary" : "Vitest: Path Traversal / Arbitrary File Read via @vitest/mocker Redirect Mock",
"details" : "## Summary\n`@vitest/mocker` registers a redirect mock's target path without validating it\nagainst the dev server's file-serving allowlist. An attacker who can reach the\ndev server's WebSocket can register a redirect mock pointing outside the project\nroot; when the mocked module is requested, the plugin's `load` hook returns\n`readFile(<attacker path>)` as the module source, disclosing local files.\n\nThis is exploitable **without authentication** only through the public\n`mockerPlugin` / standalone `interceptorPlugin` exports (used by third-party dev\nservers), which register the handler on Vite's unauthenticated HMR socket.\nVitest's own browser mode registers mocks over a **token-authenticated** RPC and\nis not remotely reachable by default (see Scope).\n\n## Affected code\n`packages/mocker/src/node/interceptorPlugin.ts`.\n\nThe `load` hook is the file-read sink:\n\n```ts\nif (mock.type === 'redirect') {\n return readFile(mock.redirect, 'utf-8')\n}\n```\n\n`mock.redirect` is derived from client input at registration time with no\nboundary check:\n\n```ts\nif (event.type === 'redirect') {\n const redirectUrl = new URL(event.redirect)\n event.redirect = join(server.config.root, redirectUrl.pathname)\n}\nregistry.register(event)\n```\n\nThere is no `server.fs.allow` / `server.fs.deny` check and no assertion that the\nresolved path stays within the project root.\n\n## Registration paths and trust boundaries\n- **Public `mockerPlugin` / `interceptorPlugin` (unauthenticated).** In\n `configureServer`, the plugin registers `server.ws.on('vitest:interceptor:register', …)`\n on Vite's HMR WebSocket. That socket performs no token, Origin, or same-origin\n check, so any client that can reach it can register a redirect mock. This is\n the path the \"unauthenticated\" impact applies to.\n- **Vitest browser mode (authenticated).** Mocks register over the browser RPC\n (`registerMock`), which sits behind a per-run token (`isValidApiRequest`, a\n random `api.token`). The interceptor's `configureServer` socket is not used for\n registration here (in v5 it does not run at all, as the plugin is injected per\n environment). The same missing boundary check exists on the authenticated RPC\n path, but reaching it requires the token, so it is not a remote-unauthenticated\n read.\n\n## Path handling\n`new URL(redirect).pathname` combined with `join(root, pathname)` does **not**\nconfine reads to the root:\n\n- Special/hierarchical schemes (`file:`, `http:`) are normalized by WHATWG URL,\n so `..` segments are collapsed and the result stays under the root. Payloads of\n the form `file:///../../etc/passwd` do **not** escape.\n- A non-special (opaque) scheme preserves `..` in `pathname`, so\n `join(root, \"../../…/etc/passwd\")` resolves outside the root and reads an\n arbitrary file.\n\nEven without escaping the root, the missing `server.fs` check allows reading any\nin-root file the dev server would otherwise refuse to serve (for example an\nin-root `.env` or source that is denied by `server.fs.deny`).\n\n## Scope / preconditions\n- This is a **development-server** issue. The dev server binds to `localhost` by\n default and is not reachable from the network unless the developer exposes it\n (`server.host` / `0.0.0.0`, a LAN bind, or a proxy).\n- A raw (non-browser) client against a reachable server bypasses browser origin\n and CORS protections entirely and can both register the mock and read the\n response.\n- A browser-based drive-by against a localhost server is substantially mitigated\n by Vite defaults: the default CORS origin allowlist is limited to `localhost`\n origins, and `server.allowedHosts` blocks DNS-rebinding, so a cross-origin page\n cannot read the file contents back.\n\n## Impact\nDisclosure of local files readable by the dev-server process (source, in-root\n`.env`/secrets, and, via the opaque-scheme payload, files outside the project\nroot). No integrity or availability impact.\n\n## Affected versions\nPresent since `@vitest/mocker` was introduced.\n\n- **Affected: `@vitest/mocker` >= 2.1.0** (shipped in `vitest` and\n `@vitest/browser` >= 2.1.0), through 4.1.x and the 5.0.0 pre-releases.\n- **Fixed:** Vitest 4.1.11 and 5.0.0. Older majors (2.1.x, 3.x) are not\n maintained and are not planned to receive the fix.\n\n## Fix\nValidate the resolved redirect target against Vite's file-serving allowlist\n(`isFileLoadingAllowed`) before registering it, at every registration site, and\nstop registering the interceptor WebSocket events in Vitest's browser mode\n(mocks there flow through the authenticated RPC).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@vitest/mocker"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.1.0"
}, {
"fixed" : "4.1.11"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "vitest"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.1.0"
}, {
"fixed" : "4.1.11"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "vitest"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0-beta.1"
}, {
"fixed" : "5.0.0-rc.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@vitest/mocker"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.0-beta.1"
}, {
"fixed" : "5.0.0-rc.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/security/advisories/GHSA-82fw-gwwq-j7x9"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-84373"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/pull/10972"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/pull/10974"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/commit/51edf2b072902aec6d30c90ebaafd8f121c6f9d8"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/commit/8ff9b9a9efca7c6cfd5243569440de8d7a33aec4"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/commit/fe5a11d3ceac5ec10d6d7d21a46d4caca132c48f"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/vitest-dev/vitest"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/releases/tag/v4.1.11"
}, {
"type" : "WEB",
"url" : "https://github.com/vitest-dev/vitest/releases/tag/v5.0.0-rc.2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-09-08T20:46:45Z",
"nvd_published_at" : "2026-09-01T22:17:19Z"
}
}