Skip to content

vm: access to Symbols on global context does not work across sandbox boundary #884

Closed
@Sebmaster

Description

This is more a guess than anything, but apparently accessing Symbols in a vm context is not forwarded to the original object handle, resulting in different values depending on which side of the sandbox boundary the access happens.

Reduced test case:

"use strict";

var vm = require("vm");

var symbol = Symbol();

function Document() {
  this[symbol] = "foo";
  this.prop = "bar";
}

Document.prototype.symbol = function () {
  return this[symbol];
};

Document.prototype.property = function () {
  return this.prop;
};

var context = new Document();
vm.createContext(context);

console.log(context.symbol());
console.log(vm.runInContext("this.symbol()", context)); // should be foo, returns undefined

// compare:

console.log(context.property());
console.log(vm.runInContext("this.property()", context)); // should be bar, correct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions