isolated-vm
isolated-vm copied to clipboard
`reference.set` fails if the property already exists
await execution_context.eval("var window = {};"); // Created “globalThis.window” from inside
await execution_context.global.set("window", 1); // Setting it fails, not overwriting.
https://github.com/laverdet/isolated-vm/blob/22ed400de4cd65cbe537614af59228b3fc416f4b/src/module/reference_handle.cc#L597-L599
TypeError: Set failed
at (<isolated-vm boundary>)
Is this intended behavior?
7.3.5
CreateDataProperty(O, P, V)The abstract operation
CreateDataPropertytakes argumentsO(anObject),P(a property key), andV(an ECMAScript language value) and returns either a normal completion containing aBooleanor an abrupt completion. It is used to create a new own property of an object. It performs the following steps when called:
- Let
newDescbe thePropertyDescriptor{[[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}.- Return ?
O.[[DefineOwnProperty]](P, newDesc).This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist. If it does exist and is not configurable or if
Ois not extensible,[[DefineOwnProperty]]will returnfalse.
var a;
Object.getOwnPropertyDescriptor(globalThis, "a");
// {value: undefined, writable: true, enumerable: true, configurable: false}
I get the CreateDataProperty returning false because a non-configurable property already exists for the key; but the question is: is it expected behavior for (reference).set, which has enough force to alter the property descriptor? Isn’t it a bit a misnomer, “set?”
Is there any way to force-set the non-configurable Object.prototype and replace it with a Proxy to it? For the obfuscated code analysis purposes. I need to track down what properties it accesses.