Executive brief
@nyariv/sandboxjs is a JavaScript library that creates isolated execution environments to safely run untrusted code. An attacker can escape the sandbox by shadowing the hasOwnProperty method on objects, bypassing prototype protection checks and polluting the host process's Object.prototype. This allows arbitrary code execution on the host system, data theft, and persistent compromise of all code running in the host environment.
Technical details
The vulnerability is a prototype whitelist bypass in the property-access validation logic. The prototypeAccess check in executor.ts uses a.hasOwnProperty(b) directly, which is bypassable when an attacker's sandboxed object shadows hasOwnProperty to return true, causing the whitelist enforcement to be skipped. This permits direct access to __proto__ and other blocked prototype properties. An attacker with the ability to execute arbitrary code in the sandbox can leverage prototype pollution to modify Object.prototype, Array.prototype, and other built-in prototypes, leading to host process compromise. The attack requires no privileges, authentication, or user interaction beyond code execution within the default Sandbox configuration. Patches are available in version 0.8.29 and later.
Affected products
- nyariv sandboxjs 0.8.28 and earlier
Timeline
- 2026-02-05: disclosed
- 2026-02-05: patched: Fixed in version 0.8.29