Code injection in Vitest manual mock registration
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
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
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| vitest-dev | vitest | 2.1.0-beta.7 to before 4.1.12; 5.0.0 to before 5.0.3 | 4.1.12, 5.0.3 | Patch available | CNA |
| @vitest | mocker | 2.1.0-beta.7 to before 4.1.12; 5.0.0 to before 5.0.3 | 4.1.12, 5.0.3 | Patch available | CNA |
| — | @vitest/mocker (npm) | 2.1.0-beta.7 to before 4.1.12 | 4.1.12 | Patch available | GHSA-qxg6-89mg-rqv8 |
| — | @vitest/mocker (npm) | 5.0.0-beta.1 to before 5.0.3 | 5.0.3 | Patch available | GHSA-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.
| CPE | Versions | Role | Vendor |
|---|---|---|---|
| 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 →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat AMQ Broker 7 | Affected | No fix yet: Fix deferred |
| Red Hat Ansible Automation Platform 2 | Affected | No fix yet: Fix deferred |
| Red Hat Build of Keycloak | Affected | No fix yet: Fix deferred |
| Red Hat Build of Podman Desktop | Affected | No fix yet: Fix deferred |
| Red Hat JBoss Enterprise Application Platform 8 | Affected | No fix yet: Fix deferred |
| Red Hat JBoss Enterprise Application Platform Expansion Pack | Affected | No fix yet: Fix deferred |
| Red Hat Trusted Artifact Signer | Affected | No fix yet: Fix deferred |
Not affected: 1 product
- Red Hat Hardened Images
Timeline
- 2026-10-20 Threatist record created from CVE-2026-112949
- 2026-10-21 Affected versions changed · Red Hat
- 2026-10-21 CVSS score added · Red Hat
- 2026-10-21 Alias added: GHSA-qxg6-89mg-rqv8
- 2026-10-21 Fix available: npm/@vitest/[email protected], npm/@vitest/[email protected] · GHSA-qxg6-89mg-rqv8
- 2026-10-21 CVSS score added · GHSA-qxg6-89mg-rqv8
- 2026-10-21 Weakness changed · GHSA-qxg6-89mg-rqv8
- 2026-10-21 7 new references · GHSA-qxg6-89mg-rqv8
- 2026-10-23 CISA SSVC decision points changed
- 2026-10-23 Priority changed: LOW → MEDIUM
References
Other 6
- https://github.com/vitest-dev/vitest/security/advisories/GHSA-qxg6-89mg-rqv8
- https://github.com/vitest-dev/vitest/commit/15cc006aa9f8683dc5f7e895d011fa7dc751ce35
- https://github.com/vitest-dev/vitest/commit/b825313243dc55757e8d7c0f9e7a792135e13473
- https://github.com/vitest-dev/vitest/releases/tag/v4.1.12
- https://github.com/vitest-dev/vitest/releases/tag/v5.0.3
- https://github.com/vitest-dev/vitest
More vitest-dev vulnerabilities
- 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
Sources
- CVE-2026-112949 · CVE Program
- CVE-2026-112949 · NVD
- FIRST EPSS
- GHSA-qxg6-89mg-rqv8 · GitHub Advisory Database · CC BY 4.0
- CVE-2026-112949 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences