Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@record/web-assembly

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@record/web-assembly

Sandboxed ECMAScript support for the WebAssembly API

latest
Source
npmnpm
Version
0.7.2
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

web-assembly

Build status

web-assembly is an implementation of the WebAssembly API for secure execution of ECMAScript. It has a footprint of 5KB and does not depend on the DOM.

web-assembly has been designed with efficiency and security in mind. Code is sandboxed purely by means of the JS runtime API. No lexing or parsing is carried out. Security measures are designed to be immune to extensions of the ECMAScript language. The package works in an ES5-compliant manner, making results predictable and security best assessable.

Installation

Install this package using NPM:

npm install @record/web-assembly --save-dev

Usage

import WebAssembly from '@record/web-assembly';

let sandbox = {console};

WebAssembly.instantiate('console.log("Hello world")', sandbox);

See the WebAssembly API documentation for further details.

Method

web-assembly executes scripts synchronously in the global scope. The package has no dependencies, that is, tertiary APIs such as DOM or Worker are not involved. Code is not transpiled.

In order to sandbox code and prevent leaks or side-effects, built-in objects are frozen. That is, any modifications on properties or sub-properties of built-in objects (such as Object.prototype.toString) will be discarded (see the behavior of Object.freeze()).

Objects are thoroughly isolated from the host environment. Variables passed as importObject are completely represented in the sandbox: methods are callable and properties are recursively accessible. However, changes made to these properties are not reflected in the host environment.

Caveats

  • Scripts run in strict mode (or a superset, depending on browser support).
  • Built-in objects (Object, Array, Date etc.) and their prototypes are immutable.

License

© 2016 Filip Dalüge, all rights reserved.

FAQs

Package last updated on 16 May 2017

Did you know?

Socket

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.

Install

Related posts