Oct 2, 2026·5 min read·27 visits
The vm2 sandbox allows unauthenticated execution of arbitrary native code via the crypto.setEngine API when the crypto builtin is permitted, resulting in a full host escape.
A critical sandbox escape vulnerability in the vm2 library allows sandboxed JavaScript code to bypass containment and execute arbitrary native code on the host process. This occurs when the host's builtin crypto module is exposed to the NodeVM environment. Although vm2 implements a read-only proxy layer to restrict direct modifications to host properties, it does not prevent invocation of host-level functions. By calling the crypto.setEngine API with a path to a malicious native library on disk, an attacker can trigger OpenSSL's dynamic module loader. The host's operating system loader immediately runs the dynamic library's initializers/constructors before verifying engine compatibility, leading to remote code execution in the context of the host process.
CVE-2026-92939 is a critical sandbox escape vulnerability in the vm2 npm library affecting versions 3.11.3 through 3.11.6. The flaw manifests when the host Node.js crypto builtin module is permitted within a NodeVM sandbox configuration.
While vm2 wraps exposed host modules in a read-only proxy via its internal vm.readonly() function, this protection is insufficient for callable functions. The read-only wrapper prevents property modification but does not restrict or sanitize the invocation of host-process functions.
By calling crypto.setEngine(), sandboxed code can force the host Node.js process to load a dynamic library from disk. If an attacker can write a file to a location accessible by the host, this mechanism allows arbitrary native code execution and a complete sandbox escape.
The root cause lies in the architectural limitation of the vm.readonly() proxy wrapper and Node.js's delegation of cryptographic engines to OpenSSL. The proxy prevents writing properties back to the host object but still permits invoking properties that are callable functions.
When crypto.setEngine(path) is executed, the string argument is forwarded directly to OpenSSL's internal ENGINE loading mechanism. OpenSSL then requests the host operating system to dynamically load the shared library using platform-specific APIs such as dlopen on POSIX systems or LoadLibrary on Windows.
During this loading phase, the operating system's dynamic linker executes the library's static initializers or constructors immediately. This execution occurs before OpenSSL validates the library's contents or checks for valid engine exports.
Consequently, even if OpenSSL subsequently rejects the library and throws an ERR_CRYPTO_ENGINE_UNKNOWN exception, the malicious payload has already executed with the privileges of the parent Node.js process.
Prior to the fix, vm2 exposed builtin modules directly after wrapping them with vm.readonly() without inspecting their internal methods. This allowed sandboxed code to access the unmitigated crypto.setEngine API directly from the host context.
// Vulnerable pattern in lib/builtin.js
builtins.set(key, vm => vm.readonly(hostRequire(key)));The official patch in commit aa146a77f859325e079f3bfbfe6d8309af483daa implements a sanitization layer called BUILTIN_MEMBER_SANITIZERS. This subsystem strips or overrides dangerous callable methods before the module is exposed to the sandbox.
// Patched mitigation in lib/builtin.js
function sanitizeCryptoModule(mod) {
const copy = Object.assign({}, mod);
copy.setEngine = function setEngine() {
throw new Error('crypto.setEngine is disabled in vm2 sandboxes...');
};
return copy;
}This approach neutralizes the risk by ensuring that calling crypto.setEngine from within the sandbox immediately throws an error within the JS runtime, preventing any lower-level calls to the operating system's loader.
Exploitation of this vulnerability requires two conditions: the sandbox must allow the crypto builtin module, and the attacker must have a method to place a compiled native library on the host filesystem.
The attack path begins with compiling a shared library containing a constructor function. For systems using GCC or Clang, this constructor is defined using __attribute__((constructor)), which triggers code execution during the initialization phase of a library load.
Once the library path is supplied to crypto.setEngine(), the OS dynamic loader maps the library into the host process memory and runs the constructor. The host process eventually catches an unknown engine exception, but by that time, the native payload has already executed.
The impact of CVE-2026-92939 is rated critical with a CVSS v3.1 score of 9.9. Because the execution transitions from the Node.js V8 sandbox into native binary execution, all sandbox restrictions are bypassed completely.
An attacker achieves arbitrary remote code execution (RCE) with the security context and system privileges of the parent Node.js process. This allows unauthorized reading of sensitive environment variables, filesystem manipulation, and establishing outbound network connections.
In environments where untrusted code execution is a core feature, such as serverless function hosting or plugin-based architectures, this flaw completely undermines the multi-tenant isolation boundary.
To address this vulnerability, administrators and developers must upgrade vm2 to version 3.11.7 or later. The patch effectively disables the vulnerable function by replacing it with a stub that throws an exception.
However, because vm2 is now deprecated and has historically had numerous structural sandbox escapes, users should transition to stronger isolation mechanisms. Secure alternatives include running untrusted code in short-lived containers, microVMs, or WebAssembly runtimes.
If upgrading is not immediately possible, configurations must be audited to ensure that the crypto module is not included in the allowed list of builtins for any NodeVM instances.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
vm2 patriksimek | >= 3.11.3, <= 3.11.6 | 3.11.7 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-114 (Process Control) |
| Attack Vector | Network |
| CVSS v3.1 | 9.9 (Critical) |
| EPSS Score | 0.00616 |
| Exploit Status | PoC Available |
| KEV Status | Not Listed |
CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.