GHSA-8686-vhfx-7r3j: Critical severity npm/vm2 vulnerability

Published Oct 1, 2026
·
Updated

Summary

NodeVM normalizes node:-prefixed builtin specifiers during require() resolution, but it does not normalize user-provided negative builtin entries in wildcard policy.

As a result, this configuration:

js new NodeVM({ require: { builtin: ['', '-node:childprocess'] } });

does not deny the canonical childprocess builtin. Sandboxed code can require both childprocess and node:childprocess, and receives the host module with process-spawning APIs such as execSync and spawn.

The safe proof below only checks module and function reachability. It does not execute any OS command.

Affected Mode

NodeVM.

Affected Configuration

js new NodeVM({ require: { builtin: ['', '-node:childprocess'] } });

This affects users who deny builtins using their node:-prefixed spelling, expecting -node:childprocess to deny require('node:childprocess') and require('childprocess').

Affected Files / Functions

- lib/builtin.js - makeBuiltinsFromLegacyOptions - wildcard builtin expansion - exact negative entry check: builtins.indexOf(\-${name}\) - addDefaultBuiltin - lib/resolver.js - Resolver.resolve - lib/setup-node-sandbox.js - requireImpl - node: prefix stripping before builtin load

Root Cause

lib/setup-node-sandbox.js strips the node: prefix from resolved builtin filenames before loading the builtin:

js if (localStringPrototypeStartsWith(filename, 'node:')) { id = localStringPrototypeSlice(filename, 5); let nmod = cacheBuiltins[id]; if (!nmod) { nmod = loadBuiltinModule(id); if (!nmod) throw new VMError(Cannot find module '${filename}', 'ENOTFOUND'); cacheBuiltins[id] = nmod; } return nmod; }

But lib/builtin.js checks wildcard negative entries by exact string match against the names in BUILTINMODULES:

js if (builtins.indexOf(-${name}) === -1) { addDefaultBuiltin(res, name, hostRequire); }

BUILTINMODULES contains the canonical name childprocess, not node:childprocess. Therefore -node:childprocess does not exclude childprocess, and addDefaultBuiltin() registers the host builtin.

Security Boundary Crossed

Sandboxed code reaches a host builtin that the embedder attempted to deny.

Boundary crossed:

- sandbox -> host childprocess builtin - sandbox -> host process-spawning function references

Impact

Confirmed impact:

- require('childprocess') succeeds inside the sandbox. - require('node:childprocess') succeeds inside the sandbox. - The returned module exposes execSync and spawn as functions.

Worst confirmed impact is access to host process-spawning APIs. The proof does not execute any command.

The proof does not execute a command, but it confirms access to the host childprocess module and its process-spawning APIs. For untrusted sandbox code, this is equivalent to command execution capability.

Safe Local Reproduction

Tested on Node.js v24.14.0.

This proof only checks whether the module and dangerous functions are reachable. It does not spawn a process and does not run OS commands.

js 'use strict';

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

function probe(builtin) { const vm = new NodeVM({ require: { builtin } });

return vm.run( const out = {};

for (const spec of ['childprocess', 'node:childprocess']) { try { const cp = require(spec); out[spec] = { loaded: true, execSyncType: typeof cp.execSync, spawnType: typeof cp.spawn, moduleToStringTag: Object.prototype.toString.call(cp) }; } catch (e) { out[spec] = { loaded: false, name: e && e.name, code: e && e.code, message: e && e.message }; } }

module.exports = out; ); }

console.log(JSON.stringify({ nodeVersion: process.version, denyNodePrefixed: probe(['', '-node:childprocess']), denyCanonical: probe(['', '-childprocess']) }, null, 2));

Observed result:

json { "nodeVersion": "v24.14.0", "denyNodePrefixed": { "childprocess": { "loaded": true, "execSyncType": "function", "spawnType": "function", "moduleToStringTag": "[object Object]" }, "node:childprocess": { "loaded": true, "execSyncType": "function", "spawnType": "function", "moduleToStringTag": "[object Object]" } }, "denyCanonical": { "childprocess": { "loaded": false, "name": "VMError", "code": "ENOTFOUND", "message": "Cannot find module 'childprocess'" }, "node:childprocess": { "loaded": false, "name": "VMError", "code": "ENOTFOUND", "message": "Cannot find module 'node:childprocess'" } } }

Expected Secure Behavior

-node:childprocess and -childprocess should be equivalent.

If either spelling is denied, both of these should fail:

js require('childprocess') require('node:childprocess')

Suggested Fix

1. Canonicalize builtin names before allow/deny comparison: - Strip node: from user-provided builtin entries. - Preserve whether an entry is negative (-...) before canonicalizing. - Store and compare one canonical builtin key.

2. Apply the same normalization to: - wildcard negative entries - explicit allowlist entries - object-form builtin entries - mock/override keys if they are intended to support node: spelling

3. Add regression tests: - builtin: ['', '-node:childprocess'] blocks childprocess. - builtin: ['', '-node:childprocess'] blocks node:childprocess. - builtin: ['', '-node:fs'] blocks fs and node:fs. - builtin: ['', '-node:fs/promises'] and -fs/promises behave consistently. - Canonical dangerous builtins remain denied even if explicitly requested with node: spelling.

Affected Software

1 affected componentFixes available
npm/vm2<=3.11.6
3.11.7

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.7
  2. Compensating control

    Canonicalize builtin names before allow/deny comparison by stripping the `node:` prefix from user-provided entries, preserving whether an entry is negative before canonicalization, and storing/comparing one canonical builtin key so `-node:child_process` and `-child_process` are equivalent. Apply the same normalization to explicit allowlist entries, mock/override keys, object-form builtin entries, wildcard expansion, and wildcard negative entries.

Event History

Oct 1, 2026
Advisory Published
via GitHub·03:36 PM
Data Sourced
via GitHub·03:36 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed to this issue?

Only NodeVM mode is identified as affected. The vulnerable configuration uses a wildcard builtin allowlist together with a node:-prefixed negative entry, such as builtin: ['*', '-node:child_process'].

2

What must an attacker be able to do to exploit this?

An attacker needs the ability to run code inside the affected NodeVM sandbox. That code can require child_process using either require('child_process') or require('node:child_process') and obtain host process-spawning APIs.

3

Are configurations that explicitly deny the canonical builtin name affected?

The described bypass is specifically caused by denying the builtin with its node:-prefixed spelling while wildcard expansion uses the canonical name. A negative entry matching the canonical name is not identified as affected by the provided data.

4

What configuration change can reduce exposure if patching is not immediately possible?

Do not rely on -node:child_process to block the module when using wildcard builtin configuration. Avoid the wildcard builtin allowlist or use the canonical child_process spelling for the negative entry.

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