Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2026-43998 — vm2

🟠 CVSS 8.0 — High ⚠️ Exploit Public CWE-59 OSV
8.0
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

vm2 has a NodeVM require.root bypass via symlink traversal that allows sandbox escape

Summary

NodeVM's require.root path restriction can be bypassed using filesystem symlinks, allowing sandboxed code to load modules from outside the allowed root directory in host context. Because path validation uses path.resolve() (which does not dereference symlinks) but module loading uses Node's native require() (which does), an attacker can load arbitrary host-realm modules and achieve remote code execution.

Severity

High (CVSS 3.1: 8.5)

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

  • Attack Vector: Network — sandboxed code is typically received from external sources (user-submitted scripts, plugin code)
  • Attack Complexity: High — requires symlinks inside the allowed root that point outside it; common with pnpm, npm workspaces, and npm link but not guaranteed in all deployments
  • Privileges Required: Low — attacker needs only the ability to submit code to the sandbox, which is the intended use case
  • User Interaction: None
  • Scope: Changed — the vulnerability is in the sandbox boundary; impact is on the host system
  • Confidentiality Impact: High — arbitrary file read via host command execution
  • Integrity Impact: High — arbitrary command execution on the host
  • Availability Impact: High — arbitrary command execution on the host

Affected Component

  • lib/resolver-compat.jsCustomResolver.isPathAllowed() (line 53-60)
  • lib/resolver-compat.jsCustomResolver.loadJS() (line 62-66)
  • lib/filesystem.jsDefaultFileSystem.resolve() (line 8-10)

CWE

  • CWE-59: Improper Link Resolution Before File Access

Description

Root Cause: Check/Use Path Discrepancy

The isPathAllowed method validates whether a resolved filename falls within the allowed root paths using a string-prefix check:

```js

// lib/resolver-compat.js:53-60

isPathAllowed(filename) {

return this.rootPaths === undefined || this.rootPaths.some(path => {

if (!filename.startsWith(path)) return false;

const len = path.length;

if (filename.length === len || (len > 0 && this.fs.isSeparator(path[len-1]))) return true;

return this.fs.isSeparator(filename[len]);

});

}

```

The filename passed to this check is resolved via DefaultFileSystem.resolve(), which uses path.resolve():

```js

// lib/filesystem.js:8-10

resolve(path) {

return pa.resolve(path);

}

```

path.resolve() normalizes the path (resolves ., .., and makes it absolute) but does NOT dereference symlinks. A symlink at /root/node_modules/safe pointing to /outside/root/malicious resolves to /root/node_modules/safe — passing the prefix check.

However, the actual module loading uses Node's native require(), which does follow symlinks:

```js

// lib/resolver-compat.js:62-66

loadJS(vm, mod, filename) {

if (this.pathContext(filename, 'js') !== 'host') return super.loadJS(vm, mod, filename);

const m = this.hostRequire(filename);

mod.exports = vm.readonly(m);

}

```

No Symlink Defenses Exist

A search for realpath, readlink, lstat, or any symlink-aware function across the entire lib/ directory returns zero results. Neither DefaultFileSystem nor VMFileSystem provides a realpath method. The root paths themselves are also resolved without dereferencing symlinks:

```js

// lib/resolver-compat.js:218

const checkedRootPaths = rootPaths ? (Array.isArray(rootPaths) ? rootPaths : [rootPaths]).map(f => fsOpt.resolve(f)) : undefined;

```

Full Execution Chain

1. Host creates NodeVM with require: { external: ['safe'], root: '/tmp/root', context: 'host' }

2. A symlink exists: /tmp/root/node_modules/safe/outside/root/vm2/ (e.g., via pnpm, npm link, or workspaces)

3. Sandbox code calls require('safe')

4. DefaultResolver.resolveFull() resolves to /tmp/root/node_modules/safe/index.js

5. tryFile() calls this.fs.resolve(x)path.resolve()/tmp/root/node_modules/safe/index.js (symlink NOT followed)

6. isPathAllowed() checks if path starts with /tmp/root/PASSES

7. loadJS() detects context: 'host', calls this.hostRequire(filename)

8. Node's require() follows the symlink, loads from /outside/root/vm2/index.js

9. Module executes in host realm; exports proxied to sandbox

10. Sandbox uses loaded module to escalate (e.g., creates a new privileged NodeVM with child_process)

Proof of Concept

```js

const path = require('path');

const fs = require('fs');

const os = require('os');

const { NodeVM } = require('vm2');

// Create an "allowed" root directory

const root = fs.mkdtempSync(path.join(os.tmpdir(), 'vm2-root-'));

fs.mkdirSync(path.join(root, 'node_modules'), { recursive: true });

// Symlink inside root pointing to vm2 package outside root

// In real deployments: pnpm, npm link, workspaces create these automatically

const link = path.join(root, 'node_modules', 'safe');

fs.symlinkSync(path.resolve(__dirname),

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is high, an attacker needs low-level privileges on the target. No user interaction is required. The scope is changed, meaning a successful attack can affect components beyond the vulnerable one. Rated impact: confidentiality high, integrity high, availability high.

CVSS metrics in full

The score comes from this vector: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: High — the attacker first has to win a race, learn a secret or otherwise prepare the target.
  • Privileges required: Low — an ordinary user account is enough.
  • User interaction: None — nobody has to be tricked into anything.
  • Scope: Changed — a successful attack reaches components beyond the vulnerable one.
  • Confidentiality impact: High — total loss, or loss the attacker controls.
  • Integrity impact: High — total loss, or loss the attacker controls.
  • Availability impact: High — total loss, or loss the attacker controls.

Weakness class

CVE-2026-43998 is classified as CWE-59: Link Following. The software follows symbolic or hard links without verifying their target, so a planted link can redirect an operation to a sensitive file.

Affected software

CVE-2026-43998 is recorded against 1 package.

  • vm2

Timeline and source

Published on 7 May 2026 and last revised on 6 August 2026. A public exploit is known to exist, which raises the urgency of patching considerably. Record sourced from OSV.

References

github.com (Web)
nvd.nist.gov (Advisory)
github.com (Package)
github.com (Web)

Other advisories for this package

vm2 has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-59: Link Following) in other software:

CVE-2026-43998 on other distributions

Each distribution ships its own build and its own fixed version. Pick the one you run:

Details

Severity HIGH
CVSS Score 8.0
CVSS Vector CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H
CWE CWE-59
Public Exploit ⚠️ Yes
Source OSV
Published 2026-05-07
Updated 2026-08-20
Modified 2026-08-06
Fix URL N/A

Affected Packages

Software From version Fixed in
vm2

Similar Threats

Exploit Protection

Are you running vm2?

CVE-2026-43998 carries CVSS 8.0 High rating and a public exploit already exists. BotEraser checks your installation against this and other known CVE records, and blocks IPs associated with exploit activity.

Check My Site For CVE-2026-43998 →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.

Browse related advisories

All advisoriesCVECVE 2026