CVE-2026-47428: Vitest XSS in Browser Mode via otelCarrier parameter

CVE-2026-47428 · Severity: critical · CVSS 9.6 · Published 2026-07-14

Vitest's browser testing mode is a development tool that runs tests in a real browser environment via a local web server. The server fails to sanitize the `otelCarrier` query parameter before embedding it in an inline JavaScript block, allowing an attacker to inject arbitrary code that executes in the browser with access to authentication tokens and configuration files. An attacker who can trick a developer into clicking a malicious link while Vitest is running can compromise the local test environment and potentially execute code on the developer's machine.

Technologies: @vitest/browser (npm). Vendors: npm, Vitest.

Quick answers

Is CVE-2026-47428 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-47428 being exploited in the wild.
How severe is CVE-2026-47428?
Critical severity, with a CVSS score of 9.6, published 14 July 2026.
Which products and versions are affected?
@vitest/browser (npm) SEMVER:introduced=4.0.17,fixed=4.1.6.
Is there a fix for CVE-2026-47428?
Yes. @vitest/browser (npm): upgrade to 4.1.6 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-47428 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-47428?
Check whether you run @vitest/browser (npm) or Vitest Browser Mode at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • @vitest/browser (npm): upgrade to 4.1.6 or later
    npm install @vitest/browser@4.1.6

Technical details

The vulnerability is a reflected cross-site scripting (XSS) flaw in Vitest's browser mode orchestrator. The `otelCarrier` query parameter is extracted from the request URL (in serverOrchestrator.ts line 48) and directly interpolated into an inline module script block (esm-client-injector.js line 41) without sanitization or escaping. Because the parameter is embedded as JavaScript source code rather than a data value, an attacker can craft a URL with arbitrary JavaScript payload in the `otelCarrier` parameter. When a victim visits the crafted URL in their browser while the Vitest server is running, the injected code executes in the server's origin. The proof-of-concept demonstrates both simple XSS (triggering an alert) and chained RCE: the injected script can steal `VITEST_API_TOKEN` (embedded on the same page), use it to authenticate to the WebSocket API, call `triggerCommand("writeFile")` to modify `vite.config.ts`, and trigger a config reload that executes arbitrary Node.js code. User interaction is required (clicking a malicious link), but attack surface is broad in local development scenarios. Patches are available in @vitest/browser versions 4.1.6 and 5.0.0-beta.3.

Affected products

  • Vitest @vitest/browser >=4.0.17, <4.1.6; >=5.0.0-beta.0, <5.0.0-beta.3

Identifiers

  • CVE-2026-47428
  • GHSA-2h32-95rg-cppp

Timeline

  • 2026-05-19: disclosed: Vulnerability disclosed on GitHub
  • 2026-06-01: advisory: GHSA-2h32-95rg-cppp published on GitHub Advisory Database
  • 2026-05-19: patched: Patches released: @vitest/browser 4.1.6 and 5.0.0-beta.3

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.