Junglewise Threat Intelligence

safe-eval sandbox escape and arbitrary code execution

Severity: info · Published 2020-09-03

Technologies: safe-eval (npm). Vendors: npm.

Executive brief

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.

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

Related threats