Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair Proxy with stamping power #1756

Open
mhofman opened this issue Sep 2, 2023 · 0 comments
Open

Repair Proxy with stamping power #1756

mhofman opened this issue Sep 2, 2023 · 0 comments
Labels
confinement Pertaining to confinement of guest programs. enhancement New feature or request ses

Comments

@mhofman
Copy link
Contributor

mhofman commented Sep 2, 2023

What is the Problem Being Solved?

Hardened JS provides and OCap environment, however because of some of the remaining JS semantics, that is not sufficient for mutually suspicious parties in the same vat / agent to easily reason about their interactions.

In particular, property access on an object, even hardened, may throw or become re-entrant. Or adopting a Promise can also cause re-entrancy. There are actually 2 situations that can cause these surprising behaviors:

  • an object / promise with accessors instead of data properties
  • a proxy pretending data properties

While the former can and is protected by disallowing accessors when sharing objects through a boundary between mutually suspicious code (as implemented by passStyleOf checks), the latter cannot be protected against with normal JS features since proxies are meant to be completely transparent.

Description of the Design

Hardened JS would replace the Proxy constructor with a version that stamps instances (e.g. add them to a WeakMap), and create a power in the start compartment that allows detecting whether an object is a proxy instance.

This predicate power could be provided to makePassStyleOf to let it detect these exotic proxy object, and disqualify them as passable. In the case of the agoric-sdk, liveslots would arrange to instantiate passStyleOf and endow it to compartments in which user code runs.

Some open questions are whether the Proxy constructor in the initial compartment should be the stamping version of not, and where to place the predicate. For example we could arrange for the %InitialProxy% to be exempt from stamping (only for %SharedProxy%to stamp its instances), and for the predicate to live on%InitialProxy%.isSharedProxy`.

Alternative / Rejected Design

The main concern with proxies is its ability to execute user code in objects that may be considered inert. One alternative would be to change the semantics of proxies to bypass the handler traps once the object is frozen. However there are some problems with that approach:

  • testing whether an object is frozen can itself trigger traps if the object is not frozen
  • proxy invariants regarding get / set of non-own properties are lax and cannot be cached (unless we change the invariants to require non-exotic behavior, aka lookup on the prototype chain)

In the case of OCap checks, the first issue is the biggest problem. We would need to implement an "isFrozen" / "isExtensible" predicate that is guaranteed to no trigger proxy traps, which reduced back to the isProxy predicate.

Security Considerations

This would enable solving the following issues:

Other relevant issues:

Scaling Considerations

N/A

Test Plan

Unit tests

Upgrade Considerations

This is a new capability which by itself does not result in any behavioral changes for existing code.

@mhofman mhofman added enhancement New feature or request confinement Pertaining to confinement of guest programs. ses labels Sep 2, 2023
@kriskowal kriskowal added the kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 label Jan 8, 2024
@aj-agoric aj-agoric removed the kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confinement Pertaining to confinement of guest programs. enhancement New feature or request ses
Projects
None yet
Development

No branches or pull requests

3 participants