ses 0.15.2 → 0.15.6

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 CHANGED
@@ -3,6 +3,49 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.15.6](https://github.com/endojs/endo/compare/ses@0.15.5...ses@0.15.6) (2022-01-27)
7
+
8
+ **Note:** Version bump only for package ses
9
+
10
+
11
+
12
+
13
+
14
+ ### [0.15.5](https://github.com/endojs/endo/compare/ses@0.15.4...ses@0.15.5) (2022-01-25)
15
+
16
+ **Note:** Version bump only for package ses
17
+
18
+
19
+
20
+
21
+
22
+ ### [0.15.4](https://github.com/endojs/endo/compare/ses@0.15.3...ses@0.15.4) (2022-01-23)
23
+
24
+
25
+ ### Features
26
+
27
+ * **ses:** Check early for dynamic evalability ([d0f6f09](https://github.com/endojs/endo/commit/d0f6f099d41edee3f484da5d5094848f72f93084)), closes [#343](https://github.com/endojs/endo/issues/343)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **ses:** Direct eval check should not preclude no-eval under CSP ([#1004](https://github.com/endojs/endo/issues/1004)) ([fc8f9ee](https://github.com/endojs/endo/commit/fc8f9eee5ec703ebc611bc015b94fc8ecb721324))
33
+ * **ses:** Fix mistaken this binding example ([#990](https://github.com/endojs/endo/issues/990)) ([71db876](https://github.com/endojs/endo/commit/71db876ee3d7557f0f19dd995a4e027cc7945c2b))
34
+ * minor wording ([#989](https://github.com/endojs/endo/issues/989)) ([f8d6ff6](https://github.com/endojs/endo/commit/f8d6ff6c63b0c46bcaf93378b61d7286d971fd5f))
35
+ * **ses:** Add assert.error options bag to type definition ([#978](https://github.com/endojs/endo/issues/978)) ([ca42997](https://github.com/endojs/endo/commit/ca4299714d5769ea15418612f679abb400ff7e25)), closes [#977](https://github.com/endojs/endo/issues/977)
36
+ * **ses:** Number.prototype.toLocaleString radix confusion ([#975](https://github.com/endojs/endo/issues/975)) ([6a17595](https://github.com/endojs/endo/commit/6a175953e5c78d2575c2e9e4e72e6b893bcdb631)), closes [#852](https://github.com/endojs/endo/issues/852)
37
+ * **ses:** Remove superfluous error cause on prototypes ([#955](https://github.com/endojs/endo/issues/955)) ([6e50c45](https://github.com/endojs/endo/commit/6e50c4526f457b31e00a783406d175b0088907eb))
38
+
39
+
40
+
41
+ ### [0.15.3](https://github.com/endojs/endo/compare/ses@0.15.2...ses@0.15.3) (2021-12-14)
42
+
43
+ **Note:** Version bump only for package ses
44
+
45
+
46
+
47
+
48
+
6
49
  ### [0.15.2](https://github.com/endojs/endo/compare/ses@0.15.1...ses@0.15.2) (2021-12-08)
7
50
 
8
51
 
package/NEWS.md CHANGED
@@ -1,5 +1,12 @@
1
1
  User-visible changes in SES:
2
2
 
3
+ # v0.15.3 (2022-01-21)
4
+
5
+ - Fixes the type definition for assert.error so that the final options bag,
6
+ which may include `errorName`, checks correctly in TypeScript.
7
+ - Lockdown will now throw an error if code running before SES initialization
8
+ replaced `eval`.
9
+
3
10
  # 0.15.2 (2021-12-08)
4
11
 
5
12
  - The `Removing...` messages that Lockdown emits when encountering unrecognized
package/README.md CHANGED
@@ -13,7 +13,7 @@ Most existing JavaScript libraries can run on hardened JavaScript.
13
13
  other. By sharing the intrinsics, programs from separate compartments
14
14
  can recognize each other's arrays, data objects, and so on.
15
15
  * **Strict mode** SES enforces JavaScript strict mode that enhances security,
16
- for example by changing some silent errors into throw errors.
16
+ for example by changing some silent failures into thrown errors.
17
17
  * **POLA** (Principle of Least Authority) By default, Compartments receive no
18
18
  ambient authority. They are created without host-provided APIs, (for example
19
19
  no `fetch`). Compartments can be selectively endowed with powerful arguments,
@@ -28,10 +28,9 @@ See https://github.com/Agoric/Jessie to see how SES fits into the various
28
28
  flavors of confined JavaScript execution. And visit
29
29
  https://ses-demo.agoric.app/demos/ for a demo.
30
30
 
31
- Derived from the Caja project, https://github.com/google/caja/wiki/SES.
32
-
33
- Still under development: do not use for production systems yet, there are
34
- known security holes that need to be closed.
31
+ SES starts where the Caja project left off
32
+ https://github.com/google/caja/wiki/SES, and goes on to introduce compartments
33
+ and modernize the permitted JavaScript features.
35
34
 
36
35
  ## Install
37
36
 
@@ -94,7 +93,7 @@ Lockdown does not erase any powerful objects from the initial global scope.
94
93
  Instead, **Compartments** give complete control over what powerful objects
95
94
  exist for client code.
96
95
 
97
- See [`lockdown` options](./lockdown-options.md) for configuration options to
96
+ See [`lockdown` options](docs/lockdown.md) for configuration options to
98
97
  `lockdown`. However, all of these have sensible defaults that should
99
98
  work for most projects out of the box.
100
99
 
@@ -213,9 +212,15 @@ For example, the `Function` constructor in one compartment creates functions
213
212
  that evaluate in the global scope of that compartment.
214
213
 
215
214
  ```js
216
- const f = new Function("return this");
217
- f() === globalThis
218
- // true
215
+ const c1 = new Compartment();
216
+ const f1 = new c.globalThis.Function('return globalThis');
217
+ f1() === c1.globalThis; // true
218
+
219
+ const c2 = new Compartment();
220
+ const f2 = new c.globalThis.Function('return globalThis');
221
+ f2() === c2.globalThis; // true
222
+
223
+ f1() === f2(); // false
219
224
  ```
220
225
 
221
226
  Lockdown prepares for compartments with separate globals by freezing
@@ -247,7 +252,7 @@ The `importHook` accepts a full specifier and asynchronously returns a
247
252
 
248
253
  ```js
249
254
  import 'ses';
250
- import { StaticModuleRecord } from '@endo/static-module-record`;
255
+ import { StaticModuleRecord } from '@endo/static-module-record';
251
256
 
252
257
  const c1 = new Compartment({}, {}, {
253
258
  name: "first compartment",
@@ -503,6 +508,195 @@ system generated other diagnostic information hidden in side tables. The tamed
503
508
  console uses these side tables to output more informative diagnostics.
504
509
  [Logging Errors](./src/error/README.md) explains the design.
505
510
 
511
+ ## Security claims and caveats
512
+
513
+ The `ses` shim concerns boundaries between programs in the same process and
514
+ JavaScript realm.
515
+ In terms of the [Taxonomy of Security Issues](https://agoric.com/blog/all/taxonomy-of-security-issues/),
516
+ the `ses` shim creates a boundary that is finer than an operating system
517
+ process or thread and facilitates boundaries as fine as individual objects.
518
+ While `ses` can interpose at granularities where process isolation is not a
519
+ viable boundary, as between an application and its dependencies or between a
520
+ platform and a plugin, `ses` combines well with coarser boundaries for defense
521
+ in depth.
522
+
523
+ For the purposes of these claims and caveats, a "host program" is a program
524
+ that arranges `ses`, calls `lockdown`, and orchestrates one or more "guest
525
+ programs", providing limited access to its resources.
526
+
527
+ Provided that the `ses` implementation and its trusted compute base are
528
+ correct, we claim that a host program (Figure 1) can evaluate a guest program
529
+ (`program`) in a compartment after `lockdown` and that the program:
530
+
531
+ - will initially only have access to one mutable object, the compartment's
532
+ `globalThis`,
533
+ - specifically cannot modify any shared primordial objects, which are part of
534
+ the default execution environment,
535
+ - cannot initially perform any I/O (except I/O necessarily performed by the
536
+ trusted compute base like paging virtual memory),
537
+ - and specifically cannot measure the passage of time at any resolution.
538
+
539
+ However, such a program can:
540
+
541
+ - execute for an indefinite amount of time,
542
+ - allocate arbitrary amounts of memory,
543
+ - detect the platform endianness,
544
+ - in some JavaScript engines, observe the contents of the stack.
545
+ This may include sensitive information about the layout of files on the host
546
+ disk.
547
+ In cases where the stack is data-dependent, a guest can infer the data.
548
+ `ses` occludes the stack on V8 and SpiderMonkey, but cannot on
549
+ JavaScriptCore.
550
+
551
+ ```js
552
+ // Claims, Figure 1
553
+ lockdown();
554
+ const compartment = new Compartment();
555
+ compartment.evaluate(program);
556
+ ```
557
+
558
+ If the host program (Figure 2) arranges for the compartment's `globalThis` to
559
+ be frozen, we additionally claim that the host can evaluate any two guest
560
+ programs (`program1` and `program2`) such that neither program will:
561
+
562
+ - initially share *any* mutable objects.
563
+ - be able to observe the relative passage of time of the other program,
564
+ as they would had they been given a reference to a working `Date.now()`.
565
+ - be able to communicate, as they would if they had shared access to mutable
566
+ state like an unfrozen object, a hardened collection like a `Map`, or even
567
+ `Math.random()`.
568
+
569
+ ```js
570
+ // Claims, Figure 2
571
+ lockdown();
572
+ const compartment = new Compartment();
573
+ harden(compartment.globaThis);
574
+ compartment.evaluate(program1);
575
+ compartment.evaluate(program2);
576
+ ```
577
+
578
+ However such programs (`program`, `program1`, or `program2`) are only
579
+ as useful as a calculator.
580
+ A host program is therefore responsible for maintaining any of the desired
581
+ invariants above when "endowing" a compartment with any of its own objects.
582
+
583
+ For example, a host program (Figure 3) may run two programs in separate
584
+ compartments, giving one program the ability to resolve a promise and the other
585
+ program the ability to observe the settlement (fulfillment or rejection) of
586
+ that promise.
587
+ The host program is responsible for hardening these objects.
588
+
589
+ ```js
590
+ // Claims, Figure 2
591
+ lockdown();
592
+
593
+ const promise = new Promise(resolve => {
594
+ const compartmentA = new Compartment(harden({
595
+ resolve,
596
+ }));
597
+ compartment.evaluate(programA);
598
+ });
599
+
600
+ const compartmentB = new Compartment(harden({
601
+ promise,
602
+ }));
603
+ compartmentB.evaluate(programB);
604
+ ```
605
+
606
+ With `ses`, guest programs are initially powerless.
607
+ A host can explicitly share limited powers with guest programs
608
+ and provide intentional communication channels between them.
609
+
610
+ Host programs must maintain the `ses` boundary with care in what they present
611
+ as endowments.
612
+ A host program should take care not to share mutable state with guests,
613
+ or distribute mutable state to multiple guests, such as an unfrozen object (use
614
+ `harden`), direct read and write access to a collection, like a `Map` or `Set`,
615
+ even if hardened.
616
+ Furthermore, typed arrays are collections and cannot be hardened.
617
+
618
+ For the purposes of sharing state, pseudo-random number generators (PRNG) like
619
+ `Math.random()` are equivalent to read and write access to shared state, and
620
+ any guest can use one to eavesdrop on other guests or the host that share one.
621
+
622
+ If a guest program needs a high resolution timer to function, the host should
623
+ only invite one guest to a single operating system process and limit the
624
+ activity of the host program in the same process.
625
+
626
+ Hosts must avoid exposing `SharedArrayBuffer` to guests.
627
+ Any two JavaScript programs sharing a `SharedArrayBuffer` can use the shared
628
+ buffer to construct a high resolution timer.
629
+
630
+ The `ses` shim does not in itself isolate the stack of guest programs, even
631
+ when evaluated in separate compartments.
632
+ This is relevant when program created objects are shared between guest
633
+ programs.
634
+
635
+ When a program interacts with an object introduced by another program (as
636
+ through the per-compartment `globalThis`, function arguments or returned
637
+ values), there are potential risks due to the synchronous nature of object
638
+ access.
639
+ Even interactions that are not explicit function calls may cause code from
640
+ another program, like property accessors or proxy traps, to execute on the same
641
+ stack, which may be able to call back into the program (reentrancy), throw, or
642
+ detect the current stack height.
643
+
644
+ A host object can defend itself from reentrancy attacks by ensuring that it
645
+ interacts with guest objects on a clean stack through the use of promises.
646
+
647
+ Within these constraints, a host program can provide objects that grant limited
648
+ I/O capabilities to guest programs, and even revoke or suspend those
649
+ capabilities at runtime.
650
+
651
+ The trusted compute base (TCB) for `ses` includes:
652
+
653
+ - the host hardware,
654
+ - the host operating system,
655
+ - any intermediate virtual operating systems or hypervisors,
656
+ - the process memory manager,
657
+ - an implementation of JavaScript conforming to ECMAScript 262 as of
658
+ 2021, providing no unspecified embedding host behavior like the introduction of syntax
659
+ that when evaluated reveals a mutable object.
660
+ `ses` accounts for one such host behavior provided by Node.js, namely the `domain`
661
+ property on promises, by preventing the use of `ses` in concert with the
662
+ `domain` module.
663
+ - Also, any attached debugger, and
664
+ - any JavaScript that has executed in the same realm before the host program calls
665
+ `lockdown`, including JavaScript that executes after `ses` initializes.
666
+
667
+ ## Audits
668
+
669
+ In June 2021, `ses` underwent formal third party vulnerability assessment over a
670
+ period of 4 weeks with 3 engineers and a dedicated project manager that
671
+ surfaced no unknown security issues or vulnerabilities within the code. As a
672
+ result of this assessment, [a single code change was
673
+ made](https://github.com/endojs/endo/issues/126) to set a flag to disable the
674
+ domain module in Node.js to mitigate a known issue identified in the code. The
675
+ code will be the subject of another round of intense application security
676
+ review mid-2022 by a reputable application security firm renowned for their
677
+ results in security reviews.
678
+
679
+ In July 2021, `ses` was the target of an intensive collaborative bug hunt lead by
680
+ the MetaMask team.
681
+ No critical flaws in the code surfaced during the review.
682
+ As a result of the search for flaws, deficiencies, and weaknesses in the code
683
+ (which is currently a Stage 1 proposal with the ECMA TC39 committee), a series
684
+ of small code changes and documentation improvements were made. There is a
685
+ report available on the
686
+ [Agoric blog](https://agoric.com/blog/technology/metamask-agoric-hardened-js-security-review/)
687
+ that includes links to recordings of code walk-throughs and technical
688
+ discussion, and issues are tagged
689
+ [audit-SEStival](https://github.com/endojs/endo/labels/audit-sestival).
690
+
691
+ In addition to vulnerability assessments, active efforts to [formally verify
692
+ the Agoric kernel](https://agoric.com/blog/technology/the-path-to-verified-blds-how-informal-systems-and-agoric-are-using-formal-methods-analysis-to-improve-software-integrity/)
693
+ have found the object capability model that `ses` provides to be sound.
694
+
695
+ Hardened JavaScript is also within the scope of the [Agoric bug bounty
696
+ program](hackerone.com/agoric), which rewards researchers for surfacing valid
697
+ bugs in our code. We welcome the opportunity to cooperate with researchers,
698
+ whose efforts will undoubtedly yield stronger, more resilient code.
699
+
506
700
  ## Bug Disclosure
507
701
 
508
702
  Please help us practice coordinated security bug disclosure, by using the
package/SECURITY.md CHANGED
@@ -6,20 +6,33 @@ The SES package is still undergoing development and security review, and all
6
6
  users are encouraged to use the latest version available. Security fixes will
7
7
  be made for the most recent branch only.
8
8
 
9
- | Version | Supported |
10
- | ------- | ------------------ |
11
- | 0.12.x | :white_check_mark: |
12
-
13
- ## Reporting a Vulnerability
14
-
15
- Please help us practice coordinated security bug disclosure. If you find a
16
- security-sensitive bug that should not be revealed publically until a fix is
17
- available, please send email to `security` at (@) `agoric.com`. To encrypt,
18
- please use my (@warner) personal GPG key [A476E2E6 11880C98 5B3C3A39 0386E81B
19
- 11CAA07A](http://www.lothar.com/warner-gpg.html) . Keybase users can also
20
- send messages to `@agoric_security`, or share code and other log files via
21
- the Keybase encrypted file system
22
- (`/keybase/private/agoric_security,$YOURNAME`).
23
-
24
- We will create a GitHub security advisory promptly. Let us know your GitHub
25
- username and we'll add you to the collaborator list for further discussion.
9
+ ## Coordinated Vulnerability Disclosure of Security Bugs
10
+
11
+ SES stands for fearless cooperation, and strong security requires strong collaboration with security researchers. If you believe that you have found a security sensitive bug that should not be disclosed until a fix has been made available, we encourage you to report it. To report a bug in HardenedJS, you have several options that include:
12
+
13
+ * Reporting the issue to the [Agoric HackerOne vulnerability rewards program](hackerone.com/agoric).
14
+
15
+ * Sending an email to security at (@) agoric.com., encrypted or unencrypted. To encrypt, please use @Warner’s personal GPG key [A476E2E6 11880C98 5B3C3A39 0386E81B 11CAA07A](http://www.lothar.com/warner-gpg.html) .
16
+
17
+ * Sending a message on Keybase to `@agoric_security`, or sharing code and other log files via Keybase’s encrypted file system. ((_keybase_private/agoric_security,$YOURNAME).
18
+
19
+ * It is important to be able to provide steps that reproduce the issue and demonstrate its impact with a Proof of Concept example in an initial bug report. Before reporting a bug, a reporter may want to have another trusted individual reproduce the issue.
20
+
21
+ * A bug reporter can expect acknowledgment of a potential vulnerability reported through [security@agoric.com](mailto:security@agoric.com) within one business day of submitting a report. If an acknowledgement of an issue is not received within this time frame, especially during a weekend or holiday period, please reach out again. Any issues reported to the HackerOne program will be acknowledged within the time frames posted on the program page.
22
+ * The bug triage team and Agoric code maintainers are primarily located in the San Francisco Bay Area with business hours in [Pacific Time](https://www.timeanddate.com/worldclock/usa/san-francisco) .
23
+
24
+ * For the safety and security of those who depend on the code, bug reporters should avoid publicly sharing the details of a security bug on Twitter, Discord, Telegram, or in public Github issues during the coordination process.
25
+
26
+ * Once a vulnerability report has been received and triaged:
27
+ * Agoric code maintainers will confirm whether it is valid, and will provide updates to the reporter on validity of the report.
28
+ * It may take up to 72 hours for an issue to be validated, especially if reported during holidays or on weekends.
29
+
30
+ * When the Agoric team has verified an issue, remediation steps and patch release timeline information will be shared with the reporter.
31
+ * Complexity, severity, impact, and likelihood of exploitation are all vital factors that determine the amount of time required to remediate an issue and distribute a software patch.
32
+ * If an issue is Critical or High Severity, Agoric code maintainers will release a security advisory to notify impacted parties to prepare for an emergency patch.
33
+ * While the current industry standard for vulnerability coordination resolution is 90 days, Agoric code maintainers will strive to release a patch as quickly as possible.
34
+
35
+ When a bug patch is included in a software release, the Agoric code maintainers will:
36
+ * Confirm the version and date of the software release with the reporter.
37
+ * Provide information about the security issue that the software release resolves.
38
+ * Credit the bug reporter for discovery by adding thanks in release notes, securing a CVE designation, or adding the researcher’s name to a Hall of Fame.