Sandbox Breakout / Arbitrary Code Execution in notevil
Summary
GHSA-7r5f-7qr4-pf6q: Sandbox Breakout / Arbitrary Code Execution in notevil. Affects notevil versions < 1.3.2. Fixed in 1.3.2. 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 notevil package is an npm package used for safe evaluation of JavaScript code. It provides a sandbox environment to execute untrusted code securely. The package is designed to prevent access to sensitive JavaScript features and restrict the execution capabilities of the code being evaluated.
Vulnerability Detail
Versions of notevil prior to 1.3.2 are vulnerable to a Sandbox Escape vulnerability, which can lead to Remote Code Execution. The vulnerability arises from the package's failure to prevent access to the Function constructor. By not properly checking the return values of function calls, attackers can bypass the sandbox and access the Function prototype's constructor. This allows them to execute arbitrary code outside the intended sandbox environment. An example payload demonstrating the vulnerability is as follows:
var safeEval = require('notevil');
var input = "" +
"function fn() {}" +
"var constructorProperty = Object.getOwnPropertyDescriptors(fn.__proto__).constructor;" +
"var properties = Object.values(constructorProperty);" +
"properties.pop();" +
"properties.pop();" +
"properties.pop();" +
"var Function = properties.pop();" +
"(Function('return this'))();";
safeEval(input);
This vulnerability can have severe consequences as it allows an attacker to execute arbitrary code with the privileges of the application using the notevil package.
How To Fix
Minimum fixed version
1.3.2
This is the first release that contains the fix.
npm install notevil@1.3.2
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. Upgrading to the fixed version is the only recommended solution.
Conclusion
The notevil package prior to version 1.3.2 is vulnerable to a Sandbox Escape vulnerability, which can lead to Remote Code Execution. It is crucial to upgrade to the fixed version to ensure the secure execution of untrusted code. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for notevil →
FAQ
This vulnerability allows an attacker to execute arbitrary code with the privileges of the application using the notevil package. This can lead to unauthorized access, data breaches, and potential compromise of the entire system.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. The playground analyzes your package-lock.json file and provides real-time alerts for open-source vulnerabilities, including this one.
Yes, upgrading to version 1.3.2 or later of the notevil package fixes this vulnerability. It is recommended to update your package to the latest version to ensure the security of your application.
No, there are no known workarounds for this vulnerability. Upgrading to the fixed version is the only recommended solution.
You can find more information about this vulnerability in the GitHub Advisory Database at https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/09/GHSA-7r5f-7qr4-pf6q/GHSA-7r5f-7qr4-pf6q.json
References
Related vulnerabilities
Recent vulnerabilities recorded for notevil.