Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@edge-runtime/vm
Advanced tools
@edge-runtime/vm is a Node.js package that provides a runtime environment for executing JavaScript code in a secure and isolated context. It is particularly useful for edge computing scenarios where you need to run code close to the data source with minimal latency.
Execute JavaScript Code
This feature allows you to execute arbitrary JavaScript code within a secure and isolated virtual machine context.
const { EdgeVM } = require('@edge-runtime/vm');
const vm = new EdgeVM();
const result = vm.run('2 + 2');
console.log(result); // 4
Sandboxed Environment
You can create a sandboxed environment with predefined global variables, ensuring that the executed code does not have access to the outer scope.
const { EdgeVM } = require('@edge-runtime/vm');
const vm = new EdgeVM({ sandbox: { foo: 'bar' } });
const result = vm.run('foo');
console.log(result); // 'bar'
Timeouts and Resource Limits
This feature allows you to set execution timeouts and resource limits to prevent infinite loops and excessive resource consumption.
const { EdgeVM } = require('@edge-runtime/vm');
const vm = new EdgeVM({ timeout: 1000 });
try {
vm.run('while(true) {}');
} catch (e) {
console.log(e.message); // 'Script execution timed out.'
}
vm2 is a popular Node.js package that provides a sandboxed environment for executing JavaScript code. It offers similar functionalities to @edge-runtime/vm, such as running code in an isolated context and setting resource limits. However, vm2 is more mature and widely used in the community.
isolated-vm is another Node.js package designed for running JavaScript code in isolation. It provides a high level of security and performance, making it suitable for scenarios where you need to run untrusted code. Compared to @edge-runtime/vm, isolated-vm offers more advanced features like shared memory and asynchronous execution.
@edge-runtime/vm: Low level bindings for creating Web Standard contexts.
See @edge-runtime/vm section in our website for more information.
Using npm:
npm install @edge-runtime/vm --save
or using yarn:
yarn add @edge-runtime/vm --dev
or using pnpm:
pnpm install @edge-runtime/vm --save
@edge-runtime/vm © Vercel, released under the MPLv2 License.
Authored and maintained by Vercel with help from contributors.
vercel.com · GitHub Vercel · Twitter @vercel
FAQs
Low level bindings for creating Web Standard contexts.
The npm package @edge-runtime/vm receives a total of 526,886 weekly downloads. As such, @edge-runtime/vm popularity was classified as popular.
We found that @edge-runtime/vm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.