ses 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/NEWS.md +7 -0
- package/README.md +204 -10
- package/SECURITY.md +30 -17
- package/dist/lockdown.cjs +61 -5
- package/dist/lockdown.mjs +61 -5
- package/dist/lockdown.umd.js +61 -5
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +61 -5
- package/dist/ses.mjs +61 -5
- package/dist/ses.umd.js +61 -5
- package/dist/ses.umd.min.js +1 -1
- package/index.d.ts +2 -1
- package/package.json +7 -8
- package/src/commons.js +1 -0
- package/src/lockdown-shim.js +35 -0
- package/src/tame-locale-methods.js +12 -0
- package/src/whitelist.js +6 -0
package/dist/lockdown.mjs
CHANGED
|
@@ -28,6 +28,7 @@ const {
|
|
|
28
28
|
JSON,
|
|
29
29
|
Map,
|
|
30
30
|
Math,
|
|
31
|
+
Number,
|
|
31
32
|
Object,
|
|
32
33
|
Promise,
|
|
33
34
|
Proxy,
|
|
@@ -37,7 +38,7 @@ const {
|
|
|
37
38
|
String,
|
|
38
39
|
WeakMap,
|
|
39
40
|
WeakSet } =
|
|
40
|
-
globalThis;$h_once.Array(Array);$h_once.Date(Date);$h_once.Float32Array(Float32Array);$h_once.JSON(JSON);$h_once.Map(Map);$h_once.Math(Math);$h_once.Object(Object);$h_once.Promise(Promise);$h_once.Proxy(Proxy);$h_once.Reflect(Reflect);$h_once.FERAL_REG_EXP(FERAL_REG_EXP);$h_once.Set(Set);$h_once.String(String);$h_once.WeakMap(WeakMap);$h_once.WeakSet(WeakSet);
|
|
41
|
+
globalThis;$h_once.Array(Array);$h_once.Date(Date);$h_once.Float32Array(Float32Array);$h_once.JSON(JSON);$h_once.Map(Map);$h_once.Math(Math);$h_once.Number(Number);$h_once.Object(Object);$h_once.Promise(Promise);$h_once.Proxy(Proxy);$h_once.Reflect(Reflect);$h_once.FERAL_REG_EXP(FERAL_REG_EXP);$h_once.Set(Set);$h_once.String(String);$h_once.WeakMap(WeakMap);$h_once.WeakSet(WeakSet);
|
|
41
42
|
|
|
42
43
|
const {
|
|
43
44
|
// The feral Error constructor is safe for internal use, but must not be
|
|
@@ -2733,7 +2734,10 @@ function NativeErrorPrototype(constructor) {
|
|
|
2733
2734
|
message: 'string',
|
|
2734
2735
|
name: 'string',
|
|
2735
2736
|
// Redundantly present only on v8. Safe to remove.
|
|
2736
|
-
toString: false
|
|
2737
|
+
toString: false,
|
|
2738
|
+
// Superfluously present in some versions of V8.
|
|
2739
|
+
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
|
|
2740
|
+
cause: false };
|
|
2737
2741
|
|
|
2738
2742
|
}
|
|
2739
2743
|
|
|
@@ -2997,7 +3001,10 @@ const whitelist = {
|
|
|
2997
3001
|
// Seen on FF Nightly 88.0a1
|
|
2998
3002
|
at: false,
|
|
2999
3003
|
// Seen on FF and XS
|
|
3000
|
-
stack: false
|
|
3004
|
+
stack: false,
|
|
3005
|
+
// Superfluously present in some versions of V8.
|
|
3006
|
+
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
|
|
3007
|
+
cause: false },
|
|
3001
3008
|
|
|
3002
3009
|
|
|
3003
3010
|
// NativeError
|
|
@@ -7709,7 +7716,8 @@ const tameFunctionToString = () => {
|
|
|
7709
7716
|
})
|
|
7710
7717
|
,
|
|
7711
7718
|
// === functors[35] ===
|
|
7712
|
-
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h_imports([["./commons.js", [["String", [$h_a => (String = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["getOwnPropertyNames", [$h_a => (getOwnPropertyNames = $h_a)]],["isObject", [$h_a => (isObject = $h_a)]],["regexpExec", [$h_a => (regexpExec = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]]]]]);
|
|
7719
|
+
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let Number,String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h_imports([["./commons.js", [["Number", [$h_a => (Number = $h_a)]],["String", [$h_a => (String = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["getOwnPropertyNames", [$h_a => (getOwnPropertyNames = $h_a)]],["isObject", [$h_a => (isObject = $h_a)]],["regexpExec", [$h_a => (regexpExec = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]]]]]);
|
|
7720
|
+
|
|
7713
7721
|
|
|
7714
7722
|
|
|
7715
7723
|
|
|
@@ -7743,10 +7751,15 @@ const tamedMethods = {
|
|
|
7743
7751
|
}
|
|
7744
7752
|
assert(s === that, d`expected ${q(s)} and ${q(that)} to compare`);
|
|
7745
7753
|
return 0;
|
|
7754
|
+
},
|
|
7755
|
+
|
|
7756
|
+
toString() {
|
|
7757
|
+
return `${this}`;
|
|
7746
7758
|
} };
|
|
7747
7759
|
|
|
7748
7760
|
|
|
7749
7761
|
const nonLocaleCompare = tamedMethods.localeCompare;
|
|
7762
|
+
const numberToString = tamedMethods.toString;
|
|
7750
7763
|
|
|
7751
7764
|
function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
7752
7765
|
if (localeTaming !== 'safe' && localeTaming !== 'unsafe') {
|
|
@@ -7781,6 +7794,12 @@ function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
|
7781
7794
|
}
|
|
7782
7795
|
}
|
|
7783
7796
|
}
|
|
7797
|
+
|
|
7798
|
+
// Numbers are special because toString accepts a radix instead of ignoring
|
|
7799
|
+
// all of the arguments that we would otherwise forward.
|
|
7800
|
+
defineProperty(Number.prototype, 'toLocaleString', {
|
|
7801
|
+
value: numberToString });
|
|
7802
|
+
|
|
7784
7803
|
}$h_once.default(tameLocaleMethods);
|
|
7785
7804
|
})
|
|
7786
7805
|
,
|
|
@@ -8144,7 +8163,9 @@ markVirtualizedNativeFunction)
|
|
|
8144
8163
|
})
|
|
8145
8164
|
,
|
|
8146
8165
|
// === functors[39] ===
|
|
8147
|
-
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let TypeError,arrayFilter,arrayMap,globalThis,is,ownKeys,stringSplit,enJoin,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,makeEnvironmentCaptor,getAnonymousIntrinsics,makeCompartmentConstructor;$h_imports([["./commons.js", [["TypeError", [$h_a => (TypeError = $h_a)]],["arrayFilter", [$h_a => (arrayFilter = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]],["is", [$h_a => (is = $h_a)]],["ownKeys", [$h_a => (ownKeys = $h_a)]],["stringSplit", [$h_a => (stringSplit = $h_a)]]]],["./error/stringify-utils.js", [["enJoin", [$h_a => (enJoin = $h_a)]]]],["./make-hardener.js", [["makeHardener", [$h_a => (makeHardener = $h_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h_a => (makeIntrinsicsCollector = $h_a)]]]],["./whitelist-intrinsics.js", [["default", [$h_a => (whitelistIntrinsics = $h_a)]]]],["./tame-function-constructors.js", [["default", [$h_a => (tameFunctionConstructors = $h_a)]]]],["./tame-date-constructor.js", [["default", [$h_a => (tameDateConstructor = $h_a)]]]],["./tame-math-object.js", [["default", [$h_a => (tameMathObject = $h_a)]]]],["./tame-regexp-constructor.js", [["default", [$h_a => (tameRegExpConstructor = $h_a)]]]],["./enable-property-overrides.js", [["default", [$h_a => (enablePropertyOverrides = $h_a)]]]],["./tame-locale-methods.js", [["default", [$h_a => (tameLocaleMethods = $h_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h_a => (setGlobalObjectConstantProperties = $h_a)]],["setGlobalObjectMutableProperties", [$h_a => (setGlobalObjectMutableProperties = $h_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h_a => (makeSafeEvaluator = $h_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h_a => (initialGlobalPropertyNames = $h_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h_a => (tameFunctionToString = $h_a)]]]],["./tame-domains.js", [["tameDomains", [$h_a => (tameDomains = $h_a)]]]],["./error/tame-console.js", [["tameConsole", [$h_a => (tameConsole = $h_a)]]]],["./error/tame-error-constructor.js", [["default", [$h_a => (tameErrorConstructor = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]],["makeAssert", [$h_a => (makeAssert = $h_a)]]]],["./environment-options.js", [["makeEnvironmentCaptor", [$h_a => (makeEnvironmentCaptor = $h_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h_a => (getAnonymousIntrinsics = $h_a)]]]],["./compartment-shim.js", [["makeCompartmentConstructor", [$h_a => (makeCompartmentConstructor = $h_a)]]]]]);
|
|
8166
|
+
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,arrayMap,globalThis,is,ownKeys,stringSplit,enJoin,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,makeEnvironmentCaptor,getAnonymousIntrinsics,makeCompartmentConstructor;$h_imports([["./commons.js", [["FERAL_FUNCTION", [$h_a => (FERAL_FUNCTION = $h_a)]],["FERAL_EVAL", [$h_a => (FERAL_EVAL = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["arrayFilter", [$h_a => (arrayFilter = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]],["is", [$h_a => (is = $h_a)]],["ownKeys", [$h_a => (ownKeys = $h_a)]],["stringSplit", [$h_a => (stringSplit = $h_a)]]]],["./error/stringify-utils.js", [["enJoin", [$h_a => (enJoin = $h_a)]]]],["./make-hardener.js", [["makeHardener", [$h_a => (makeHardener = $h_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h_a => (makeIntrinsicsCollector = $h_a)]]]],["./whitelist-intrinsics.js", [["default", [$h_a => (whitelistIntrinsics = $h_a)]]]],["./tame-function-constructors.js", [["default", [$h_a => (tameFunctionConstructors = $h_a)]]]],["./tame-date-constructor.js", [["default", [$h_a => (tameDateConstructor = $h_a)]]]],["./tame-math-object.js", [["default", [$h_a => (tameMathObject = $h_a)]]]],["./tame-regexp-constructor.js", [["default", [$h_a => (tameRegExpConstructor = $h_a)]]]],["./enable-property-overrides.js", [["default", [$h_a => (enablePropertyOverrides = $h_a)]]]],["./tame-locale-methods.js", [["default", [$h_a => (tameLocaleMethods = $h_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h_a => (setGlobalObjectConstantProperties = $h_a)]],["setGlobalObjectMutableProperties", [$h_a => (setGlobalObjectMutableProperties = $h_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h_a => (makeSafeEvaluator = $h_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h_a => (initialGlobalPropertyNames = $h_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h_a => (tameFunctionToString = $h_a)]]]],["./tame-domains.js", [["tameDomains", [$h_a => (tameDomains = $h_a)]]]],["./error/tame-console.js", [["tameConsole", [$h_a => (tameConsole = $h_a)]]]],["./error/tame-error-constructor.js", [["default", [$h_a => (tameErrorConstructor = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]],["makeAssert", [$h_a => (makeAssert = $h_a)]]]],["./environment-options.js", [["makeEnvironmentCaptor", [$h_a => (makeEnvironmentCaptor = $h_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h_a => (getAnonymousIntrinsics = $h_a)]]]],["./compartment-shim.js", [["makeCompartmentConstructor", [$h_a => (makeCompartmentConstructor = $h_a)]]]]]);
|
|
8167
|
+
|
|
8168
|
+
|
|
8148
8169
|
|
|
8149
8170
|
|
|
8150
8171
|
|
|
@@ -8233,6 +8254,37 @@ const harden = makeHardener();
|
|
|
8233
8254
|
// only ever need to be called once and that simplifying lockdown will improve
|
|
8234
8255
|
// the quality of audits.
|
|
8235
8256
|
|
|
8257
|
+
const assertDirectEvalAvailable = () => {
|
|
8258
|
+
let allowed = false;
|
|
8259
|
+
try {
|
|
8260
|
+
allowed = FERAL_FUNCTION(
|
|
8261
|
+
'eval',
|
|
8262
|
+
'SES_changed',
|
|
8263
|
+
`\
|
|
8264
|
+
eval("SES_changed = true");
|
|
8265
|
+
return SES_changed;
|
|
8266
|
+
`)(
|
|
8267
|
+
FERAL_EVAL, false);
|
|
8268
|
+
// If we get here and SES_changed stayed false, that means the eval was sloppy
|
|
8269
|
+
// and indirect, which generally creates a new global.
|
|
8270
|
+
// We are going to throw an exception for failing to initialize SES, but
|
|
8271
|
+
// good neighbors clean up.
|
|
8272
|
+
if (!allowed) {
|
|
8273
|
+
delete globalThis.SES_changed;
|
|
8274
|
+
}
|
|
8275
|
+
} catch (_error) {
|
|
8276
|
+
// We reach here if eval is outright forbidden by a Content Security Policy.
|
|
8277
|
+
// We allow this for SES usage that delegates the responsibility to isolate
|
|
8278
|
+
// guest code to production code generation.
|
|
8279
|
+
allowed = true;
|
|
8280
|
+
}
|
|
8281
|
+
if (!allowed) {
|
|
8282
|
+
throw new TypeError(
|
|
8283
|
+
`SES cannot initialize unless 'eval' is the original intrinsic 'eval', suitable for direct-eval (dynamically scoped eval) (SES_DIRECT_EVAL)`);
|
|
8284
|
+
|
|
8285
|
+
}
|
|
8286
|
+
};
|
|
8287
|
+
|
|
8236
8288
|
/**
|
|
8237
8289
|
* @param {LockdownOptions} [options]
|
|
8238
8290
|
* @returns {() => void} repairIntrinsics
|
|
@@ -8320,6 +8372,8 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8320
8372
|
// trace retained:
|
|
8321
8373
|
priorLockdown.stack;
|
|
8322
8374
|
|
|
8375
|
+
assertDirectEvalAvailable();
|
|
8376
|
+
|
|
8323
8377
|
/**
|
|
8324
8378
|
* Because of packagers and bundlers, etc, multiple invocations of lockdown
|
|
8325
8379
|
* might happen in separate instantiations of the source of this module.
|
|
@@ -8563,6 +8617,7 @@ assign(globalThis, {
|
|
|
8563
8617
|
JSON: cell("JSON"),
|
|
8564
8618
|
Map: cell("Map"),
|
|
8565
8619
|
Math: cell("Math"),
|
|
8620
|
+
Number: cell("Number"),
|
|
8566
8621
|
Object: cell("Object"),
|
|
8567
8622
|
Promise: cell("Promise"),
|
|
8568
8623
|
Proxy: cell("Proxy"),
|
|
@@ -8862,6 +8917,7 @@ assign(globalThis, {
|
|
|
8862
8917
|
JSON: cells[0].JSON.set,
|
|
8863
8918
|
Map: cells[0].Map.set,
|
|
8864
8919
|
Math: cells[0].Math.set,
|
|
8920
|
+
Number: cells[0].Number.set,
|
|
8865
8921
|
Object: cells[0].Object.set,
|
|
8866
8922
|
Promise: cells[0].Promise.set,
|
|
8867
8923
|
Proxy: cells[0].Proxy.set,
|
package/dist/lockdown.umd.js
CHANGED
|
@@ -28,6 +28,7 @@ const {
|
|
|
28
28
|
JSON,
|
|
29
29
|
Map,
|
|
30
30
|
Math,
|
|
31
|
+
Number,
|
|
31
32
|
Object,
|
|
32
33
|
Promise,
|
|
33
34
|
Proxy,
|
|
@@ -37,7 +38,7 @@ const {
|
|
|
37
38
|
String,
|
|
38
39
|
WeakMap,
|
|
39
40
|
WeakSet } =
|
|
40
|
-
globalThis;$h_once.Array(Array);$h_once.Date(Date);$h_once.Float32Array(Float32Array);$h_once.JSON(JSON);$h_once.Map(Map);$h_once.Math(Math);$h_once.Object(Object);$h_once.Promise(Promise);$h_once.Proxy(Proxy);$h_once.Reflect(Reflect);$h_once.FERAL_REG_EXP(FERAL_REG_EXP);$h_once.Set(Set);$h_once.String(String);$h_once.WeakMap(WeakMap);$h_once.WeakSet(WeakSet);
|
|
41
|
+
globalThis;$h_once.Array(Array);$h_once.Date(Date);$h_once.Float32Array(Float32Array);$h_once.JSON(JSON);$h_once.Map(Map);$h_once.Math(Math);$h_once.Number(Number);$h_once.Object(Object);$h_once.Promise(Promise);$h_once.Proxy(Proxy);$h_once.Reflect(Reflect);$h_once.FERAL_REG_EXP(FERAL_REG_EXP);$h_once.Set(Set);$h_once.String(String);$h_once.WeakMap(WeakMap);$h_once.WeakSet(WeakSet);
|
|
41
42
|
|
|
42
43
|
const {
|
|
43
44
|
// The feral Error constructor is safe for internal use, but must not be
|
|
@@ -2733,7 +2734,10 @@ function NativeErrorPrototype(constructor) {
|
|
|
2733
2734
|
message: 'string',
|
|
2734
2735
|
name: 'string',
|
|
2735
2736
|
// Redundantly present only on v8. Safe to remove.
|
|
2736
|
-
toString: false
|
|
2737
|
+
toString: false,
|
|
2738
|
+
// Superfluously present in some versions of V8.
|
|
2739
|
+
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
|
|
2740
|
+
cause: false };
|
|
2737
2741
|
|
|
2738
2742
|
}
|
|
2739
2743
|
|
|
@@ -2997,7 +3001,10 @@ const whitelist = {
|
|
|
2997
3001
|
// Seen on FF Nightly 88.0a1
|
|
2998
3002
|
at: false,
|
|
2999
3003
|
// Seen on FF and XS
|
|
3000
|
-
stack: false
|
|
3004
|
+
stack: false,
|
|
3005
|
+
// Superfluously present in some versions of V8.
|
|
3006
|
+
// https://github.com/tc39/notes/blob/master/meetings/2021-10/oct-26.md#:~:text=However%2C%20Chrome%2093,and%20node%2016.11.
|
|
3007
|
+
cause: false },
|
|
3001
3008
|
|
|
3002
3009
|
|
|
3003
3010
|
// NativeError
|
|
@@ -7709,7 +7716,8 @@ const tameFunctionToString = () => {
|
|
|
7709
7716
|
})
|
|
7710
7717
|
,
|
|
7711
7718
|
// === functors[35] ===
|
|
7712
|
-
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h_imports([["./commons.js", [["String", [$h_a => (String = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["getOwnPropertyNames", [$h_a => (getOwnPropertyNames = $h_a)]],["isObject", [$h_a => (isObject = $h_a)]],["regexpExec", [$h_a => (regexpExec = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]]]]]);
|
|
7719
|
+
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let Number,String,TypeError,defineProperty,getOwnPropertyNames,isObject,regexpExec,assert;$h_imports([["./commons.js", [["Number", [$h_a => (Number = $h_a)]],["String", [$h_a => (String = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["defineProperty", [$h_a => (defineProperty = $h_a)]],["getOwnPropertyNames", [$h_a => (getOwnPropertyNames = $h_a)]],["isObject", [$h_a => (isObject = $h_a)]],["regexpExec", [$h_a => (regexpExec = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]]]]]);
|
|
7720
|
+
|
|
7713
7721
|
|
|
7714
7722
|
|
|
7715
7723
|
|
|
@@ -7743,10 +7751,15 @@ const tamedMethods = {
|
|
|
7743
7751
|
}
|
|
7744
7752
|
assert(s === that, d`expected ${q(s)} and ${q(that)} to compare`);
|
|
7745
7753
|
return 0;
|
|
7754
|
+
},
|
|
7755
|
+
|
|
7756
|
+
toString() {
|
|
7757
|
+
return `${this}`;
|
|
7746
7758
|
} };
|
|
7747
7759
|
|
|
7748
7760
|
|
|
7749
7761
|
const nonLocaleCompare = tamedMethods.localeCompare;
|
|
7762
|
+
const numberToString = tamedMethods.toString;
|
|
7750
7763
|
|
|
7751
7764
|
function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
7752
7765
|
if (localeTaming !== 'safe' && localeTaming !== 'unsafe') {
|
|
@@ -7781,6 +7794,12 @@ function tameLocaleMethods(intrinsics, localeTaming = 'safe') {
|
|
|
7781
7794
|
}
|
|
7782
7795
|
}
|
|
7783
7796
|
}
|
|
7797
|
+
|
|
7798
|
+
// Numbers are special because toString accepts a radix instead of ignoring
|
|
7799
|
+
// all of the arguments that we would otherwise forward.
|
|
7800
|
+
defineProperty(Number.prototype, 'toLocaleString', {
|
|
7801
|
+
value: numberToString });
|
|
7802
|
+
|
|
7784
7803
|
}$h_once.default(tameLocaleMethods);
|
|
7785
7804
|
})
|
|
7786
7805
|
,
|
|
@@ -8144,7 +8163,9 @@ markVirtualizedNativeFunction)
|
|
|
8144
8163
|
})
|
|
8145
8164
|
,
|
|
8146
8165
|
// === functors[39] ===
|
|
8147
|
-
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let TypeError,arrayFilter,arrayMap,globalThis,is,ownKeys,stringSplit,enJoin,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,makeEnvironmentCaptor,getAnonymousIntrinsics,makeCompartmentConstructor;$h_imports([["./commons.js", [["TypeError", [$h_a => (TypeError = $h_a)]],["arrayFilter", [$h_a => (arrayFilter = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]],["is", [$h_a => (is = $h_a)]],["ownKeys", [$h_a => (ownKeys = $h_a)]],["stringSplit", [$h_a => (stringSplit = $h_a)]]]],["./error/stringify-utils.js", [["enJoin", [$h_a => (enJoin = $h_a)]]]],["./make-hardener.js", [["makeHardener", [$h_a => (makeHardener = $h_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h_a => (makeIntrinsicsCollector = $h_a)]]]],["./whitelist-intrinsics.js", [["default", [$h_a => (whitelistIntrinsics = $h_a)]]]],["./tame-function-constructors.js", [["default", [$h_a => (tameFunctionConstructors = $h_a)]]]],["./tame-date-constructor.js", [["default", [$h_a => (tameDateConstructor = $h_a)]]]],["./tame-math-object.js", [["default", [$h_a => (tameMathObject = $h_a)]]]],["./tame-regexp-constructor.js", [["default", [$h_a => (tameRegExpConstructor = $h_a)]]]],["./enable-property-overrides.js", [["default", [$h_a => (enablePropertyOverrides = $h_a)]]]],["./tame-locale-methods.js", [["default", [$h_a => (tameLocaleMethods = $h_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h_a => (setGlobalObjectConstantProperties = $h_a)]],["setGlobalObjectMutableProperties", [$h_a => (setGlobalObjectMutableProperties = $h_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h_a => (makeSafeEvaluator = $h_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h_a => (initialGlobalPropertyNames = $h_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h_a => (tameFunctionToString = $h_a)]]]],["./tame-domains.js", [["tameDomains", [$h_a => (tameDomains = $h_a)]]]],["./error/tame-console.js", [["tameConsole", [$h_a => (tameConsole = $h_a)]]]],["./error/tame-error-constructor.js", [["default", [$h_a => (tameErrorConstructor = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]],["makeAssert", [$h_a => (makeAssert = $h_a)]]]],["./environment-options.js", [["makeEnvironmentCaptor", [$h_a => (makeEnvironmentCaptor = $h_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h_a => (getAnonymousIntrinsics = $h_a)]]]],["./compartment-shim.js", [["makeCompartmentConstructor", [$h_a => (makeCompartmentConstructor = $h_a)]]]]]);
|
|
8166
|
+
(({ imports: $h_imports, liveVar: $h_live, onceVar: $h_once, }) => { let FERAL_FUNCTION,FERAL_EVAL,TypeError,arrayFilter,arrayMap,globalThis,is,ownKeys,stringSplit,enJoin,makeHardener,makeIntrinsicsCollector,whitelistIntrinsics,tameFunctionConstructors,tameDateConstructor,tameMathObject,tameRegExpConstructor,enablePropertyOverrides,tameLocaleMethods,setGlobalObjectConstantProperties,setGlobalObjectMutableProperties,makeSafeEvaluator,initialGlobalPropertyNames,tameFunctionToString,tameDomains,tameConsole,tameErrorConstructor,assert,makeAssert,makeEnvironmentCaptor,getAnonymousIntrinsics,makeCompartmentConstructor;$h_imports([["./commons.js", [["FERAL_FUNCTION", [$h_a => (FERAL_FUNCTION = $h_a)]],["FERAL_EVAL", [$h_a => (FERAL_EVAL = $h_a)]],["TypeError", [$h_a => (TypeError = $h_a)]],["arrayFilter", [$h_a => (arrayFilter = $h_a)]],["arrayMap", [$h_a => (arrayMap = $h_a)]],["globalThis", [$h_a => (globalThis = $h_a)]],["is", [$h_a => (is = $h_a)]],["ownKeys", [$h_a => (ownKeys = $h_a)]],["stringSplit", [$h_a => (stringSplit = $h_a)]]]],["./error/stringify-utils.js", [["enJoin", [$h_a => (enJoin = $h_a)]]]],["./make-hardener.js", [["makeHardener", [$h_a => (makeHardener = $h_a)]]]],["./intrinsics.js", [["makeIntrinsicsCollector", [$h_a => (makeIntrinsicsCollector = $h_a)]]]],["./whitelist-intrinsics.js", [["default", [$h_a => (whitelistIntrinsics = $h_a)]]]],["./tame-function-constructors.js", [["default", [$h_a => (tameFunctionConstructors = $h_a)]]]],["./tame-date-constructor.js", [["default", [$h_a => (tameDateConstructor = $h_a)]]]],["./tame-math-object.js", [["default", [$h_a => (tameMathObject = $h_a)]]]],["./tame-regexp-constructor.js", [["default", [$h_a => (tameRegExpConstructor = $h_a)]]]],["./enable-property-overrides.js", [["default", [$h_a => (enablePropertyOverrides = $h_a)]]]],["./tame-locale-methods.js", [["default", [$h_a => (tameLocaleMethods = $h_a)]]]],["./global-object.js", [["setGlobalObjectConstantProperties", [$h_a => (setGlobalObjectConstantProperties = $h_a)]],["setGlobalObjectMutableProperties", [$h_a => (setGlobalObjectMutableProperties = $h_a)]]]],["./make-safe-evaluator.js", [["makeSafeEvaluator", [$h_a => (makeSafeEvaluator = $h_a)]]]],["./whitelist.js", [["initialGlobalPropertyNames", [$h_a => (initialGlobalPropertyNames = $h_a)]]]],["./tame-function-tostring.js", [["tameFunctionToString", [$h_a => (tameFunctionToString = $h_a)]]]],["./tame-domains.js", [["tameDomains", [$h_a => (tameDomains = $h_a)]]]],["./error/tame-console.js", [["tameConsole", [$h_a => (tameConsole = $h_a)]]]],["./error/tame-error-constructor.js", [["default", [$h_a => (tameErrorConstructor = $h_a)]]]],["./error/assert.js", [["assert", [$h_a => (assert = $h_a)]],["makeAssert", [$h_a => (makeAssert = $h_a)]]]],["./environment-options.js", [["makeEnvironmentCaptor", [$h_a => (makeEnvironmentCaptor = $h_a)]]]],["./get-anonymous-intrinsics.js", [["getAnonymousIntrinsics", [$h_a => (getAnonymousIntrinsics = $h_a)]]]],["./compartment-shim.js", [["makeCompartmentConstructor", [$h_a => (makeCompartmentConstructor = $h_a)]]]]]);
|
|
8167
|
+
|
|
8168
|
+
|
|
8148
8169
|
|
|
8149
8170
|
|
|
8150
8171
|
|
|
@@ -8233,6 +8254,37 @@ const harden = makeHardener();
|
|
|
8233
8254
|
// only ever need to be called once and that simplifying lockdown will improve
|
|
8234
8255
|
// the quality of audits.
|
|
8235
8256
|
|
|
8257
|
+
const assertDirectEvalAvailable = () => {
|
|
8258
|
+
let allowed = false;
|
|
8259
|
+
try {
|
|
8260
|
+
allowed = FERAL_FUNCTION(
|
|
8261
|
+
'eval',
|
|
8262
|
+
'SES_changed',
|
|
8263
|
+
`\
|
|
8264
|
+
eval("SES_changed = true");
|
|
8265
|
+
return SES_changed;
|
|
8266
|
+
`)(
|
|
8267
|
+
FERAL_EVAL, false);
|
|
8268
|
+
// If we get here and SES_changed stayed false, that means the eval was sloppy
|
|
8269
|
+
// and indirect, which generally creates a new global.
|
|
8270
|
+
// We are going to throw an exception for failing to initialize SES, but
|
|
8271
|
+
// good neighbors clean up.
|
|
8272
|
+
if (!allowed) {
|
|
8273
|
+
delete globalThis.SES_changed;
|
|
8274
|
+
}
|
|
8275
|
+
} catch (_error) {
|
|
8276
|
+
// We reach here if eval is outright forbidden by a Content Security Policy.
|
|
8277
|
+
// We allow this for SES usage that delegates the responsibility to isolate
|
|
8278
|
+
// guest code to production code generation.
|
|
8279
|
+
allowed = true;
|
|
8280
|
+
}
|
|
8281
|
+
if (!allowed) {
|
|
8282
|
+
throw new TypeError(
|
|
8283
|
+
`SES cannot initialize unless 'eval' is the original intrinsic 'eval', suitable for direct-eval (dynamically scoped eval) (SES_DIRECT_EVAL)`);
|
|
8284
|
+
|
|
8285
|
+
}
|
|
8286
|
+
};
|
|
8287
|
+
|
|
8236
8288
|
/**
|
|
8237
8289
|
* @param {LockdownOptions} [options]
|
|
8238
8290
|
* @returns {() => void} repairIntrinsics
|
|
@@ -8320,6 +8372,8 @@ const repairIntrinsics = (options = {}) => {
|
|
|
8320
8372
|
// trace retained:
|
|
8321
8373
|
priorLockdown.stack;
|
|
8322
8374
|
|
|
8375
|
+
assertDirectEvalAvailable();
|
|
8376
|
+
|
|
8323
8377
|
/**
|
|
8324
8378
|
* Because of packagers and bundlers, etc, multiple invocations of lockdown
|
|
8325
8379
|
* might happen in separate instantiations of the source of this module.
|
|
@@ -8563,6 +8617,7 @@ assign(globalThis, {
|
|
|
8563
8617
|
JSON: cell("JSON"),
|
|
8564
8618
|
Map: cell("Map"),
|
|
8565
8619
|
Math: cell("Math"),
|
|
8620
|
+
Number: cell("Number"),
|
|
8566
8621
|
Object: cell("Object"),
|
|
8567
8622
|
Promise: cell("Promise"),
|
|
8568
8623
|
Proxy: cell("Proxy"),
|
|
@@ -8862,6 +8917,7 @@ assign(globalThis, {
|
|
|
8862
8917
|
JSON: cells[0].JSON.set,
|
|
8863
8918
|
Map: cells[0].Map.set,
|
|
8864
8919
|
Math: cells[0].Math.set,
|
|
8920
|
+
Number: cells[0].Number.set,
|
|
8865
8921
|
Object: cells[0].Object.set,
|
|
8866
8922
|
Promise: cells[0].Promise.set,
|
|
8867
8923
|
Proxy: cells[0].Proxy.set,
|