CVE-2017-16088: Sandbox Breakout in safe-eval
Summary
CVE-2017-16088: Sandbox Breakout in safe-eval. Affects safe-eval versions < 0.3.0. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The safe-eval package is an npm package that provides a sandboxed JavaScript evaluator. It allows users to execute JavaScript code in a controlled environment, preventing access to potentially harmful operations. However, certain versions of safe-eval are vulnerable to a sandbox escape, which can lead to unauthorized access to the entire standard library and potential security breaches.
Vulnerability Detail
The vulnerability in safe-eval arises from the ability of un-sanitized user input to access object constructors. By exploiting this, an attacker can break out of the sandbox and gain access to sensitive resources. For example, an attacker could access the process object and call .exit(), potentially terminating the application or executing arbitrary code. This vulnerability poses a significant risk as it allows an attacker to bypass the intended restrictions of the sandbox and perform unauthorized actions.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
If updating to the latest version of safe-eval is not immediately feasible, a temporary workaround is to avoid using un-sanitized user input in the evaluation process. By thoroughly validating and sanitizing user input before passing it to safe-eval, the risk of a sandbox escape can be mitigated. Here is an example of how to sanitize user input in Node.js:
const safeEval = require('safe-eval');
function sanitizeInput(input) {
// Perform input validation and sanitization
// ...
return sanitizedInput;
}
const userInput = 'this.constructor.constructor(\'return process\')().exit()';
const sanitizedInput = sanitizeInput(userInput);
safeEval(sanitizedInput);
Conclusion
The safe-eval package is vulnerable to a sandbox escape, allowing unauthorized access to the standard library. It is crucial to update to version 0.4.0 or later to fix this vulnerability. If immediate updating is not possible, sanitizing user input can provide a temporary workaround. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for safe-eval →
FAQ
This vulnerability allows an attacker to break out of the sandbox in safe-eval and access the entire standard library. This can lead to unauthorized actions, such as terminating the application or executing arbitrary code.
Versions 0.3.0 and earlier of safe-eval are affected by this vulnerability.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your package-lock.json file, and Vulert will analyze it for any open-source vulnerabilities, including this one.
Yes, updating to version 0.4.0 or later of the safe-eval package will fix this vulnerability.
If updating to the latest version is not immediately feasible, you can sanitize user input before passing it to safe-eval to mitigate the risk of a sandbox escape. Ensure thorough validation and sanitization of user input to prevent unauthorized access.
References
Related vulnerabilities
Recent vulnerabilities recorded for safe-eval.