{"id":"GHSA-46pr-c5wc-xffx","summary":"vm2 crypto builtin loads attacker native code through setEngine","details":"Summary\n\nvm2 3.11.6 exposes the host `crypto` module to a `NodeVM` when that single builtin is allowed. The module is presented through a read-only bridge, but its functions still execute with host-process authority. `crypto.setEngine()` accepts a filesystem path and asks OpenSSL to dynamically load the referenced native library.\n\nAn attacker whose untrusted plugin package contains a native library can therefore load that library into the host process by calling `crypto.setEngine()` from sandboxed JavaScript. The native library's constructor executes before OpenSSL finishes validating whether the file is a usable engine. Consequently, even the expected `ERR_CRYPTO_ENGINE_UNKNOWN` exception occurs only after arbitrary native code has already run.\n\nThe exploit requires only the `crypto` builtin. It does not require `fs`, `process`, `module`, `child_process`, `worker_threads`, `vm`, `inspector`, unrestricted builtins, or vm2 nesting.\n\n### Details\n\nThe vulnerable boundary is the generic builtin loader. Builtins that are not specially wrapped or classified as dangerous are imported in the host realm and exposed through a recursive read-only proxy:\n\n```js\nbuiltins.set(key, special ? special : vm =\u003e vm.readonly(hostRequire(key)));\n```\n\nRead-only prevents sandbox code from assigning properties on the module object. It does not reduce the authority of callable exports. Calls are forwarded to the original host function with bridge values converted back to host values.\n\nThe `crypto` module includes this callable export:\n\n```js\ncrypto.setEngine(enginePath)\n```\n\nWhen `enginePath` names a dynamic library, OpenSSL loads that file into the current process. Operating-system dynamic loaders execute library constructors as part of loading. Engine-symbol validation happens afterward. A file does not have to become a functional cryptographic engine for its constructor to execute.\n\nThe resulting exploit flow is:\n\n```text\nattacker supplies an untrusted plugin package containing a native library\n  -\u003e host executes the plugin in NodeVM with only crypto allowed\n  -\u003e plugin calls crypto.setEngine(pathToBundledLibrary)\n  -\u003e vm2 forwards the call to the host crypto module\n  -\u003e OpenSSL asks the operating-system loader to load the library\n  -\u003e the library constructor executes native code in the host process\n  -\u003e OpenSSL may then reject the file, but host compromise has already occurred\n```\n\nThis is different from merely granting JavaScript filesystem access. A plugin system commonly has to place an untrusted package on disk before running its JavaScript. The native file can therefore already exist inside that package even when the sandbox denies `fs` and all process-execution builtins. Allowing `crypto` for hashing or signature verification unexpectedly turns that inert package file into a native-code execution primitive.\n\n### PoC\n\nThe attached PoC is local and harmless. Its native library constructor creates a marker file; it does not spawn a process, open a network connection, or modify any other file.\n\n1. Install Node.js with OpenSSL engine support, a C compiler, and npm.\n2. In the attached `poc` directory, install the exact affected package:\n\n   ```bash\n   npm install --ignore-scripts\n   ```\n\n3. Build the marker library.\n\n   On macOS:\n\n   ```bash\n   cc -dynamiclib -O2 -o probe-engine.dylib engine_probe.c\n   node poc.js ./probe-engine.dylib\n   ```\n\n   On Linux:\n\n   ```bash\n   cc -shared -fPIC -O2 -o probe-engine.so engine_probe.c\n   node poc.js ./probe-engine.so\n   ```\n\n4. A vulnerable result contains all of the following:\n\n   - the sandbox configuration lists only `crypto` as an allowed builtin;\n   - `crypto.setEngine()` reports `ERR_CRYPTO_ENGINE_UNKNOWN` or returns;\n   - `vm2-setengine-native-marker.txt` exists afterward;\n   - the marker contains `VM2_SETENGINE_NATIVE_CODE_EXECUTED`.\n\nThe exception is not a negative result. The marker proves that the native constructor ran before engine validation failed.\n\n### Impact\n\nThis is a sandbox escape to arbitrary native code execution. The code runs with the operating-system identity and privileges of the Node.js host process, outside all vm2 language and module restrictions.\n\nAn attacker can replace the marker-only constructor with native code that:\n\n- reads application secrets, environment variables, credentials, and files available to the host user;\n- modifies application data or executable files and establishes persistence;\n- accesses internal services using the host's network identity;\n- steals other tenants' data from the same process;\n- terminates or corrupts the host process; and\n- executes arbitrary operating-system actions permitted to the host account.\n\nThe realistic affected workflow is a plugin, automation, notebook, or multi-tenant code runner that stores attacker-supplied package contents on disk and runs the package's JavaScript in `NodeVM` while allowing `crypto`. The attacker does not need the sandbox to expose a file-write or command-execution module.","aliases":["CVE-2026-92939"],"modified":"2026-10-01T15:45:05.648155026Z","published":"2026-10-01T15:28:36Z","database_specific":{"github_reviewed_at":"2026-10-01T15:28:36Z","nvd_published_at":null,"cwe_ids":["CWE-114"],"severity":"CRITICAL","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/patriksimek/vm2/security/advisories/GHSA-46pr-c5wc-xffx"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-92939"},{"type":"WEB","url":"https://github.com/patriksimek/vm2/commit/aa146a77f859325e079f3bfbfe6d8309af483daa"},{"type":"PACKAGE","url":"https://github.com/patriksimek/vm2"},{"type":"WEB","url":"https://github.com/patriksimek/vm2/releases/tag/v3.11.7"},{"type":"WEB","url":"https://www.vulncheck.com/advisories/vm2-3.11.3-through-3.11.6-native-code-execution-via-crypto-setengine"}],"affected":[{"package":{"name":"vm2","ecosystem":"npm","purl":"pkg:npm/vm2"},"ranges":[{"type":"SEMVER","events":[{"introduced":"3.11.3"},{"fixed":"3.11.7"}]}],"database_specific":{"last_known_affected_version_range":"\u003c= 3.11.6","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-46pr-c5wc-xffx/GHSA-46pr-c5wc-xffx.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H"}]}