Skip to content

Commit

Permalink
refactor(ses): one shot hardening of intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Jan 9, 2024
1 parent 849725e commit e13cda6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/ses/src/lockdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,27 @@ export const repairIntrinsics = (options = {}) => {

// Finally register and optionally freeze all the intrinsics. This
// must be the operation that modifies the intrinsics.
tamedHarden(intrinsics);

// Harden evaluators
tamedHarden(globalThis.Function);
tamedHarden(globalThis.eval);
// @ts-ignore Compartment does exist on globalThis
tamedHarden(globalThis.Compartment);
const toHarden = {
intrinsics,
globals: {
// Harden evaluators
Function: globalThis.Function,
eval: globalThis.eval,
// @ts-ignore Compartment does exist on globalThis
Compartment: globalThis.Compartment,

// Harden Symbol
Symbol: globalThis.Symbol,
},
};

// Harden Symbol and properties for initialGlobalPropertyNames in the host realm
tamedHarden(globalThis.Symbol);
for (const prop of getOwnPropertyNames(initialGlobalPropertyNames)) {
tamedHarden(globalThis[prop]);
toHarden.globals[prop] = globalThis[prop];
}

tamedHarden(toHarden);

return tamedHarden;
};

Expand Down

0 comments on commit e13cda6

Please sign in to comment.