Skip to content

GHSA-6w8r-xxw2-g3hx CVE-2026-92938

vm2 allows a sandboxed plugin to execute native code through `node:sqlite`

Critical npm
Severity
9.4 / 10
Critical · CVSS 4.0
Exploit chance (EPSS)
0.62%
Chance of exploitation in the next 30 days. Higher than 49.55% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-693 Protection Mechanism Failure
Fix
3.11.7
Upgrade vm2 to this version or later

Description

Summary

vm2 3.11.6 exposes Node.js's host node:sqlite module to NodeVM code when that builtin is allowed explicitly or through builtin: ['*']. The module is wrapped as read-only, but callable methods retain host-process authority. A sandboxed plugin can construct an in-memory database with extension loading enabled and call DatabaseSync.loadExtension() on a native library bundled in the plugin directory.

SQLite loads the library into the Node.js host process and invokes its native extension entry point. This gives the untrusted plugin arbitrary native code execution outside the sandbox.

The exploit needs only the node:sqlite builtin and a compatible native library already present in the untrusted plugin package. It does not require fs, process, module, child_process, worker_threads, vm, inspector, vm2 nesting, or an existing database file.

Details

The vulnerable boundary spans the builtin inventory, resolver, runtime loader, and generic read-only wrapper.

On current Node.js versions, the builtin inventory contains the literal name node:sqlite. vm2 admits that name when it is explicitly configured or when the wildcard allowlist is expanded:

const BUILTIN_MODULES = module.builtinModules.filter(/* denylist checks */);

The resolver then treats every request beginning with node: as a core-module request, even if the complete request string is not an allowlist key:

if (x.startsWith('node:') || this.builtins.has(x)) {
  return x;
}

The sandbox runtime removes exactly one node: prefix and looks up the remainder in the configured builtin map:

if (filename.startsWith('node:')) {
  id = filename.slice(5);
  return loadBuiltinModule(id);
}

Consequently, the sandbox spelling below resolves to the configured map entry node:sqlite:

require('node:node:sqlite')

The default builtin loader imports the real module in the host realm and exposes it through vm.readonly():

builtins.set(key, vm => vm.readonly(hostRequire(key)));

Read-only wrapping prevents property assignment. It does not remove dangerous callable capabilities. Calls to DatabaseSync and loadExtension() are forwarded to the host implementation.

The complete exploit flow is:

attacker supplies an untrusted plugin package containing JavaScript and a native library
  -> host runs the JavaScript in NodeVM with node:sqlite allowed
  -> plugin resolves the host module as node:node:sqlite
  -> plugin creates an in-memory DatabaseSync with allowExtension enabled
  -> plugin derives the bundled library path from its own __dirname
  -> plugin calls database.loadExtension(libraryPath)
  -> vm2 forwards the call to host SQLite
  -> SQLite loads the library into the Node.js host process
  -> SQLite invokes the library's native extension entry point
  -> attacker native code executes with the host process's privileges

The path does not need to be read through a sandboxed filesystem API. CommonJS already supplies the plugin's own directory, so an attacker can concatenate __dirname with the known name of a bundled library. The host necessarily places the untrusted plugin package on disk before evaluating its JavaScript.

PoC

The attached PoC is local and harmless. Its native extension entry point writes one marker file and returns success. It does not launch a process, connect to a network service, or modify any other file.

Prerequisites: macOS, Node.js with node:sqlite, npm, and a C compiler.

  1. Open the attached poc directory.

  2. Install the exact affected package:

    npm install --ignore-scripts
    
  3. Compile and run the proof:

    npm run poc
    

The script compiles extension_probe.c as libvm2_sqlite_probe.dylib, then runs untrusted-plugin.js in this restrictive configuration:

new NodeVM({
  console: 'off',
  require: { builtin: ['node:sqlite'] },
});

The sandboxed plugin performs only:

const { DatabaseSync } = require('node:node:sqlite');
const database = new DatabaseSync(':memory:', { allowExtension: true });
database.loadExtension(__dirname + '/libvm2_sqlite_probe.dylib');
database.close();

A vulnerable result is:

{
  "sandboxResult": {
    "nativeExtensionLoaded": true,
    "usedOnlySQLiteBuiltin": true
  },
  "markerExists": true,
  "markerText": "VM2_SQLITE_EXTENSION_ENTRYPOINT_EXECUTED"
}

The marker is written from the compiled native extension entry point, not from JavaScript. loadExtension() also returns successfully, proving that SQLite both loaded the library and invoked its entry point.

Impact

This is a sandbox escape to arbitrary native code execution. The native code runs inside the Node.js host process with the operating-system identity and privileges of that process, beyond all vm2 JavaScript, module, and proxy restrictions.

An attacker can replace the marker-only extension with native code that:

  • reads application secrets, credentials, environment variables, and files available to the host account;
  • modifies application data or executable files and establishes persistence;
  • accesses internal services using the host's network identity;
  • steals other tenants' data from the same process;
  • terminates or corrupts the host process; and
  • performs any other operating-system action permitted to the host account.

The realistic affected workflow is a plugin platform, automation service, notebook, build service, or multi-tenant code runner that stores attacker-supplied package contents and evaluates the package's JavaScript in NodeVM while allowing node:sqlite or all builtins. The attacker does not need pre-existing host execution, a writable database, or a command-execution builtin.

Affected versions

npm

PackageVulnerableFixed in
vm2
>= 3.11.3, < 3.11.7
3.11.7

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

vm2 npm → 3.11.7

npm
npm install vm2@3.11.7
yarn
yarn add vm2@3.11.7
pnpm
pnpm add vm2@3.11.7

Severity breakdown

CVSS 4.0 9.4

CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

Attack vector
Network
Attack complexity
Low
Attack requirements
None
Privileges required
Low
User interaction
None
Confidentiality (vulnerable system)
High
Integrity (vulnerable system)
High
Availability (vulnerable system)
High
Confidentiality (subsequent systems)
High
Integrity (subsequent systems)
High
Availability (subsequent systems)
High
Exploit maturity
Not defined
Scope
X

CVSS 3.1 9.9

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

Weakness

CWE-693: Protection Mechanism Failure

The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-489w-w794-jq94
vm2: NodeVM zlib Buffers expose pooled host memory across the VM boundary
High Also affects vm2
GHSA-2v2p-6j97-cjg9
vm2: Host Promise rejection from an exposed constructor can terminate the vm2 host process
Medium Also affects vm2
GHSA-5h3f-q97h-ccvc
vm2: NodeVM custom resolution bypasses external path boundaries
Critical Also affects vm2
GHSA-pq68-rvw4-xp4r
vm2 contains a sandbox escape vulnerability
Critical Also affects vm2
GHSA-f8gf-w286-fmq2
vm2: `allowAsync: false` can be bypassed through Promise thenable assimilation in VM and NodeVM
High Also affects vm2
GHSA-6rh5-qq4q-97xh
vm2: NodeVM builtin denylist bypass via fs/promises despite -fs, allowing host filesystem writes
High Also affects vm2
GHSA-8686-vhfx-7r3j
vm2: NodeVM node:-prefixed negative builtin deny bypass exposes child_process
Critical Also affects vm2
GHSA-wjwh-qqvp-g4p4
vm2 sandbox escape via WebAssembly.compileStreaming Promise species bypass
Critical Also affects vm2
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor