/

CVE-2026-25142

Severity:

CRITICAL RISK

(10.0)

Code Injection / Sandbox Escape in SandboxJS JavaScript

CVE-2026-25142

Analyzed

Vulnerability type

Category:

Code Injection / Sandbox Escape

CWE:

CWE-94, CWE-1321

Impact:

Remote Code Execution via Sandbox Escape

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

SandboxJS fails to properly restrict the __lookupGetter__ API, allowing access to object prototypes from within the sandboxed environment.

If an attacker can run JavaScript code inside a SandboxJS instance, they may be able to escape the sandbox and achieve remote code execution in the host context.

Affected context

This vulnerability affects applications that embed untrusted or semi-trusted JavaScript inside SandboxJS for isolation.

It is relevant when:

  • SandboxJS is used as the primary defense to contain untrusted scripts
  • The environment exposes __lookupGetter__ or related prototype-manipulating APIs to sandboxed code
  • Host objects or powerful capabilities (e.g., file, network, process, or module access) are reachable via prototype chains

In these setups, a crafted script can leverage prototype access to break containment guarantees.

Exploit preconditions

  • Attack surface: JavaScript execution environment where SandboxJS is used to run external or untrusted code
  • Required access: Ability to supply or influence code executed inside a SandboxJS sandbox (e.g., plugin systems, user scripts, configuration-based code)
  • Trigger point: Execution of attacker-controlled JavaScript that calls __lookupGetter__ (or equivalent) to traverse prototype chains
  • Why exploitation is possible: The sandbox does not sufficiently restrict access to prototype accessors, enabling retrieval of powerful host objects and eventual code execution outside the intended isolation boundary

Why this happens

The underlying issue is an incomplete isolation model around the JavaScript object system.

SandboxJS attempts to restrict what sandboxed code can reach, but leaves __lookupGetter__ available, which allows inspection and retrieval of getters associated with object properties.

Through this mechanism, an attacker can reach prototypes and potentially discover or construct references to privileged host objects and functions.

This behavior maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because untrusted code is effectively able to generate or invoke code in the host context by bypassing intended sandbox restrictions.

Potential impact

  • Sandbox escape from the JavaScript sandbox into the host execution environment
  • Remote code execution with the privileges of the embedding application or service
  • Access to sensitive in-memory data, configuration, or secrets available to the host process
  • Abuse of filesystem, network, or process APIs exposed in the host environment
  • Lateral movement within a system or infrastructure where the host application has elevated access

General mitigation guidance

Effective mitigation focuses on tightening the sandbox boundary and reducing trust in hosted scripts:

  • Restrict or remove access to prototype manipulation APIs (__lookupGetter__, __lookupSetter__, and related reflective capabilities) from sandboxed code
  • Isolate untrusted code in separate, least-privileged processes or runtimes rather than relying solely on in-VM sandboxes
  • Minimize the capabilities and host-object surface area exposed to sandboxed code, following a strict allowlist model
  • Apply a defense-in-depth approach: even if the sandbox fails, OS-level permissions, containerization, and network restrictions should limit the damage
  • Treat the sandbox as one layer of protection rather than the only security boundary around untrusted code execution

How teams detect issues like this

Detection typically involves reviewing both sandbox configuration and code paths that expose host functionality:

  • Static analysis or code review focused on:
  • Calls to sandbox APIs that execute user-controlled or external JavaScript
  • Instances where host objects, modules, or system APIs are passed into or exposed within the sandbox
  • Continued availability of __lookupGetter__, __lookupSetter__, or similar reflective APIs within sandboxed contexts
  • Security-focused tests that:
  • Execute crafted scripts inside the sandbox to verify that prototype access and escape attempts are blocked
  • Validate that host resources (filesystem, network, environment variables, process control) are not reachable from sandboxed code
  • Policy enforcement in CI/CD pipelines to require manual review or automated checks when sandbox configuration or allowed host APIs change

Sources

SourceLink
github.comgithub.com/nyariv/SandboxJS/blob/f212a38fb5a6d4bc2bc2e2466c0c011ce8d41072/src/executor.ts#L368-L398
github.comgithub.com/nyariv/SandboxJS/commit/75c8009db32e6829b0ad92ca13bf458178442bd3
github.comgithub.com/nyariv/SandboxJS/security/advisories/GHSA-9p4w-fq8m-2hp7

Frequently asked

questions

It can be, if an attacker can supply or influence JavaScript executed inside SandboxJS—such as through user-generated scripts, plugin systems, or configuration-driven code. In such cases, remote inputs can translate into sandbox escapes and remote code execution.

It depends on how SandboxJS is integrated. If only authenticated users can provide scripts to the sandbox, then authentication is required; if any external party can submit code that is run in the sandbox, then unauthenticated remote exploitation may be possible.

The safest pattern is to ensure that sandboxed code cannot reach powerful host objects or reflective prototype APIs, and to run untrusted code in isolated, least-privileged processes or containers. Limiting exposed capabilities and enforcing strict boundaries at both the library and process levels significantly reduces risk.

Treat sandboxing as a defense-in-depth measure, not a single point of trust. Use hardened, well-maintained isolation mechanisms; restrict reflective and prototype-based APIs in untrusted contexts; minimize exposed host functionality; and regularly test for sandbox escape vectors as part of your security review and CI processes.

Find out what's already
exploitable in your codebase.