Executive brief
SandboxJS is a JavaScript library used to safely execute untrusted code in an isolated sandbox environment. A vulnerability in its design allows attackers to bypass the sandbox restrictions by accessing the unprotected AsyncFunction constructor, gaining the ability to execute arbitrary code with full access to the host system. This can lead to complete compromise of any system running SandboxJS to execute user-supplied code.
Technical details
SandboxJS attempts to prevent code escape by replacing the global Function constructor with a sandboxed version through a mapping in utils.ts. However, the library failed to include mappings for AsyncFunction, GeneratorFunction, and AsyncGeneratorFunction—constructors that are accessible via the .constructor property of function instances. In executor.ts, when the sandboxed code accesses the .constructor property of an async function, the executor returns the native host AsyncFunction constructor instead of a safe replacement. An attacker can exploit this by obtaining the host AsyncFunction constructor and using it to create functions that execute in the global scope outside the sandbox context, achieving remote code execution. The vulnerability affects all versions before 0.8.26 and is fixed in version 0.8.26 and later.
Affected products
- nyariv SandboxJS before 0.8.26
Timeline
- 2026-01-27: disclosed
- 2026-01-27: advisory
- 2026-01-27: patched: Version 0.8.26 released