Read the docs

Code injection in Vitest manual mock registration

Priority MEDIUM 55CWE-116Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
Required
Attack complexity
High
Impact type
Security bypass, Code execution
Confidentiality · integrity · availability
Low · Low · None
Fix status
Partial Red Hat: 7 without a fix

Attack profile from CVSS 3.1 · CNA. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-306 and CWE-94.

Summary

Vitest from 2.1.0-beta.7 before 4.1.12 and from 5.0.0 before 5.0.3 is affected, as is @vitest/mocker in the same ranges. The createManualModuleSource function inserts an attacker-supplied URL into generated module source without escaping it (CWE-116). An unauthenticated non-browser WebSocket client that can reach a development server using interceptorPlugin can register such a manual mock, and when a developer browser loads the affected module, attacker JavaScript runs on the development server origin.

Written with Claude Haiku 5.5 from the sources below · 2026-10-28

Description from the CNA

Vitest is a Vite-native testing framework for JavaScript and TypeScript projects. From 2.1.0-beta.7 until 4.1.12 and 5.0.3, an unauthenticated non-browser WebSocket client that can reach a development server using interceptorPlugin can register a manual mock whose attacker-controlled url createManualModuleSource inserts unescaped into generated module source. When the developer browser loads the affected module, attacker-controlled JavaScript executes on the development-server origin. This issue is fixed in versions 4.1.12 and 5.0.3.

Why it matters now

Exploitation Proof of concept CISA SSVC · not in CISA KEV
EPSS 0.00336 27th percentileScored 2026-11-07
Fix Partial vitest (vitest-dev): 4.1.12, 5.0.3mocker (@vitest): 4.1.12, 5.0.3+1 more productRed Hat: 7 without a fix

SSVC decision points

CISA ADP · SSVC 2.0.3

Exploitation
Poc
Automatable
No
Technical impact
Partial

The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.

Affected products

VendorProductAffected versionsFixed inStatusSource
vitest-devvitest2.1.0-beta.7 to before 4.1.12; 5.0.0 to before 5.0.34.1.12, 5.0.3Patch availableCNA
@vitestmocker2.1.0-beta.7 to before 4.1.12; 5.0.0 to before 5.0.34.1.12, 5.0.3Patch availableCNA
—@vitest/mocker (npm)2.1.0-beta.7 to before 4.1.124.1.12Patch availableGHSA-qxg6-89mg-rqv8
—@vitest/mocker (npm)5.0.0-beta.1 to before 5.0.35.0.3Patch availableGHSA-qxg6-89mg-rqv8
  • vitest Vendorvitest-dev Affected 2.1.0-beta.7 to before 4.1.12; 5.0.0 to before 5.0.3 Fixed in 4.1.12, 5.0.3 Patch available CNA
  • mocker Vendor@vitest Affected 2.1.0-beta.7 to before 4.1.12; 5.0.0 to before 5.0.3 Fixed in 4.1.12, 5.0.3 Patch available CNA
  • @vitest/mocker (npm) Vendor— Affected 2.1.0-beta.7 to before 4.1.12 Fixed in 4.1.12 Patch available GHSA-qxg6-89mg-rqv8
  • @vitest/mocker (npm) Vendor— Affected 5.0.0-beta.1 to before 5.0.3 Fixed in 5.0.3 Patch available GHSA-qxg6-89mg-rqv8

CPE names Threatist (inferred) · 1

Inferred from how NVD named this product before; not given by a source.

CPEVersionsRoleVendor
cpe:2.3:a:vitest.dev:vitest:*:*:*:*:*:*:*:*——vitest-dev
  • cpe:2.3:a:vitest.dev:vitest:*:*:*:*:*:*:*:* Versions — — ·vitest-dev

Remediation

Update @vitest/mocker to 4.1.12 or 5.0.3, which fix the flaw. The sources list no fixed version for vitest. Red Hat lists Red Hat AMQ Broker 7, Red Hat Ansible Automation Platform 2, Red Hat Build of Keycloak, Red Hat Build of Podman Desktop, Red Hat JBoss Enterprise Application Platform 8, Red Hat JBoss Enterprise Application Platform Expansion Pack and Red Hat Trusted Artifact Signer as affected without a fix, and it has no plan available for them.

Written with Claude Haiku 5.5 from the sources below · 2026-10-28

  • Fix · CNA vitest (vitest-dev) Fixed in 4.1.12, 5.0.3
  • Fix · CNA mocker (@vitest) Fixed in 4.1.12, 5.0.3
  • Fix · GHSA-qxg6-89mg-rqv8 @vitest/mocker (npm) Fixed in 4.1.12 Advisory →
  • Fix · GHSA-qxg6-89mg-rqv8 @vitest/mocker (npm) Fixed in 5.0.3 Advisory →

Vendor assessments

Red Hat

Red Hat rating: Moderate. Red Hat's page for this CVE →

ProductStatusPlan or fix
Red Hat AMQ Broker 7AffectedNo fix yet: Fix deferred
Red Hat Ansible Automation Platform 2AffectedNo fix yet: Fix deferred
Red Hat Build of KeycloakAffectedNo fix yet: Fix deferred
Red Hat Build of Podman DesktopAffectedNo fix yet: Fix deferred
Red Hat JBoss Enterprise Application Platform 8AffectedNo fix yet: Fix deferred
Red Hat JBoss Enterprise Application Platform Expansion PackAffectedNo fix yet: Fix deferred
Red Hat Trusted Artifact SignerAffectedNo fix yet: Fix deferred
Not affected: 1 product
  • Red Hat Hardened Images

Timeline

  1. 2026-10-20 Threatist record created from CVE-2026-112949
  2. 2026-10-21 Affected versions changed · Red Hat
  3. 2026-10-21 CVSS score added · Red Hat
  4. 2026-10-21 Alias added: GHSA-qxg6-89mg-rqv8
  5. 2026-10-21 Fix available: npm/@vitest/[email protected], npm/@vitest/[email protected] · GHSA-qxg6-89mg-rqv8
  6. 2026-10-21 CVSS score added · GHSA-qxg6-89mg-rqv8
  7. 2026-10-21 Weakness changed · GHSA-qxg6-89mg-rqv8
  8. 2026-10-21 7 new references · GHSA-qxg6-89mg-rqv8
  9. 2026-10-23 CISA SSVC decision points changed
  10. 2026-10-23 Priority changed: LOW → MEDIUM

References

  • TI-2026-38677 Vitest: Exposed Browser Mode API Can Proxy CDP and Overwrite Config Files, Leading to RCE CVSS 3.1CRITICAL 9.8
  • TI-2026-34992 Vitest: Arbitrary file can be read and executed when Vitest UI server is listening CVSS 3.1CRITICAL 9.8
  • TI-2026-34991 Vitest browser mode serves unsanitized otelCarrier query parameter as inline script CVSS 3.1CRITICAL 9.6
  • TI-2025-18644 Remote Code Execution when accessing a malicious website while Vitest API server is listening CVSS 3.1CRITICAL 9.7
  • TI-2025-18643 Browser mode serves arbitrary files in vitest CVSS 3.1HIGH 7.5
  • TI-2026-76917 Backslash traversal in Vitest mocker exposes files on Windows CVSS 3.1MEDIUM 5.9
See all 9 →

Sources