Kritisch

Vitest Browser: Exposed Browser Mode API Can Proxy CDP and Overwrite Config Files, Leading to RCE

  • Veröffentlicht: 15.06.2026
  • Aktualisiert: 11.10.2026 10:22

Summary

Vitest Browser Mode exposes a cdp() API that forwards raw Chrome DevTools Protocol (CDP) methods over the Vitest browser WebSocket RPC. CDP is not gated by browser.api.allowWrite, browser.api.allowExec, api.allowWrite, or api.allowExec.

As a result, disabling Browser Mode write and exec operations does not prevent a browser API client from using CDP to perform equivalent actions. In a verified reproduction with allowWrite: false and allowExec: false, CDP Page.setDownloadBehavior set the browser download directory to the project root, and CDP Runtime.evaluate downloaded a controlled vite.config.ts. Vitest reloaded the changed config and executed attacker-controlled Node.js code.

When the Browser Mode API is also exposed to the network, this becomes remotely exploitable because the generated browser runner page exposes the API token, active session id, project name, and project root path needed to connect to the browser WebSocket API and select the target download directory.

Impact

This affects Browser Mode projects using a CDP-capable provider, such as Playwright Chromium, when the browser API server is exposed to the network, for example with --browser.api.host=0.0.0.0.

In this mode Vitest warns that write and exec operations are disabled by default, but the generated browser runner page exposes enough metadata for a remote client to authenticate to the browser WebSocket API while an active session exists. This includes the browser API token, active session id, project name, and serialized test config including the project root path. The attacker can then call Vitest's CDP RPC and use Chrome's download controls to overwrite vite.config.ts in the project root. When Vitest reloads the changed config, attacker-controlled Node.js code executes on the host running Vitest.

The same exposed CDP bridge also allows direct browser-session JavaScript execution through Runtime.evaluate. A separate local probe showed that CDP can navigate the browser to a file:// URL and read rendered file contents, but the primary verified impact is config-file overwrite leading to RCE.

Reproduction

For a concrete reproduction, start Browser Mode in watch mode using the official Lit example:

bash
pnpm dlx tiged vitest-dev/vitest/examples/lit vitest-poc
cd vitest-poc
pnpm install

Configure the Browser Mode API to listen on all interfaces while explicitly disabling write and exec operations:

ts
import { playwright } from '@vitest/browser-playwright'
import { defineConfig } from 'vite'

export default defineConfig({
  test: {
    browser: {
      enabled: true,
      provider: playwright(),
      instances: [
        { browser: 'chromium' },
      ],
      api: {
        host: '0.0.0.0',
        allowWrite: false,
        allowExec: false,
      },
    },
  },
})

Then start the test server:

bash
pnpm test

Vitest serves the browser runner HTML and WebSocket API at http://localhost:63315.

While the browser session is active:

  1. Fetch the generated browser runner page:

    http://localhost:63315/__vitest_test__/
  2. Extract the embedded browser API token, active session id, project name, and project root:

    • window.VITEST_API_TOKEN
    • __vitest_browser_runner__.sessionId
    • __vitest_browser_runner__.config.name
    • __vitest_browser_runner__.config.root
  3. Connect to the browser API WebSocket as a tester client:

    /__vitest_browser_api__?type=tester&rpcId=<fresh-id>&sessionId=<session-id>&projectName=<project-name>&method=none&token=<token>
  4. Call the sendCdpEvent RPC method with:

    Page.setDownloadBehavior({
      behavior: "allow",
      downloadPath: __vitest_browser_runner__.config.root
    })
  5. Call sendCdpEvent again with Runtime.evaluate. The evaluated JavaScript creates a Blob containing a malicious Vite config and clicks an anchor element <a download="vite.config.ts">.

  6. Observed result:

    • vite.config.ts is overwritten with attacker-controlled content.
    • Vitest reloads the changed config.
    • The injected Node.js payload runs on the host.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
npm-Paket vite-plus < 0.1.24 0.1.24
npm-Paket @vitest/browser >= 5.0.0-beta.0, < 5.0.0-beta.4, >= 4.0.0, < 4.1.8, >= 3.0.0, < 3.2.5 5.0.0-beta.4, 4.1.8, 3.2.5

Verweise

CVSS-Wert 9.8/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Schwäche (CWE)
CWE-749, CWE-862
Plattform
npm
Paket
vite-plus, @vitest/browser
Veröffentlicht
15.06.2026
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-g8mr-85jm-7xhm - CC BY 4.0

Schwachstellenhistorie: @vitest/browser

Alle veröffentlichten Schwachstellen dieses Pakets (npm-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Einträge insgesamt
4
Erste → letzte
02.2025 07.2026
Ohne Fix
0
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 3
  • Mittel 1

Veröffentlichungen pro Jahr

  1. 2025: 1
  2. 2026: 3
  1. Kritisch · 9.4 CVE-2026-73653 >= 4.0.0, < 4.1.10, < 3.2.7, >= 5.0.0-beta.1, < 5.0.0-beta.6 4.1.10, 3.2.7, 5.0.0-beta.6
  2. Vitest Browser: Exposed Browser Mode API Can Proxy CDP and Overwrite Config Files, Leading to RCE dieser Eintrag
    Kritisch · 9.8 CVE-2026-53633 >= 5.0.0-beta.0, < 5.0.0-beta.4, >= 4.0.0, < 4.1.8, >= 3.0.0, < 3.2.5 5.0.0-beta.4, 4.1.8, 3.2.5
  3. Kritisch · 9.6 CVE-2026-47428 >= 4.0.17, < 4.1.6, >= 5.0.0-beta.0, < 5.0.0-beta.3 4.1.6, 5.0.0-beta.3
  4. Mittel · 5.9 CVE-2025-24963 >= 2.0.4, < 2.1.9, >= 3.0.0, < 3.0.4 2.1.9, 3.0.4

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.