Skip to content
RCE Write-up Advanced

Escaping the Matrix: A Deep Dive into SandboxJS RCE (CVE-2026–23830)

SandboxJS failed to sandbox the AsyncFunction constructor, allowing sandboxed code to obtain the host's Function constructor and execute arbitrary JavaScript outside the sandbox. An attacker could then use Node.js internals to run system commands, achieving remote code execution.

meysam_bal-afkan Follow

Published on medium.com

We often rely on sandboxes to run untrusted code securely. Whether it’s a coding interview platform, a discord bot, or a rule engine, we assume the “box” is sealed.

Meysam Bal-afkan, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The library sandboxed the standard Function constructor but overlooked the AsyncFunction constructor, which still pointed to the host environment.

Impact

An attacker could execute arbitrary system commands on the host, and even with no visible output could exfiltrate data out-of-band.

What the attacker needed

Ability to run code in SandboxJS < 0.8.26; network egress for out-of-band exfiltration

The fix

The library was fixed by properly wrapping and isolating AsyncFunction; users should upgrade to the latest version.

How it was found

  1. Define an empty async function inside the sandbox.
  2. Read its constructor property to obtain the host's Function constructor.
  3. Use that constructor to reach Node.js internals such as process.mainModule.require.
  4. Load child_process and execute system commands, optionally exfiltrating output out-of-band.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A sandbox is meant to run untrusted code safely, like a playpen. Here, the library forgot to block one way of reaching JavaScript's built-in function maker, so code inside the playpen could build a new function that runs outside it. That let an attacker run commands on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.