# safe-eval sandbox escape and arbitrary code execution

Source: https://junglewise.ai/threats/safe-eval-sandbox-escape-and-arbitrary-code-execution-8c44a96c  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2020-09-03. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: info · Published 2020-09-03

safe-eval is a JavaScript library designed to safely evaluate code in a restricted sandbox environment. The vulnerability allows attackers to break out of this sandbox and execute arbitrary code on the system, potentially leading to complete system compromise and unauthorized access to sensitive data or resources.

Technologies: [safe-eval (npm)](https://junglewise.ai/threats/technologies/safe-eval). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Informational severity, published 3 September 2020.

**Which products and versions are affected?** safe-eval (npm) all versions.

**Is there a fix for This vulnerability?** No fixed version is recorded yet. Check the vendor's advisory in the references below. If you run it, Junglewise drafts a mitigation that fits your setup and applies it once you approve, with senior security engineers behind it.

**How is This vulnerability attacked?** It is attacked over the network, in a software library.

**Am I affected?** Check whether you run safe-eval (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

This is a sandbox escape vulnerability in safe-eval affecting all versions. The vulnerability exploits JavaScript function constructor chains (specifically leveraging callee and caller constructors) to bypass sandbox restrictions and gain access to the global process object. An attacker can craft a malicious payload that uses Object.defineProperty and getter functions to invoke the Function constructor with arbitrary code, allowing execution of Node.js commands like child_process.execSync(). No authentication or user interaction is required; the vulnerability is triggered when any untrusted code is evaluated through safe-eval. No patch is currently available; the developers recommend using an alternative package.

## Affected products

- npm safe-eval all versions

## Timeline

- 2020-09-03: disclosed

## References

- [https://www.npmjs.com/advisories/1033](https://www.npmjs.com/advisories/1033)

## Related threats

- [safe-eval sandbox bypass via prototype pollution](https://junglewise.ai/threats/cve-2023-26122-safe-eval-sandbox-bypass-via-prototype-pollution)
- [safe-eval prototype pollution in safeEval function](https://junglewise.ai/threats/cve-2023-26121-safe-eval-prototype-pollution-in-safeeval-function)
- [hacksparrow safe-eval Prototype Pollution in safeEval](https://junglewise.ai/threats/cve-2022-25904-hacksparrow-safe-eval-prototype-pollution-in-safeeval)
- [safe-eval sandbox escape and arbitrary code execution](https://junglewise.ai/threats/cve-2020-7710-safe-eval-sandbox-escape-and-arbitrary-code-execution)
- [safe-eval sandbox escape via constructor access](https://junglewise.ai/threats/cve-2017-16088-safe-eval-sandbox-escape-via-constructor-access)
