vm2 3.11.0 fixes CVE-2026-44004 by adding an option called bufferAllocLimit. The fix's own regression test contains a passing assertion named default is permissive (Infinity): large allocations are allowed without an explicit cap. The CVE record at NVD says "This vulnerability is fixed in 3.11.0." The fix is a feature, not a behavior change. Embedders who upgrade to 3.11.0 and do nothing else stay exactly as vulnerable as they were on 3.10.6.
CVE-2026-44004: vm2's Fix for Buffer.alloc Is Off By Default
vendor
patterns
cve
proof of concept
"Fixed in 3.11.0" is an option named bufferAllocLimit
The patched code lives in two files. The cap itself is in lib/setup-sandbox.js, captured into a closure-scoped constant at sandbox initialization so a sandbox-side prototype-pollution attempt cannot mutate it post-init:
const { allowAsync, GeneratorFunction, AsyncFunction, AsyncGeneratorFunction, bufferAllocLimit } = data;
// SECURITY (GHSA-6785-pvv7-mvg7): Buffer.alloc / allocUnsafe / allocUnsafeSlow
// (and the deprecated Buffer(N) / new Buffer(N) forms) execute as a single
// synchronous host C++ allocation. V8's `timeout` cannot interrupt them, so
// an attacker controlling the size argument can amplify a small payload into
// hundreds of megabytes of host RSS, crashing the host process in
// memory-constrained environments (Docker/K8s/Lambda). Cap every allocation
// size before it reaches the host implementation.
const localBufferAllocLimit = bufferAllocLimit;
function checkBufferAllocLimit(size) {
if (typeof size === 'number' && size > localBufferAllocLimit) {
throw new RangeError('Buffer allocation size ' + size + ' exceeds bufferAllocLimit ' + localBufferAllocLimit);
}
}data is built by the VM constructor in lib/vm.js. The default written into the constructor's destructure is Infinity:
const {
compiler = 'javascript',
compilerOptions,
allowAsync: optAllowAsync = true,
bufferAllocLimit = Infinity,
} = options;checkBufferAllocLimit is wired into every Buffer.alloc, Buffer.allocUnsafe, Buffer.allocUnsafeSlow, the deprecated Buffer(N), and new Buffer(N) path on the sandbox-facing BufferHandler. The wrap is complete. The const-capture is deliberate, defended by a comment that explains why mutating prototype state post-init cannot defeat the cap. The fix, in mechanism, is sound.
The fix, by default, does nothing.
The primitive, end to end
The victim is the Node.js shop running vm2 in a containerized worker to execute customer-uploaded plugins. A SaaS automation builder. A workflow engine. A "run this JavaScript snippet" feature on a webhook receiver. The host process is a 512 MB container in K8s, or a 1 GB AWS Lambda, sized for the workload plus headroom. The user-supplied code runs through:
const { NodeVM } = require('vm2');
const vm = new NodeVM({ timeout: 1000 });
vm.run(userCode, 'plugin.js');The customer submits, as their plugin:
module.exports = function () {
Buffer.alloc(1024 * 1024 * 1024); // 1 GB
};The handler calls vm.run(userCode). Control enters the sandbox. The sandbox-side Buffer.alloc is the vm2 BufferHandler, which is a proxy over the host realm's Buffer. On invocation, the handler passes the size argument through to the host's native Buffer.alloc. Buffer.alloc in Node.js is a synchronous V8 C++ binding that calls into node::Buffer::Alloc, which calls into V8's ArrayBuffer allocator, which calls into the platform allocator (malloc or its equivalent). The whole stack is one synchronous host C++ frame from V8's perspective; vm.run's timeout option uses V8's interrupt API, which only fires on JS bytecode boundaries.
There are no JS bytecode boundaries inside node::Buffer::Alloc. The timeout cannot fire until the allocation returns. The allocation does not return until the OS supplies the pages. The OS supplies the pages by paging out the container's working set and then, when the container's memory limit is exceeded, killing the process: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory.
A roughly hundred-byte plugin terminates a roughly billion-byte container.
The fix is to set bufferAllocLimit on the NodeVM constructor. In 3.11.0 and later, with the cap set, the BufferHandler throws RangeError synchronously before the host allocation runs. Without the cap, the handler does what it did on 3.10.6.
The regression test names the default in writing
The repro file at test/ghsa/GHSA-6785-pvv7-mvg7/repro.js is the project's regression test for this CVE. It contains the following case, shipped alongside the fix:
it.cond(
'default is permissive (Infinity): large allocations are allowed without an explicit cap',
LARGE_ALLOC_RUNS,
function () {
this.timeout(30000);
// Sanity: with no option, sandbox can allocate above what would have been the old default cap.
const r = new VM().run('Buffer.allocUnsafe(64 * 1024 * 1024).length');
assert.strictEqual(r, 64 * 1024 * 1024);
},
);A bare new VM() with no options allocates a 64 MB buffer inside the sandbox without error. The test asserts that this allocation succeeds. The maintainer added the assertion as part of the fix that closes the CVE.
The same commit that introduced the option includes a documentation update with this line:
Default is
Infinity(non-breaking). Embedders running untrusted code in memory-constrained environments need to know this exists and that they should opt in.
The commit message, the JSDoc on the option in lib/vm.js, the README section that follows the security disclaimer, and the regression test all say the same thing in slightly different words: the option exists, the default is unbounded, embedders need to opt in. The maintainer documents the choice to the standard the project's other security work is documented to.
The CVE record at NVD does not include the word opt. It does not mention bufferAllocLimit. It says "This vulnerability is fixed in 3.11.0." Both the CVE record's description and the maintainer's commit message are public. Both cannot be operationally accurate.
The companion bug, buried in NodeVM
The GHSA-6785 fix landed two changes. The first introduced the option. The second, in lib/nodevm.js, fixed a separate bug nobody assigned a CVE to:
// SECURITY (GHSA-6785-pvv7-mvg7): forward bufferAllocLimit so embedders
// using NodeVM (the more common form for module-loading sandboxes) can
// opt into the cap. Also forward timeout / allowAsync which were
// previously silently dropped by the super() call.
super({__proto__: null, compiler: compiler, eval: allowEval, wasm, timeout, allowAsync, bufferAllocLimit});Read the second sentence of the comment.
Before this patch, NodeVM's super() call to its parent VM constructor dropped timeout. Embedders who constructed a NodeVM with { timeout: 1000 } got a sandbox with no timeout. The option was named, accepted at the API surface, and silently discarded one frame later. Same for allowAsync: an embedder who wrote new NodeVM({ allowAsync: false }) got a sandbox that ran async code anyway.
NodeVM is the form vm2's documentation describes as "the more common form" for module-loading sandboxes. The README's Hardening recommendations example uses bare VM, but most production embedders reach for NodeVM because they want require. Every one of them setting a timeout on NodeVM before 3.11.0 never had a timeout. Every one of them setting allowAsync: false got true.
This bug has no separate CVE. There is no GHSA for it. It is named in one comment in one commit and in no CVSS scoring authority's database. The CVE record for vm2 3.11.0 says one bug was fixed in this release. The release fixed two, plus eleven others.
The README says what the CVE record will not
The Hardening recommendations section vm2 added in this same release cycle opens:
vm2 prevents sandbox escapes (untrusted code obtaining host realm access). It does not, by itself, prevent every form of resource exhaustion or denial-of-service.
That is the project speaking honestly about what its sandbox does and what it does not. The section then walks through five layered defenses an embedder running untrusted code should add around the sandbox:
- Set
bufferAllocLimitto a finite value. - Install a host-side
unhandledRejectionhandler. - Run with
--max-old-space-sizeor a container memory limit. - Treat
require.builtin: ['*']as a non-sandbox configuration. - Treat
nesting: trueas an escape hatch.
Five recommendations. The CVE record does not include any of them. The CVE record's description field says "fixed in 3.11.0," which is true of exactly one fact about one of the five (bufferAllocLimit now exists as an option, and exposes a knob the embedder may turn).
The reader who installs the patch and closes the ticket has satisfied the CVE record. The reader who installs the patch and closes the ticket has not addressed the bug.
vm2's own changelog says this will happen again
vm2's Important Security Disclaimer, written into the README in the same release window:
Despite our best efforts, researchers and security professionals continuously discover new ways to escape the vm2 sandbox. We actively patch these vulnerabilities as they are reported, but the cat-and-mouse nature of in-process sandboxing means that: New bypasses will likely be discovered in the future.
The disclaimer is real. The git log in the depth-50 history of the repository shows 22 distinct GHSA identifiers landing as commits, ten of them in 3.11.4 alone. The CHANGELOG names them by class: array species self-return, cross-realm symbol extraction, host intrinsic prototype pollution, async-generator yield-return thenable exception capture, WebAssembly JSPI prototype chain, Promise species hijack, NodeVM builtin denylist bypass via process and inspector/promises subpaths.
vm2 is a Design Debt Driver. The component is a JavaScript interpreter that tries to enforce a security boundary inside the same V8 isolate as the host process. The README says so. The CHANGELOG demonstrates it. Each release closes the named instances; the design holds the primitive. A sufficiently dynamic language runtime sharing an isolate with its caller will keep producing new escape paths for as long as the runtime exists.
The "fixed in 3.11.0" framing belongs to a project where bug classes are patchable on a per-instance basis. vm2 itself does not think of its bug classes that way. Its own README explains that it does not. The disjoint between the record and the project is not the maintainer's framing of his own work. It is the CVE record's framing of vm2's work.
The pattern is safe-mode-was-opt-in
This is safe-mode-was-opt-in, extending the pattern from authoring sinks into resource-exhaustion territory. The pattern's existing exhibits cover EspoCRM's defaultTransform, which exposed no_markup and no_entities as opt-in flags on a Markdown parser and called the unsafe factory anyway; and DeepSeek-TUI's task_create, whose unwrap_or(true) lines distributed shell access to any caller that did not request its absence.
vm2's bufferAllocLimit is the same shape on the DoS axis. The library exposes a security-relevant option with an unsafe default. The fix is to set it. The flags exist. The default chooses the unsafe behavior. The release ships the option plus a recommendation to use it; the CVE record ships only the option.
The EspoCRM exhibit's closing observation applies word for word.
The defaults are the bug.
PoC: no public exploit repository exists for CVE-2026-44004; the primitive is vm.run('Buffer.alloc(2**30)') against any default-configured vm2 prior to 3.11.0, and against any default-configured vm2 from 3.11.0 onward whose embedder did not pass the new option. Vendor advisory at GHSA-6785-pvv7-mvg7.
The CVE is closed in the record. The bug is closed in Infinity increments.