ses 1.7.0 → 1.9.0

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/NEWS.md DELETED
@@ -1,983 +0,0 @@
1
- User-visible changes in `ses`:
2
-
3
- # v1.6.0 (2024-07-30)
4
-
5
- - *NOTICE*: This version introduces multiple features to converge upon a
6
- more common standard for [Hardened JavaScript](https://hardenedjs.org).
7
- All code should begin migrating to these usage patterns as the older
8
- patterns are now deprecated and will not be supported in a future major
9
- version of SES.
10
-
11
- - To converge on a portable pattern for using `Compartment`, introduces an
12
- `__options__` property for the first argument of the `Compartment`
13
- constructor that must be `true` if present and indicates the object is the
14
- options bag and not the global endowments. All code going forward should
15
- include this flag until the next major version of SES, when we plan for it to
16
- become vesgitial and drop support for three-argument `Compartment`
17
- construction.
18
-
19
- In the unlikely event that existing code names an endowment `__options__`,
20
- that code will break and need to be adjusted to adopt this version.
21
- Because we rate this unlikely, we have elected not to mark this with
22
- a major version bump.
23
-
24
- - Adds a `__noNamespaceBox__` option that aligns the behavior of the `import`
25
- method on SES `Compartment` with the behavior of XS and the behavior we will
26
- champion for compartment standards.
27
- All use of `Compartment` should migrate to use this option as the standard
28
- behavior will be enabled by default with the next major version of SES.
29
-
30
- - Adds support for module descriptors better aligned with XS.
31
- Compartments use module desriptors to load and link modules.
32
- The importHook, importNowHook, and moduleMapHook all return module descriptors
33
- (sometimes promises for module descriptors).
34
- The modules option or argument to the Compatment constructor has module
35
- descriptors for all its values.
36
- - `{record, specifier, compartment}` should become `{source: record,
37
- specifier, compartment}`.
38
- - `{specifier, compartment}` should become `{source: specifier,
39
- compartment}`.
40
- - `{record: compartment.module(specifier)}` should become `{namespace:
41
- specifier, compartment}`.
42
-
43
- - When running transpiled code on Node, the SES error taming
44
- gives line-numbers into the generated JavaScript, which often don't match the
45
- the original lines. This happens even with the normal development-time
46
- lockdown options setting,
47
- ```js
48
- errorTaming: 'unsafe'
49
- ```
50
- or setting the environment variable
51
- ```sh
52
- $ export LOCKDOWN_ERROR_TAMING=unsafe
53
- ```
54
- To get the original line numbers, this release
55
- adds `'unsafe-debug'`. This `errorTaming: 'unsafe-debug'` setting
56
- should be used ***during development only*** when you can
57
- sacrifice more security for a better debugging experience, as explained at
58
- [`errorTaming` Options](https://github.com/endojs/endo/blob/master/packages/ses/docs/lockdown.md#errortaming-options).
59
- With this setting, when running transpiled code on Node (e.g. tests written
60
- in TypeScript),
61
- the stacktrace line-numbers point back into the original
62
- source, as they do on Node without SES.
63
-
64
- # v1.5.0 (2024-05-06)
65
-
66
- - Adds `importNowHook` to the `Compartment` options. The compartment will invoke the hook whenever it encounters a missing dependency while running `compartmentInstance.importNow(specifier)`, which cannot use an asynchronous `importHook`.
67
- - To support TypeScript v5.5, a CommonJS-specific type declaration file is now explicitly exported.
68
-
69
- # v1.3.0 (2024-02-22)
70
-
71
- - Now supports `Promise.any`, `AggegateError`, `error.errors`,
72
- and `error.cause`.
73
- - Assertion functions/methods that were parameterized by an error constructor
74
- (`makeError`, `assert`, `assert.fail`, `assert.equal`) now also accept named
75
- options `cause` and `errors` in their immediately succeeding
76
- `options` argument.
77
- - For all those, the error constructor can now be an `AggregateError`.
78
- If they do make an error instance, they encapsulate the
79
- non-uniformity of the `AggregateError` construction arguments, allowing
80
- all the error constructors to be used polymorphically
81
- (generic / interchangeable).
82
- - Adds a `GenericErrorConstructor` type to be effectively the common supertype
83
- of `ErrorConstructor` and `AggregateErrorConstructor`, for typing these
84
- error constructor parameters that handle the error constructor
85
- polymorphically.
86
- - The SES `console` now includes `error.cause` and `error.errors` in
87
- its diagnostic output for errors.
88
-
89
- # v1.2.0 (2024-02-14)
90
-
91
- - Exports `ses/lockdown-shim.js`, `ses/compartment-shim.js`, and
92
- `ses/assert-shim.js` for piecemeal usage.
93
- This change is motivated by the need to omit `ses/assert-shim.js` in Test262
94
- environments.
95
-
96
- # v1.1.0 (2024-01-17)
97
-
98
- - The [iterators-helpers](https://github.com/tc39/proposal-iterator-helpers)
99
- proposal includes two accessor properties whose purpose is to emulate
100
- a data property, but without the override mistake problem. The ses-shim
101
- creates many such properties, but was unprepared for them to already be
102
- present in the JS platform it starts with. Chrome Canary and Node 22
103
- both implement the iterators-helper proposal, triggering this bug, preventing
104
- the ses-shim from initializing. The ses-shim
105
- [now copes safely](https://github.com/endojs/endo/pull/1969) with an
106
- enumerated set of such properties, starting with these two properties from
107
- the iterators-helpers proposal.
108
- - The ses-shim now permits the new methods from the
109
- [set-methods](https://github.com/tc39/proposal-set-methods) proposal,
110
- enabling these methods to be used on platforms where they are implemented,
111
- which are currently a Chrome Canary and a Node 22.
112
-
113
- # v0.18.8 (2023-09-11)
114
-
115
- - Extracts `repairIntrinsics(options)` and `hardenIntrinsics()` from the
116
- behavior of `lockdown(options)` so vetted shims can run between these
117
- calls.
118
- Any modifications to shared intrinsics survive if applied after
119
- `repairIntrinsics()`.
120
- - In the SES-shim implementation of HardenedJS, all constructed compartments
121
- get the same safe `Date` constructor, that does not provide the ability to
122
- measure duration.
123
- It used to do this by having `Date.now()` return `NaN`, and to have calls on
124
- the constructor that would normally have returned an indication of the
125
- current date, instead return the corresponding invalid date indication.
126
- Now, all of these throw a `TypeError` whose message begins with `'secure
127
- mode'`.
128
- This aligns with the XS implementation of HardenedJS.
129
- - Similarly, In the SES-shim implementation of HardenedJS, all constructed
130
- compartments get the same safe `Math` namespace object that does not provide
131
- a working `random()` function.
132
- It used to do that by omitting the `random` property from the safe `Math`
133
- namespace object.
134
- Now, the safe shared `Math` namespace object has a `Math.random()` function
135
- that throws a `TypeError whose message begins with `'secure mode'`.
136
- This again aligns with the XS implementation of HardenedJS.
137
-
138
- # v0.18.6 (2023-08-07)
139
-
140
- - Censors the pattern `{...import(specifier)}`.
141
- We previously censored `import(specifier)` and expressly allowed
142
- `object.import(specifier)`.
143
- The relaxation for the latter form in version 0.13.0 inadvertently allowed
144
- import with the spread operator.
145
-
146
- # v0.18.5 (2023-07-14)
147
-
148
- - Adds `assert.bare` for embedding unquoted strings in details.
149
- - Permits new `dispose` symbols, other recent additions to JavaScript, and for
150
- the anticipated iterator helpers.
151
- - Tames `Symbol` so symbols can be preserved in the start compartment and
152
- denied to shared compartments.
153
- - Improves debugging in Safari.
154
- - Adds missing native function markers.
155
- All native functions should have a `toString` that says `[native code]`, even
156
- if emulated.
157
-
158
- # v0.18.4 (2023-04-20)
159
-
160
- - Pass through the start compartment's `globalThis.harden` if defined.
161
-
162
- # v0.18.3 (2023-04-14)
163
-
164
- - New `__hardenTaming__: 'unsafe'` lockdown option to fake harden unsafely,
165
- which can be used to improve performance for applications that are known to be
166
- safe even with a no-op `harden`.
167
- - Finite deep stacks, using LRU budgets for depth of stacks an well as the
168
- maximum number of weakly-held errors to annotate.
169
- - Add `%AsyncGenerator%.length` and `%AsyncFunctionPrototype%.length` `number`
170
- properties to allowlist.
171
-
172
- # v0.18.2 (2023-03-07)
173
-
174
- - Introduces the `__syncModuleFunctor__` property of static module record
175
- to replace evauluation of `__syncModuleProgram__` for environments without eval.
176
-
177
- # v0.18.1 (2022-12-23)
178
-
179
- - Fixes a bug for SES initialization in a no-unsafe-eval
180
- Content-Security-Policy.
181
- - Fixes a bug where reexport of multiple named exports of the same name was
182
- causing them to be overridden by the last value. Now named exports are
183
- handled in the same manner as `export *`.
184
- - Allows Compatment `importHook` implementations to return aliases: module
185
- descriptors that refer to a module by its specifier in the same or a
186
- specified compartment, without providing a static module record (module
187
- source).
188
-
189
- # v0.18.0 (2022-11-14)
190
-
191
- - *BREAKING*: Removes support for `globalLexicals`.
192
- To our knowledge, there are no production uses for `globalLexicals`.
193
- They currently could leak because `moduleLexicals` and `globalLexicals`
194
- used the same scope object, so properties of one would leak to the other
195
- with crafted modules.
196
- We had an opportunity to plug the leak at the cost of a fifth scope
197
- in all evaluators, but elected to remove the unnecessary complexity instead.
198
-
199
- # v0.17.0 (2022-10-24)
200
-
201
- - Previous versions of SES would leak the proxy used to isolate evaluated
202
- code to functions added to the global object by guest code.
203
- The value of `this` in such functions should be `undefined`, but that is not
204
- possible to emulate in this shim.
205
- This version changes the value of `this` in such functions to be the same as
206
- `globalThis` of the compartment, as would be correct in sloppy mode.
207
- - Removes experimental support for "known scope proxies".
208
-
209
- # v0.16.0 (2022-10-19)
210
-
211
- - When hardening a typed array, detects and locks down properties named as
212
- number-coercible strings that are not index properties.
213
-
214
- # v0.15.23 (2022-09-27)
215
-
216
- - Fixes the unhandled promise rejection logic to report unhandled rejections
217
- when the promise is collected. Because of a bug it previously only reported
218
- at process exit.
219
- - Improves the fidelity of emulation for V8 `Error.prepareStackTrace`,
220
- allowing more legacy code to work by default in isolation.
221
-
222
- # v0.15.18 (2022-08-23)
223
-
224
- - Removes the `__allowUnsafeMonkeyPatching__` option to lockdown. As the name
225
- should indicate, this was always an unsafe temporary kludge. Its only known
226
- use was in agoric-sdk, now gone at
227
- https://github.com/Agoric/agoric-sdk/pull/5922 . Without this option, a
228
- successful `lockdown` will now always harden the primordials.
229
-
230
- # v0.15.8 (2022-02-18)
231
-
232
- - Harden now gives special treatment to typed arrays.
233
- Instead of freezing a typed array, harden will seal it and make all of its
234
- non-integer properties non-writable.
235
- All of their integer properties will remain writable and non-configurable.
236
- TypedArrays are exceedingly unusual because their integer properties are
237
- writable and neither freeze nor defineProperty can convert them from writable
238
- to non-writable.
239
-
240
- # v0.15.3 (2022-01-21)
241
-
242
- - Fixes the type definition for assert.error so that the final options bag,
243
- which may include `errorName`, checks correctly in TypeScript.
244
- - Lockdown will now throw an error if code running before SES initialization
245
- replaced `eval`.
246
-
247
- # 0.15.2 (2021-12-08)
248
-
249
- - The `Removing...` messages that Lockdown emits when encountering unrecognized
250
- properties on shared intrinsics are now logged as "warnings".
251
- This has the material benefit of sending these messages to STDERR on Node.js.
252
- - Updates permits for all current TC39 stage 3 and 4 proposals, notably
253
- suppressing the `Removing...` messages for `Object.hasOwn`; `findLast` and
254
- `findLastIndex` on both `Array.prototype` and `TypedArray.prototype`; and the
255
- properties `transfer`, `resize`, `resizable`, and `maxByteLength` of
256
- `ArrayBuffer.prototype`.
257
-
258
- # 0.15.1 (2021-11-15)
259
-
260
- - The TypeScript definition of `lockdown` now allows for the option
261
- `"errorTrapping": "none"`.
262
- - Fixes error trapping on the web, showing both the message (and stack) of any
263
- error that throws out of the top of an event.
264
-
265
- # 0.15.0 (2021-11-02)
266
-
267
- - _BREAKING CHANGE_: The lockdown option `domainTaming` is now `safe` by
268
- default, which will break any application that depends transtively on the
269
- Node.js `domain` module.
270
- Notably, [standard-things/esm](https://github.com/standard-things/esm)
271
- uses domains and so SES will not support `node -r esm` going forward.
272
-
273
- This protects against the unhardened `domain` property appearing on shared
274
- objects like callbacks and promises.
275
- This overcomes the last _known_ obstacle toward object capability containment.
276
-
277
- - Lockdown will now read options from the environment as defined by the Node.js
278
- `process.env` parameter space.
279
- - _BREAKING CHANGE_: Lockdown may no longer be called more than once.
280
- Lockdown no longer returns a boolean to indicate whether it was effective
281
- (true) or redundant (false). Instead, Lockdown will return undefined for
282
- its first invocation or throw an error otherwise.
283
-
284
- # 0.14.4 (2021-10-14)
285
-
286
- - Fixes a defect in the per-compartment `Function` and `eval` functions, such
287
- that these environments did not have the compartment's `globalLexicals`.
288
- There is no known environment depending on this invariant for security
289
- reasons, but such a scenario would be a program arranging a translator that
290
- introduces run-time security checks, like metering, that depend on the
291
- existence of a named global lexical.
292
- [#898](https://github.com/endojs/endo/issues/898)
293
- - The above fix incidentally improved the performance of compartment evaluation
294
- for cases that do not require special global lexicals, by sharing a single
295
- per-compartment evaluator.
296
-
297
- # 0.14.3 (2021-09-18)
298
-
299
- - Due to a peculiar bit of error handling code in Node 14, as explained at
300
- [Hardened JavaScript interferes with Node.js 14 Error
301
- construction](https://github.com/endojs/endo/issues/868),
302
- we have added more overrides to the default `overrideTaming: 'moderate'`
303
- setting. At this setting, assigning to the `name` property of a mutable error
304
- instance should work. It will continue not to work at the `'min'` setting, so
305
- use the default `'moderate'` setting if you need to.
306
- - Adds a lockdown option `domainTaming` to detect whether Node.js domains have
307
- been initialized and prevents them from being initialized afterward.
308
- Domains otherwise presented a hazard to the integrity of SES containment on
309
- Node.js.
310
- The option defaults to `"unsafe"` in this version and will be switched to
311
- `"safe"` by default in the next release that allows for breaking-changes, to
312
- afford a gradual migration.
313
- Thank you to @dominictarr with [Least Authority](https://leastauthority.com/)
314
- for devising this feature.
315
- - Fixes reflexive module imports. Previously, SES would fail to initialize a
316
- module graph where a module imported an alias to itself.
317
-
318
- # 0.14.1 (2021-08-12)
319
-
320
- - Adds permits for `Array.prototype.at` and `String.prototype.at` which are
321
- Stage 3 proposals for ECMA 262.
322
-
323
- # 0.14.0 (2021-07-22)
324
-
325
- - _BREAKING_: Any precompiled static module records from prior versions
326
- will not load in this version of SES or beyond. The format of the preamble
327
- has been changed to admit the possibility of a variable named `Map` declared
328
- in the scope of a module.
329
- - Fixes the type assertions for `assert` and `assert.string`.
330
- - Reveals `harden` only after `lockdown`. Harden was never usable before
331
- lockdown because it would render the environment irreparable.
332
- Calling `harden` before `lockdown` previously threw an exception.
333
- Now it is possible to write libraries that are usable both in JS and SES,
334
- which can know whether to harden their API by the presence of harden in
335
- global scope.
336
- - Adds `errorTrapping` lockdown option and by default traps uncaught exceptions
337
- and logs them back with their original stack traces.
338
- These would previously appear as mysterios `{}` lines in Node.js.
339
-
340
- # 0.13.4 (2021-06-19)
341
-
342
- - Adds more TypeScript definitions, importable with `/// <reference types="ses"/>`, covering `harden`, `lockdown`, `assert`, and `Compartment`,
343
- and many types importable with `import('ses')` notation.
344
- - Adds descriptive detail to module system link error messages and fixes the
345
- reported exports for one.
346
-
347
- # 0.13.1 (2021-06-05)
348
-
349
- - Fixes type exports for `harden`.
350
- - Packaging fixes.
351
-
352
- # 0.13.0 (2021-06-01)
353
-
354
- - _BREAKING CHANGE_ The `ses/lockdown` module is again just `ses`.
355
- Instead of having a light 43KB `ses/lockdown` and a heavy 3.1MB `ses`, there
356
- is just a 52KB `ses` that has everything except `StaticModuleRecord`.
357
- For this release, there remains a `ses/lockdown` alias to `ses`.
358
- - _BREAKING CHANGE_ Third-party static module interface implementations _must_
359
- now explicitly list their exported names.
360
- For CommonJS, this implies using a heuristic static analysis of `exports`
361
- changes.
362
- Consequently, third-party modules can now participate in linkage with ESM
363
- including support for `export * from './spec.cjs'` and also named imports
364
- like `import * from './spec.cjs'`.
365
- - _BREAKING CHANGE_ The `StaticModuleRecord` constructor has been removed in
366
- favor of a duck-type for compiled static module records that is intrinsic to
367
- the shim and may be emulated by a third-party `StaticModuleRecord`
368
- constructor.
369
- The constructor must perform the module analysis and transform the source,
370
- and present this duck-type to the Compartment `importHook`.
371
- This relieves SES of a dependency on Babel and simplifies its API.
372
- - _BREAKING CHANGE_ The UMD distribution of SES must have the UTF-8 charset.
373
- The prior versions were accidentally ASCII, so SES would have worked
374
- in any web page, regardless of the charset.
375
- To remedy this, be sure to include `<head><meta charset="utf-8"></head>` in
376
- the containing page (a general best-practice for web pages) or specifically
377
- use `<script charset="utf-8" src="ses.umd.min.js">` to address the single
378
- file.
379
- - Relaxes the censorship of `import` and `eval` in programs evaluated
380
- under SES to specifically allow the use of `something.import()` or
381
- `something.eval()` methods.
382
- - Fix: `new Compartment(null, null, options)` no longer throws.
383
- - New lockdown option: `overrideDebug: [...props]` to detect where a property
384
- assignment needs to be turned into a `defineProperty` to avoid the override
385
- mistake. Most useful as `overrideTaming: 'severe', overrideDebug: ['constructor']`.
386
- - We reopened Safari bug
387
- [Object.defineProperties triggering a setter](https://bugs.webkit.org/show_bug.cgi?id=222538#c17)
388
- when we found that it was causing an infinite recursion initializing SES
389
- on Safari.
390
- - We revised an error message to include the error tag of a new error
391
- explanation page:
392
- [SES_DEFINE_PROPERTY_FAILED_SILENTLY](error-codes/SES_DEFINE_PROPERTY_FAILED_SILENTLY.md).
393
- We hope to add such explanations for more errors over time. Please let us
394
- know as you encounter errors that strongly needs explaining.
395
-
396
- # 0.12.7 (2021-05-05)
397
-
398
- - Added to `assert.error` an optional options bag with an option named
399
- `errorName`. The `assert.error` function makes error objects with detailed
400
- error messages whose unredacted contents appear only in `console` output
401
- and are otherwise unobservable. If `errorName` is provided, then
402
- it is also used in the console output instead of the normal error name,
403
- but is otherwise unobservable. This will rarely be used, but will be
404
- used by the `@agoric/marshal` package to name an unserialized error
405
- so that it can be traced back to the site that serialized it; and
406
- ultimately to its origin.
407
-
408
- # 0.12.6 (2021-03-27)
409
-
410
- - Added a new temporary `__allowUnsafeMonkeyPatching__` option to `lockdown`.
411
-
412
- Sometimes SES is used where SES's safety is not required. Some libraries
413
- are not compatible with SES because they monkey patch the shared primordials
414
- is ways SES cannot allow. We temporarily introduce this option to enable
415
- some of these libraries to work in, approximately, a SES environment
416
- whose safety was sacrificed in order to allow this monkey patching to
417
- succeed. More at the
418
- [\_\_allowUnsafeMonkeyPatching\_\_ Options](./lockdown-options.md#__allowUnsafeMonkeyPatching__-options)
419
- section of [lockdown-options](./lockdown-options.md).
420
-
421
- # 0.12.5 (2021-03-25)
422
-
423
- - The 0.12.4 release was broken by https://github.com/endojs/endo/pull/552
424
- since fixed by https://github.com/endojs/endo/pull/638
425
- - These merely remove a repair needed by an old v8 / Node version that
426
- no one any longer supports.
427
-
428
- # 0.12.4 (2021-03-24)
429
-
430
- - Expand TypeScript definitions to include Compartment, StaticModuleRecord,
431
- StaticModuleType, RedirectStaticModuleInterface, FinalStaticModuleType,
432
- ThirdPartyStaticModuleInterface, Transform, ImportHook, and ModuleMapHook.
433
- - The previous took `Object.prototype.constructor` off of the default
434
- [list of properties](src/enablements.js) we enable to be overridden by
435
- assignment. This default is the `{overrideTaming: 'moderate'}` setting.
436
- In this release, we stop enabling `'hasOwnProperty'` by default as
437
- well. With both of these gone, we now have a reasonable debugging
438
- experience.
439
- - Unfortunately, both rollup and webpack seem to turn exported names
440
- into assignments to an `exports` object that inherits from
441
- `Object.prototype`, thereby potentially stepping on any name.
442
- To deal with this perverse case, the release also provides an
443
- `{overrideTaming: 'severe'}` option which enables all properties on
444
- at least `Object.prototype`. This is more compatible but makes the
445
- vscode debugger's inspector unusable. At
446
- [Tracking issue for getting 3rd party packages more SES friendly (#576)](https://github.com/endojs/endo/issues/576)
447
- we track the incompatibilities we encounter and progress toward
448
- getting them fixed.
449
- - Add utility function `Compartment.prototype.__isKnownScopeProxy__(value)` to
450
- aid working around scopeProxy leakage. Returns true if `value` is one of the
451
- scopeProxies created during calls to this Compartment instances's
452
- `Compartment.prototype.evaluate`. See `test-compartment-known-scope-proxy.js`
453
- for an example of performing a scopeProxy leak workaround.
454
- - Under the default `{errorTaming: 'safe'}` setting, the SES shim already redacts stack traces from error instances when it can (currently: v8, spiderMonkey, XS). The setting `{errorTaming: 'unsafe'}` suppresses that redaction, instead blabbing these stack traces on error instances via the expected `errorInstance.stack`.
455
-
456
- The purpose of the `details` template literal tag (often spelled `X`) together with the `quote` function (often spelled `q`) is to redact data from the error messages carried by error instances. With this release, the same `{errorTaming: 'unsafe'}` would suppress that redaction as well, so that all substitution values would act like they've been quoted. IOW, with this setting
457
-
458
- ```js
459
- assert(false, X`literal part ${secretData} with ${q(publicData)}.`);
460
- ```
461
-
462
- acts like
463
-
464
- ```js
465
- assert(false, X`literal part ${q(secretData)} with ${q(publicData)}.`);
466
- ```
467
-
468
- Note that the information rendered by the SES shim `console` object always includes all the unredacted data independent of the setting of `errorTaming`.
469
-
470
- # 0.12.3 (2021-03-01)
471
-
472
- - The `assert.js` module in the `ses` package of this repository exports
473
- a `makeAssert` function, to make other `assert` functions with a different
474
- failure scope. Inadvertantly, this did not enable the `@agoric/assert`
475
- package (currently defined in the agoric-sdk repository) to reexport
476
- the same `makeAssert` function as originally intended, and now
477
- [needed](https://github.com/Agoric/agoric-sdk/pull/2515).
478
- As of this release the `assert` object exported by the `assert.js` module
479
- now carries this function as a `makeAssert` property.
480
- - The `assert.quote` function re-exported by `@agoric/assert` as `q`
481
- has always done only a best effort stringify, intended only to
482
- be interpreted by a human under benign conditions. Within that constraint
483
- its best effort is now better, providing informative though ambiguous
484
- renderings of values problematic for `JSON.stringify`, still including
485
- cycles, but now also functions, promises, `undefined`, `NaN`, `Infinity`,
486
- bigints, and symbols. To distinguish this from
487
- strings in the input, these synthesized strings always begin and
488
- end with square brackets. To distinguish those strings from an
489
- input string with square brackets, an input string that starts
490
- with an open square bracket `[` is itself placed in square brackets.
491
- - The `q` function now has an optional second `spaces` parameter which is
492
- passed through to the underlying `JSON.stringfiy`. Passing in a space or
493
- two spaces makes the output much more readable using indentation and other
494
- whitespace, but takes multiple lines.
495
- - The SES enhanced `console` had previously only produced meaningful stack
496
- traces on v8-based browsers such as Brave, Chromium, or Chrome. It now
497
- works on Firefox and Safari as well. It should work on all major browsers
498
- but have not yet been tested on others.
499
- - On all platforms `Error.stackTrace` is now an assignable accessor property.
500
- On v8-based platforms, for the `Error` constructor in the start compartment,
501
- it has the same effect that it does outside SES. Outside the start
502
- compartment, or outside v8-based platforms, the assignment succeeds silently
503
- with no effect.
504
- This accommodates a de facto standard idiom encouraged by Google.
505
- - The "SES Demo Console" and "SES Challenge" have been fixed to work with
506
- modern SES. Both now run in browsers, though these are not yet hosted
507
- for visiting as an external web page.
508
- - We no longer enable overriding `Object.prototype.constructor` by assigning
509
- to the `constructor` property of a derived object. We were enabling it
510
- due to a bug in acorn 7, since fixed in acorn 8. To enable it, we were
511
- making `Object.prototype.constructor` into an accessor property, which
512
- confused the Node debugger, causing annoying extra noise in the console
513
- output. Now that we've worked around our acorn problem (currently with
514
- a patch) we have stopped enabling this assignment, and so stopped
515
- confusing the Node debugger.
516
-
517
- # 0.12.2 (2021-02-05)
518
-
519
- - fix non-standard regex range syntax that throws on XS (3877d72)
520
- - refine concise stack traces (cbbabeb)
521
-
522
- # 0.12.1 (2021-02-02)
523
-
524
- - Consolidated documentation of [`lockdown` options](./lockdown-options.md) into its
525
- own page.
526
- - Added a `stackFiltering` option to `lockdown` with
527
- two settings, `'concise'` and `'verbose'`. Stack traces are now filtered
528
- `'concise'` by default, making them typically much easier to work with.
529
- `'verbose'` shows complete stack traces, as sometimes it contains clues
530
- needed to find your bug.
531
- See [`stackFiltering` options](./lockdown-options.md#stackfiltering-options)
532
- for an explanation.
533
- - Changed the meaning of the default `'moderate'` setting of the
534
- `overrideTaming` options of `lockdown`. See
535
- [`overrideTaming` options](./lockdown-options.md#overridetaming-options)
536
- for an explanation of when to use which.
537
-
538
- :warning: This change of meaning of the `'moderate'` setting of the
539
- `overrideTaming` option of `lockdown` is not strictly compatible with its
540
- old meaning. The old `'moderate`' setting would enable all properties on a few
541
- widely used prototype objects, including `Object.prototype`. Resulting in a
542
- miserable debugging experience when using the VSCode debugger's object
543
- inspector.
544
-
545
- <details>
546
- <summary>Expand to see the vscode inspector display if enabling all of Object.prototype</summary>
547
-
548
- ![vscode inspector display if enabling all of Object.prototype](docs/images/override-taming-star-inspector.png)
549
-
550
- </details>
551
-
552
- The new `'moderate'` setting only tames those properties we know or expect to
553
- be problematic. If you run into an override mistake problem not addressed at
554
- the `'moderate'` setting **_please file an issue._**
555
-
556
- <details>
557
- <summary>Expand for { overrideTaming: 'moderate' } vscode inspector display</summary>
558
-
559
- ![overrideTaming: 'moderate' vscode inspector display](docs/images/override-taming-moderate-inspector.png)
560
-
561
- </details>
562
-
563
- For an even better debugging experience, try the `'min'` setting, which
564
- makes the debugging experience even less noisy, but may not be compatible with
565
- all the code you're running under SES.
566
-
567
- <details>
568
- <summary>Expand for { overrideTaming: 'min' } vscode inspector display</summary>
569
-
570
- ![overrideTaming: 'min' vscode inspector display](docs/images/override-taming-min-inspector.png)
571
-
572
- </details>
573
-
574
- # 0.11.1 (2021-01-21)
575
-
576
- - Upgrades `harden` such that that it transitively freezes an object's
577
- prototype chain, eliminating the notion of a "fringe set" and errors
578
- that were previously thrown if an object's prototype was not already
579
- in the fringe.
580
- - Added an `overrideTaming` option to `lockdown` with two settings,
581
- `'min'` and `'moderate'`. See
582
- [Enabling Override by Assignment](README.md#enabling-override-by-assignment)
583
- for an explanation of when to use which. **_(This documentation has moved
584
- to [`overrideTaming`
585
- options](./lockdown-options.md#overridetaming-options))_**
586
- - Modules and evaluated code that contains the censored substrings
587
- for dynamic eval, dynamic import, and HTML comments will now
588
- throw errors that contain the `sourceURL` from any `//#sourceURL=` comment
589
- toward the end of the source or merely `<unknown>`.
590
-
591
- # 0.11.0 (2020-11-03)
592
-
593
- - `lockdown()` adds new global `assert` and tames the global `console`. The
594
- error taming hides error stacks, accumulating them in side tables. The
595
- `assert` system generated other diagnostic information hidden in side
596
- tables. The tamed console uses these side tables to output more informative
597
- diagnostics. [Logging Errors](./src/error/README.md) explains the design.
598
- - Adds a non-standardizable `__shimTransforms__` option to the
599
- Compartment constructor that allows a single transform to work
600
- for both programs passed to `evaluate` and modules that the SES shim
601
- compiles to programs.
602
-
603
- # 0.10.4 (2020-09-28)
604
-
605
- - When converting each of [these data properties](src/enablements.js) to
606
- accessor properties, to suppress the
607
- [override mistake](https://github.com/tc39/ecma262/pull/1320), we now
608
- add to that accessor's getter an `originalValue` property to mark it
609
- as alleging that it is emulating a data property whose original value
610
- was that value.
611
- - Fixes an exception thrown when calling `lockdown` after just importing
612
- `ses/lockdown` in all environments.
613
-
614
- # 0.10.3 (2020-09-08)
615
-
616
- - The `ses/lockdown` module and Rollup bundles now include a minimal
617
- implementation of `Compartment` that supports `evaluate` but not loading
618
- modules.
619
- This is sufficient for containment of JavaScript programs, including
620
- modules that have been pre-compiled to programs out-of-band, without
621
- entraining a full JavaScript parser framework.
622
- - Allows a compartment's `importHook` to return an "alias" if the returned
623
- static module record has a different specifier than requested.
624
- - Adds the `name` option to the `Compartment` constructor and `name` accessor
625
- to the `Compartment` prototype.
626
- Errors that propagate through the module loader will be rethrown anew with
627
- the name of the module and compartment so they can be traced.
628
- At this time, the intermediate stacks of the causal chain are lost.
629
- https://github.com/Agoric/SES-shim/issues/440
630
-
631
- # 0.10.2 (2020-08-20)
632
-
633
- - Adds a `moduleMapHook` option to the `Compartment` constructor options.
634
- The module map hook can return values for the `moduleMap` for
635
- any given module specifier, or return `undefined` to fall back to the
636
- `importHook`.
637
- This allows for wildcard linkage to other compartments.
638
- - Fix dependency version for `@agoric/transform-module`.
639
-
640
- # 0.10.1 (2020-08-13)
641
-
642
- - Updates the whitelist to allow a `HandledPromise` global, which is provided
643
- by `@agoric/eventual-send`, an early implementation of
644
- https://github.com/tc39/proposal-eventual-send.
645
- - Corrects our fix for the override mistake, so that it correctly emulates
646
- how assignment would work in the absence of the override mistake.
647
- A property created by assignment will now be a writable, enumerable,
648
- configurable data property, as it is for normal assignment.
649
-
650
- # 0.10.0 (2020-08-08)
651
-
652
- - Creates a `ses/lockdown` module that only introduces `lockdown` and `harden`
653
- to global scope, for a much smaller payload than `ses`, which entrains a
654
- JavaScript parser to support ECMAScript modules.
655
- - Adds the `load` method to `Compartment`.
656
- Load allows a bundler or archiver to use the `Compartment` API to gather the
657
- transitive dependencies of modules without executing them.
658
- - Adds support for third-party implementations of a `StaticModuleRecord`
659
- interface (`{imports, execute}`).
660
-
661
- # 0.9.1 (2020-07-16)
662
-
663
- - The `*Locale*` methods removed in the previous release are now restored
664
- by aliasing them to their non-locale equivalents. `localeCompare` had no builtin
665
- non-locale equivalent, so we provide one.
666
- - Adds a TypeScript definition for `harden`.
667
-
668
- # 0.9.0 (2020-07-13)
669
-
670
- - BREAKING CHANGE: The compartment `evaluate` method no longer accepts an
671
- `endowments` option.
672
- Use `compartment.globalThis`, `endowments`, or `globalLexicals`.
673
- If per-evaluation `globalLexicals` or `endowments` are necessary,
674
- each evaluation will need a fresh `Compartment`.
675
- - BREAKING CHANGE: The `lockdown` function's deprecated `noTame*` options have
676
- been removed in favor of the `*Taming` options introduced in version 0.8.0.
677
- - BREAKING CHANGE: The `.toLocale*` methods of
678
- Object/Number/BigInt/Date/String/Array/%TypedArray% were removed from SES
679
- environments. This includes methods named `toLocaleString`,
680
- `toLocaleDateString`, `toLocaleTimeString`, `toLocaleLowerCase`,
681
- `toLocaleUpperCase`, and `localeCompare`. These may be restored (in a
682
- modified form) in a future release.
683
- - The way `lockdown()` tames the `Error` constructor now cooperates
684
- with the V8 stack trace API to a degree that is permissible without
685
- breaking the integrity of applications that use it.
686
- - The Compartment constructor now accepts a `globalLexicals` option.
687
- The own enumerable properties of the global lexicals are captured
688
- and presented as constants in the scope of all calls to `evaluate` and all
689
- modules.
690
- The global lexicals overshadow the global object.
691
-
692
- # 0.8.0 (2020-05-26)
693
-
694
- - Adds support for modules to Compartments.
695
- - SES no longer exports anything.
696
- `Compartment`, `StaticModuleRecord`, `lockdown`, and `harden` are all
697
- introduced as properties of `globalThis`.
698
- - The `Compartment` `global` getter is now named `globalThis`, consistent with
699
- the specification proposal.
700
- - The `Compartment` `transforms` constructor option is now just an array of
701
- transform functions that accept and return program strings.
702
- Transforms can no longer introduce `endowments`.
703
- The compartment constructor's `endowments` argument (first) and assigning
704
- properties to `globalThis` are the remaining supported ways to introduce
705
- endowments.
706
- - Repair `Function.apply` and `TypeError.message` (as well as `.message` on
707
- all the other Error types), to tolerate what the npm `es-abstract` module
708
- does. This allows `tape` (version 4.x) to be loaded in a locked-down SES
709
- world, and also allows its `t.throws` assertion to work. `tape` (version
710
- 5.x) still has problems. [#293]
711
-
712
- - Replaces the old `noTame*` options to `lockdown` with new `*Taming` options.
713
- The old style had boolean values defaulting to `false`. In the new style,
714
- each option supports at least the options `'safe'` and `'unsafe'` defaulting
715
- to `'safe'`. As a transitional matter, this release still supports the
716
- old style as well, as another way to say the same thing. [#326]
717
-
718
- [#293]: https://github.com/Agoric/SES-shim/issues/293
719
- [#326]: https://github.com/Agoric/SES-shim/issues/326
720
-
721
- # 0.7.7 (2020-04-27)
722
-
723
- - This version decouples lockdown and the Compartment constructor.
724
- The Compartment constructor is now exported by `ses` (was previously only
725
- available as a property of `globalThis` _after_ lockdown).
726
- The Compartment constructor will also create "privileged" compartments when
727
- constructed before lockdown.
728
-
729
- # 0.7.6 (2020-03-31)
730
-
731
- Bug fixes.
732
- This release fixes issues in RegExp and Error taming.
733
-
734
- # 0.7.4-5 (2020-03-21)
735
-
736
- This release adds Node.js ESM support by upgrading @agoric/make-hardener to a
737
- hybrid version for most modern module systems.
738
-
739
- - Newless calls to the RegExp constructor now work after lockdown.
740
-
741
- - upgrade @agoric/make-hardener v0.0.8
742
-
743
- # 0.7.2-3 (2020-03-13)
744
-
745
- Bug fixes.
746
- This release addresses an exception observed where locking down fails because
747
- SES cannot delete the prototype of the harden function.
748
- This is addressed by upgrading @agoric/make-harden to version 0.0.7.
749
- This release also restores fulls upport for importing SES as CommonJS, Node.js
750
- ESM, and Node.js emulated ESM with the `esm` package.
751
-
752
- # 0.7.1 (2020-13-10)
753
-
754
- SECURITY UPDATE: This complete re-architecture which removes the realm-shim and
755
- resolve the associatd sandbox escapes related to leaking cross-realm
756
- intrinsics. All users should update to this version.
757
-
758
- See [docs/ses-0.7.md].
759
-
760
- # 0.6.4 (2019-10-16)
761
-
762
- SECURITY UPDATE: This release upgrades realms-shim to fix multiple sandbox
763
- escapes. All users should update to this version.
764
-
765
- - upgrade to realms-shim v1.2.1
766
-
767
- Non-security fixes:
768
-
769
- - improve documentation
770
-
771
- # 0.6.3 (2019-10-02)
772
-
773
- SECURITY UPDATE: This release upgrades realms-shim to fix multiple sandbox
774
- escapes. All users should update to this version.
775
-
776
- - upgrade to realms-shim v1.2.0
777
-
778
- Non-security fixes:
779
-
780
- - add `SES.harden` to make hardening available from within the Realm. (#161)
781
-
782
- # 0.6.2 (2019-09-25)
783
-
784
- No user-visible changes.
785
-
786
- Use realms-shim as a normal package, not a git-submodule. Update eslint
787
- dependencies.
788
-
789
- # 0.6.1 (2019-19-14)
790
-
791
- - SECURITY UPDATE: This release fixes a sandbox escape discovered in the
792
- realms-shim by GitHub user "XmiliaH", which works by causing an infinite
793
- loop and extracting the real function constructor from the RangeError
794
- exception object. See https://github.com/Agoric/realms-shim/issues/48 for
795
- more details.
796
-
797
- # 0.6.0 (2019-09-03)
798
-
799
- - Breaking change: `options.transforms` may no longer specify `endow()`
800
- transforms. Instead, use `rewrite()`, which can now modify endowments.
801
- See https://github.com/Agoric/realms-shim/pull/38 for details.
802
- - Repair the "override mistake", with optional repair plan in
803
- `options.dataPropertiesToRepair`. See src/bundle/dataPropertiesToRepair.js
804
- and https://github.com/Agoric/SES/pull/146 for details.
805
- - `options.sloppyGlobals` is rejected by `makeSESRootRealm()`, since all SES
806
- root realms are frozen. `sloppyGlobals` can only be used in a new
807
- "Compartment", made by calling `Realm.makeCompartment(options)`. See
808
- https://github.com/Agoric/SES/issues/142
809
- https://github.com/Agoric/realms-shim/pull/33
810
- https://github.com/Agoric/realms-shim/pull/30 for details.
811
- - Add `options.whitelist` to override the set of properties that are retained
812
- in the new realm. The default gives you SES, but it could be overridden to
813
- e.g. enforce a Jessie-only environment.
814
-
815
- # 0.5.3 (2019-07-24)
816
-
817
- - Re-enable indirect eval. (#131)
818
-
819
- # 0.5.2 (2019-07-13)
820
-
821
- Dependency updates only, no user-visible changes.
822
-
823
- # 0.5.1 (2019-07-10)
824
-
825
- - The 'realms-shim' module, upon which SES depends, has been split out of the
826
- TC39 'proposal-realms' repository, and now lives in
827
- https://github.com/Agoric/realms-shim. It has not been released to NPM,
828
- rather SES incorporates it as a git submodule. (#110)
829
- - The documentation is now hosted on ReadTheDocs at
830
- https://ses-secure-ecmascript.readthedocs.io/en/latest/ (#111, #117)
831
- - SES.makeRootRealm() now accepts a 'transforms' option. This is a list of `{ endow, rewrite }` functions which can add/modify endowments and/or rewrite
832
- source code each time an `evaluate()` is performed. (#125)
833
-
834
- Thanks to Kate Sills, Dan Connolly, Michael Fig, and the ever-dependable
835
- Dependabot for additional fixes in this release.
836
-
837
- # 0.5.0 (2019-04-05)
838
-
839
- INCOMPATIBLE API CHANGE: Starting with this release, the SES package exports
840
- a single default object (named `SES`, from which you can get the
841
- `SES.makeSESRootRealm()` function). Previously, it exported both a `SES`
842
- object and the `makeSESRootRealm` function.
843
-
844
- Code which uses this package as an ES6 module must change its import from
845
- `import { SES } from 'ses';` to:
846
-
847
- ```js
848
- import SES from 'ses';
849
- ```
850
-
851
- Similarly, for code which uses CommonJS-style, it must change from `const { SES } = require('ses')` to:
852
-
853
- ```js
854
- const SES = require('ses');
855
- ```
856
-
857
- The package now exports bundles in various flavors: CommonJS, ES6 Module, and
858
- browser-based UMD.
859
-
860
- Other changes:
861
-
862
- - whitelist Symbol.matchAll, to fix Chrome-v73 (Issue #90)
863
- - change primary export #88
864
- - improve documentation #66 #67
865
- - add integration tests #85
866
- - packaging: remove ses-shim.js, add other generated bundles
867
- - update Realms shim to commit 0c00eb, to fix Browserify #79
868
- - test against node v10/v11, switch from travis to circleci #73
869
- - fix examples #102
870
-
871
- Thanks to Matt Bell, Kate Sills, and Mark Miller for additional fixes in this
872
- release.
873
-
874
- # 0.4.0 (2019-02-20)
875
-
876
- Improve usability.
877
-
878
- - remove `Nat` and `def` from the global environment #45
879
- - provide a helper function named `s.makeRequire()` to build a `require`
880
- endowment. This can be configured to enable `require('@agoric/nat')` or
881
- `require('@agoric/harden')` (among others), so the same code can work
882
- either inside or outside of a SES realm. For details of its configuration,
883
- see the comments in the commit which landed it. #13
884
- - harden() comes from `@agoric/make-hardener`, which doesn't climb
885
- prototype/inheritance chains, but does complain if the prototype wasn't
886
- already known to harden(). This avoids the "Ice-9" freeze-the-world
887
- problem, and also serves to signal when an object from one realm is passed
888
- into the harden() of a different realm. #15
889
- - harden() now shares a WeakSet of previously-hardened objects #4
890
- - use harden() instead of def() #39
891
- - SES no longer depends upon Nat, but uses it during unit tests. Client code
892
- that wants Nat should use `require('@agoric/nat')`. #45
893
- - Include AsyncIteratorPrototype in the set of anonIntrinsics #58
894
- - use eslint to format all SES code
895
-
896
- # 0.3.0 (2019-02-08)
897
-
898
- Improves security and functionality.
899
-
900
- This fixes all known confinement leaks:
901
-
902
- - We now freeze AsyncGeneratorFunction and AsyncFunction, the last of the
903
- "anonymous" intrinsics (which are reachable by syntax but not simple
904
- property lookup). In the previous release, attacker code could modify their
905
- behavior (which defender code might have been relying upon) or use them as
906
- a communication channel. (#3, #41)
907
- - We now remove all unknown properties from the global object, using a
908
- special list of ones that are safe to expose. This protects us from
909
- surprising platform-specific objects, or newly-added standard JS objects
910
- that have not yet been examined for safety. The 'Intl' object is currently
911
- removed by this check (and `intlMode: "allow"` has been removed), but may
912
- be brought back in a future release. (#26)
913
- - RegExp.prototype.compile is removed unconditionally (even if regexpMode:
914
- "allow" is set), because it violates the semantics of Object.freeze
915
-
916
- It also improves usability:
917
-
918
- - Uncaught exceptions in Node.js are now rendered correctly when the
919
- `errorStackMode: "allow"` option is enabled. In the previous release, such
920
- exceptions were always displayed as "undefined", which was particularly
921
- unhelpful. If your program is abruptly exiting with "undefined", try
922
- turning this option on while you're debugging. But don't leave it on,
923
- because it probably enables a confinement breach.
924
- - SES is an ES6 module, but should now be importable with `require()` by
925
- other code which is unaware of ES6 modules, because it now uses the `esm`
926
- module internally. (#32)
927
- - `console.log` is now available within the confined code, if the
928
- `consoleMode: "allow"` option is enabled. If this is disabled,
929
- `console.log()` will throw a `TypeError` (since `console` is undefined, it
930
- has no `log` property). Many other `console` methods (but not all) are
931
- exposed too. (#35)
932
-
933
- SES now requires Node.js version 10 or later.
934
-
935
- # 0.2.0 (2019-01-18)
936
-
937
- Improves confinement, small API changes.
938
-
939
- The options passed as `SES.makeSESRootRealm(options)` have changed:
940
-
941
- - `options.dateNowMode="allow"` allows `Date.now()` and `new Date()` to
942
- work normally, otherwise they return NaN
943
- - `options.mathRandomMode="allow"` allows `Math.random()` to work
944
- normally (nondeterministically), else it will throw an Error
945
- - `options.intlMode="allow"` lets `Intl.DateTimeFormat()`, `Intl.NumberFormat()`,
946
- and `Intl.getCanonicalLocales()` to work normally, else they throw Errors
947
- - `options.errorStackMode="allow"` exposes `Error.prototype.stack` and
948
- `Error.captureStackTrace` (on platforms that support them), otherwise they
949
- are suppressed. Note that these could be used to break confinement, not
950
- just access nondeterminism.
951
-
952
- Previously the only option honored was `options.dateNowTrap = false`
953
-
954
- The suppression of `Error.captureStackTrace` is new in this release. This
955
- release also suppresses `RegExp.prototype.compile` and properties like
956
- `RegExp.$1` which cause some surprising behavior.
957
-
958
- `SES.def` and `SES.Nat` are exported, so they can be used by non-confined
959
- code (mostly in tests). `def(obj)` makes an object defensive, by freezing
960
- it's external API surface (anything reachable by property lookup and
961
- prototype traversal). `Nat(num)` throws an error unless its argument is a
962
- natural number (a non-negative integer small enough to remain an integer
963
- inside a Javascript `Number` type). Both are important for defensive
964
- programming.
965
-
966
- # 0.1.3 (2018-08-24)
967
-
968
- Adds Nat and SES.confineExpr.
969
-
970
- - `Nat(val)` ensures the value is a natural (non-negative) integer
971
- - `SES.confineExpr(expr)` makes it easy to start with a function object, turn
972
- it into a string, then into a new function inside the SES realm.
973
-
974
- This also updates the challenge page to fix a demo vulnerability (#8).
975
-
976
- # 0.1.2 (2018-07-30)
977
-
978
- - npm name is now 'ses'
979
- - update to current proposal-realms
980
-
981
- # 0.0.1 (2018-07-28)
982
-
983
- first preliminary release