/

CVE-2026-25586

Severity:

CRITICAL RISK

(10.0)

Prototype Pollution / Injection in SandboxJS Property

CVE-2026-25586

Analyzed

Vulnerability type

Category:

Prototype Pollution / Injection

CWE:

CWE-74

Impact:

Sandbox Escape and Prototype Pollution Leading to Arbitrary Code Behavior

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A sandbox escape in SandboxJS before version 0.8.29 allows an attacker to bypass prototype whitelist enforcement by shadowing hasOwnProperty on sandboxed objects.

Once the check is disabled, blocked properties like __proto__ become directly accessible, enabling host Object.prototype pollution and persistent, cross-sandbox compromise of code execution and data integrity.

Affected context

This issue affects applications that:

  • Embed untrusted or semi-trusted JavaScript code using SandboxJS for isolation
  • Rely on SandboxJS's property access and prototype whitelisting to prevent access to dangerous object internals
  • Allow sandboxed code to define or modify object properties, including hasOwnProperty or similar keys

In such environments, the sandbox is expected to enforce restrictions on prototype properties like __proto__, but that enforcement can be bypassed when hasOwnProperty is shadowed inside the sandbox.

Exploit preconditions

  • Attack surface: Any interface where untrusted JavaScript is executed inside SandboxJS (e.g., plugins, user scripts, rules engines, customization hooks, or multi-tenant logic).
  • Required access: Ability to submit or influence JavaScript that runs in the SandboxJS environment.
  • Trigger point: Creation or modification of an object within the sandbox such that its own hasOwnProperty shadows the expected method, followed by property access operations.
  • Why exploitation is possible: The sandbox's property-access path assumes hasOwnProperty is trustworthy for prototype whitelist enforcement. When it is shadowed, the check becomes ineffective, allowing direct access to blocked prototype properties like __proto__, leading to host Object.prototype pollution and persistent cross-sandbox manipulation.

Why this happens

The underlying bug is a logic flaw in how SandboxJS enforces prototype whitelisting for property access.

The enforcement code relies on hasOwnProperty on sandbox objects to determine whether a given property should be allowed, effectively trusting an attacker-controlled property on the object itself.

By redefining or shadowing hasOwnProperty, sandboxed code can disable or alter this check so that restricted properties (e.g., __proto__) pass through.

This maps to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component (Injection) in the sense that untrusted inputs (sandboxed code and properties) can influence downstream behavior (sandbox enforcement) and inject changes into shared prototypes.

Conceptually, the sandbox conflates user-controlled object state with its security boundary logic, enabling prototype pollution and a full sandbox escape.

Potential impact

  • Manipulation of Object.prototype in the host context, affecting all objects that inherit from it
  • Bypassing sandbox restrictions and escaping from the intended JS isolation boundary
  • Persistent cross-sandbox impact where one tenant's code can influence other sandboxes or host logic
  • Alteration of application control flow, data validation, or security checks that depend on prototype methods
  • Potential arbitrary code execution in the broader application context, depending on how SandboxJS is integrated

General mitigation guidance

Effective mitigation focuses on hardening the sandbox boundary and removing trust in attacker-controlled object properties:

  • Design sandbox enforcement to avoid reliance on mutable, user-controlled object methods (e.g., do not trust obj.hasOwnProperty or similar instance methods for security logic).
  • Use robust, reference-safe patterns such as Object.prototype.hasOwnProperty.call(obj, key) from a trusted, non-overridable reference, or internal metadata to track allowed properties.
  • Enforce strict controls around prototype access, ensuring that properties like __proto__, constructor, and other prototype-linked fields are blocked via defensive checks not influenced by sandboxed code.
  • Reduce the privileges of sandboxed environments: ensure they cannot access sensitive APIs, global objects, or host-side capabilities beyond what is strictly necessary.
  • Consider multiple layers of isolation (e.g., process or VM-based isolation) for running highly untrusted code, instead of relying solely on an in-process JavaScript sandbox.
  • Regularly review and test sandbox logic against known prototype pollution and sandbox escape patterns to ensure that enforcement is resilient to shadowing and tampering.

How teams detect issues like this

Detection typically involves a combination of code-centric and behavior-centric approaches:

  • Static analysis and code review:
  • Search for security-critical checks that depend on methods obtained from potentially attacker-controlled objects (e.g., obj.hasOwnProperty(...) instead of using a trusted reference).
  • Flag sandbox or access-control code where prototype or property restrictions rely on values from the sandboxed environment itself.
  • Look for any direct or indirect allowance of __proto__, constructor, or prototype chain manipulation within sandboxed code paths.
  • Automated tooling and tests:
  • Integrate security-focused static analyzers or linters that recognize prototype pollution patterns and dangerous property access sequences.
  • Add regression tests that attempt to shadow core methods (like hasOwnProperty) inside the sandbox and verify that restricted properties remain inaccessible.
  • Use fuzzing or property-based tests that generate mutated object shapes and method overrides to stress-test sandbox enforcement.
  • Runtime monitoring (where feasible):
  • Instrument sandbox environments to flag attempts to access or define suspicious properties such as __proto__, prototype, constructor, or overwritten fundamental methods.

Sources

SourceLink
github.comgithub.com/nyariv/SandboxJS/commit/67cb186c41c78c51464f70405504e8ef0a6e43c3
github.comgithub.com/nyariv/SandboxJS/security/advisories/GHSA-jjpw-65fv-8g48

Frequently asked

questions

Yes, it can be remotely exploitable whenever a remote party can supply JavaScript to be executed in SandboxJS—for example, user-defined scripts, plugins, or multi-tenant business logic. The exploit does not require local system access beyond the ability to run code in the sandbox.

An attacker needs the ability to execute or influence JavaScript code inside the SandboxJS environment. No direct access to the host runtime or filesystem is required; the attack works entirely within the structure of the sandboxed code.

The safest pattern is to redesign sandbox enforcement so that it never relies on attacker-controlled object properties or methods for security-critical decisions.

Use immutable, trusted references (e.g., Object.prototype.hasOwnProperty.call) or internal metadata for whitelist checks, and comprehensively block access to dangerous prototype-linked properties irrespective of sandbox object state.

To prevent similar vulnerabilities, treat sandbox boundaries as security-critical components:

  • Avoid trusting any values or methods that can be influenced by sandboxed code when enforcing access control.
  • Adopt defense-in-depth by combining in-process sandboxes with higher-isolation mechanisms for untrusted code.
  • Include prototype pollution, sandbox escape scenarios, and method shadowing tests as part of your standard security testing.
  • Incorporate security review and automated checks specifically targeting sandbox logic whenever it is modified.
Find out what's already
exploitable in your codebase.