realms-shim@1.1.0 vulnerabilities

Spec-compliant shim for Realms TC39 Proposal

Direct Vulnerabilities

Known vulnerabilities in the realms-shim package. This does not include vulnerabilities belonging to this package’s dependencies.

Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities and provides fixes for free.
Fix for free
Vulnerability Vulnerable Version
  • C
Sandbox Bypass

realms-shim is a shim implementation of the Realm API Proposal.

Affected versions of this package are vulnerable to Sandbox Bypass via a Prototype Pollution attack vector.

PoC

import Realm from 'realms-shim'

let realm = Realm.makeRootRealm();
try {
    realm.evaluate(`
        Error.prepareStackTrace = function (error, stackTrace) {        
            stackTrace.__proto__.__proto__.polluted = 'success'            
        };
        x;
    `);
} catch(e) {
    // we do not even need to print e
}
console.log(polluted);

How to fix Sandbox Bypass?

There is no fixed version for realms-shim.

*
  • C
Sandbox Bypass

realms-shim is a shim implementation of the Realm API Proposal.

Affected versions of this package are vulnerable to Sandbox Bypass via a Prototype Pollution attack vector.

PoC

import Realm from 'realms-shim'
let realm = Realm.makeRootRealm();

realm.evaluate(`
function test() {    
    try {
       test();
    } catch (e) {                        
        e.__proto__.__proto__.__proto__.polluted = "success";        
        new Error().stack; // if one comments this uselss line, the PoC does not work anymore
    }
}
test();`);
console.log(polluted)

How to fix Sandbox Bypass?

There is no fixed version for realms-shim.

*
  • C
Sandbox Breakout

realms-shim is a shim implementation of the Realm API Proposal.

Affected versions of this package are vulnerable to Sandbox Breakout. The realms-shim is intended to provide a "safe evaluator" which executes arbitrary strings code with limited authority. This provides a "sandbox" which only has access to the specific objects and power that the caller chooses to expose. The evaluate() function it implements takes two additional arguments: endowments (which are exposed in the global lexical scope), and an options bag. The transforms option is a list of functions that are applied to the string of code, to apply Babel-like transformations before it gets executed (e.g. to implement syntax extensions).

A bug was found in the transformation pipeline that exposed a primal-Realm object to one of the transform functions. The confined code could use this to escape the sandbox and compromise the Realm which created it. This generally leads to a full compromise of the application.

How to fix Sandbox Breakout?

Upgrade realms-shim to version 1.2.1 or higher.

<1.2.1
  • C
Sandbox Breakout

realms-shim is a shim implementation of the Realm API Proposal.

Affected versions of this package are vulnerable to {{ affectedlibrary.vulnerability.title }}, which would allow the attacker to run arbitrary code.

The vulnerable paths:

  1. Reflect.construct can be used on the sandboxed Function constructor to reach the prototypes of the primal Realm.
  2. The package's confined evaluator depended upon correct behavior of the spread operator a = [...b, ...c], which could be modified by the confined code.
  3. The package has an uncaught exception that may allow an attacker to break out of the sandbox by catching the exception and using the caught Exception object.
  4. The package's core evaluator, which must switch between "unsafe mode" and "safe mode" for each call, could be left in "unsafe mode" if an attacker is able to force a RangeError in a specific timeframe.

How to fix Sandbox Breakout?

Upgrade realms-shim to version 1.2.0 or higher.

<1.2.0