ref-fvm icon indicating copy to clipboard operation
ref-fvm copied to clipboard

Syscall Access Control

Open mriise opened this issue 3 years ago β€’ 3 comments

For Account Abstraction we will be needing to constrain the available syscalls for both validate contexts and invoke on abstract accounts. Work done here will also apply towards https://github.com/filecoin-project/ref-fvm/pull/654 though it is not listed in the table.


βœ… available

🚫 forbidden

❎ not linked

✳️ see notes

❓TODO

Module Syscalls Validate Invoke (account actor) Invoke (normal) Builtin Notes Abstract Account Notes Β 
vm abort βœ… βœ… βœ… βœ… Β  Β  Β 
Β  context 🚫 βœ… βœ… βœ… probably rename to invoke_context Β  Β 
Β  validate_context βœ…β“ ❎ ❎ ❎ Β  TODO Β 
network base_fee 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  total_fil_circ_supply 🚫 βœ…β“ βœ…β“ βœ… TODO maybe constrain to only builtin actors Β  Β 
ipld block_open βœ…βœ³οΈ βœ… βœ… βœ… Β  state mutations is not saved on chain Β 
Β  block_create βœ…βœ³οΈ βœ… βœ… βœ… Β  state mutations is not saved on chain Β 
Β  block_read βœ… βœ… βœ… βœ… Β  Β  Β 
Β  block_stat βœ… βœ… βœ… βœ… Β  Β  Β 
Β  block_link βœ…βœ³οΈ βœ… βœ… βœ… Β  state mutations is not saved on chain Β 
self root βœ… βœ… βœ… βœ… Β  Β  Β 
Β  set_root 🚫 🚫 βœ… πŸš«β“ Β  Β  Β 
Β  current_balance 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  self_destruct 🚫 πŸš«β“βœ³οΈ β“βœ…βœ³οΈ 🚫 only if self == origin? Spec before this is final Β 
actor resolve_address 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  get_actor_code_cid 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  new_actor_address 🚫 βœ…β“ βœ…β“βœ³οΈ βœ… TODO merge with create_actor Β  Β 
Β  create_actor 🚫 βœ…β“ βœ…β“βœ³οΈ βœ… only init actor (!current implementation doesn’t check!) Β  Β 
Β  get_builtin_actor_type 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  get_code_cid_for_type 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  install_actor 🚫 βœ…β“βœ³οΈ βœ…β“βœ³οΈ βœ… only for m2 native, TODO be done through init actor in the future changes done in invoke cant effect validate Β 
crypto hash βœ… βœ… βœ… βœ… Β  Β  Β 
Β  recover_secp_public_key βœ… βœ… βœ… βœ… Β  Β  Β 
Β  compute_unsealed_sector_cid 🚫 βœ…β“ βœ…β“ βœ… TODO maybe just defer to a Builtin Actor Β  Β 
Β  verify_seal 🚫 βœ…β“ βœ…β“ βœ… TODO maybe constrain to Builtin actor type Β  Β 
Β  verify_post 🚫 βœ…β“ βœ…β“ βœ… TODO maybe constrain to Builtin actor type Β  Β 
Β  verify_consensus_fault 🚫 βœ…β“ βœ…β“ βœ… TODO maybe constrain to Builtin actor type Β  Β 
Β  verify_aggregate_seals 🚫 βœ…β“ βœ…β“ βœ… TODO maybe constrain to Builtin actor type Β  Β 
Β  verify_replica_update 🚫 βœ…β“ βœ…β“ βœ… TODO maybe constrain to Builtin actor type Β  Β 
Β  batch_verify_seals 🚫 βœ…β“ βœ…β“ βœ… only power actor (!current implementation doesn’t check!) Β  Β 
rand get_chain_randomness 🚫 βœ… βœ… βœ… Β  Β  Β 
Β  get_beacon_randomness 🚫 βœ… βœ… βœ… Β  Β  Β 
gas charge 🚫 βœ…β“ βœ…β“ βœ… to be unlinked for non-system actorsΒ  Β  Β 
send send 🚫 πŸš«β“βœ³οΈ βœ… βœ… Β  Spec before this is final Β 
debug enabled βœ… βœ… βœ… βœ… Β  Β  Β 
Β  log βœ…βœ³οΈ βœ…βœ³οΈ βœ…βœ³οΈ βœ…βœ³οΈ error if !enabled Β  Β 
Β  store_artifact βœ…βœ³οΈ βœ…βœ³οΈ βœ…βœ³οΈ βœ…βœ³οΈ error if !enabled Β  Β 

Account Abstraction adds validate_context and origin syscalls.

upgrade should be ran in a constrained runtime as well, but that is a later TODO.

Implementation

Goals

  • Pave the way for future differently constrained runtimes.
  • Keep actor types and syscalls composable where expected.

Appoaches

  • Runtime value inside Kernel that is checked on syscalls that are constrained at any point. This ends up being most syscalls.
  • Lean into rust traits to constrain syscall binding to certain bounds, with runtime implementation checks done inside kernel.
  • Syscall permission table per-mode, listing what syscalls are available with a closure for runtime checks.

mriise avatar Sep 13 '22 21:09 mriise

cc @Stebalien

mriise avatar Sep 13 '22 21:09 mriise

I see three major types of binding:

  • Always forbidden
  • Always allowed
  • Sometimes allowed (runtime check)

Always allowed can be done with a runtime check and be considered part of Somtimes allowed, though it probably get messy quick.

Unbound is another one potentially, but it could implemented as Always forbidden. This would mean all actors would need to import syscalls like validate_context and become_actor.

mriise avatar Sep 13 '22 21:09 mriise

General notes:

  • Invoke shouldn't differ between normal actors and abstract accounts except that abstract accounts can't set their own state or delete themselves.
  • The "builtin only" methods should only be linked to builtin actors (so they don't appear as part of the public API). They're not dangerous (generally), just unstable.

Unbound is another one potentially, but it could implemented as Always forbidden.

(see my comment about builtin actors).

This would mean all actors would need to import syscalls like validate_context and become_actor.

Actors can choose to not import a defined syscall.

Stebalien avatar Sep 14 '22 21:09 Stebalien

A note on get_code_cid_for_type and get_builtin_actor_type reasons' for being disallowed in validate contexts: Both functions breaks the (currently thought) contract of validate being solely a pure function of its own state and the message it validates. By allowing either of these, actors can write code that can test for what version of the network it is currently running on, and as such breaks that contract.

mriise avatar Oct 07 '22 22:10 mriise

on the same hand, gas_available can give hints as well by doing test operations that it knows are more expensive/cheaper on different versions of the runtime and gathering information that way, though it is a bit less accurate and easy.

mriise avatar Oct 07 '22 22:10 mriise

We're no longer implementing the validate entry point in this M2.1, so we can punt this to M2.2.

Stebalien avatar Dec 12 '22 02:12 Stebalien