Sandbox Breakout / Arbitrary Code Execution in localeval
Summary
GHSA-mmqv-m45h-q2hp: Sandbox Breakout / Arbitrary Code Execution in localeval. Affects localeval versions >= 0.0.0, < 15.3.0. Fixed in 15.3.0. 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 localeval package is an npm package used for evaluating JavaScript code in a sandboxed environment. It provides a secure way to execute user-provided code without exposing the underlying system. However, all versions of localeval are vulnerable to a Sandbox Escape leading to Remote Code Execution. This vulnerability allows attackers to execute arbitrary code in the system by bypassing the sandbox restrictions.
Vulnerability Detail
The vulnerability in localeval arises from the package's failure to restrict access to the main context through constructor.constructor. This allows attackers to execute arbitrary code in the system. By evaluating the payload constructor.constructor("return process.env")(), an attacker can retrieve the contents of process.env, potentially exposing sensitive information. This vulnerability poses a significant risk as it can lead to remote code execution and compromise the security and integrity of the system.
How To Fix
Minimum fixed version
15.3.0
This is the first release that contains the fix.
npm install localeval@15.3.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As there is no fix available, a possible workaround is to avoid using localeval altogether and switch to a different package that provides similar functionality but without the vulnerability. This will help mitigate the risk of sandbox escape and arbitrary code execution. Here is an example of how to use the vm module in Node.js as an alternative:
const vm = require('vm');
const code = 'console.log(process.env);';
const sandbox = {
console,
process
};
const script = new vm.Script(code);
const context = new vm.createContext(sandbox);
script.runInContext(context);
This code snippet demonstrates how to execute user-provided code in a sandboxed environment using the vm module in Node.js. By explicitly defining the allowed objects and properties in the sandbox object, you can restrict access to sensitive resources and prevent arbitrary code execution.
Conclusion
The localeval package is vulnerable to a Sandbox Escape leading to Remote Code Execution. This vulnerability allows attackers to execute arbitrary code in the system by bypassing the sandbox restrictions. Currently, there is no fix available, and it is recommended to consider using an alternative package until a fix is made available. Stay updated with the official GitHub repository or the npm package page for any updates on a patched version. For further support on vulnerability remediation, you can reach out to the Devnack team at DevNack.com.
See every vulnerability recorded for localeval →
FAQ
localeval is an npm package used for evaluating JavaScript code in a sandboxed environment. It provides a secure way to execute user-provided code without exposing the underlying system.
This vulnerability allows attackers to break out of the sandbox and execute arbitrary code in the system. It can lead to remote code execution and compromise the security and integrity of the system.
Currently, there is no fix available for this vulnerability in localeval. It is recommended to consider using an alternative package until a fix is made available.
To mitigate the risk of this vulnerability, it is recommended to avoid using localeval and switch to a different package that provides similar functionality but without the vulnerability. Additionally, ensure that your application is always up to date with the latest security patches and follow secure coding practices.
You can find more information about this vulnerability in the official GitHub advisory database. Additionally, you can reach out to the Devnack team at info@devnack.com for further support on vulnerability remediation.