Skip to main content

Module untrusted

Module untrusted 

Source
Expand description

Untrusted bytecode: verifier, capabilities, quotas, and attestation are separate controls.

§Untrusted bytecode

The verifier, the capability table, and the quotas answer different questions. Passing one of them does not make a module safe.

ControlWhat it decidesWhat it does not decide
verify / decodeThe module is structurally a chunk this runtime can load: opcodes, jumps, arities, gather windows (Call / Spawn / CallNative / StartChild), pack windows, receive immediates, and constant tags allowed for the trust level. A repeated map key is FormatError::DuplicateMapKeyWhether the program should be allowed to run, or what it will do
CapabilitiesWhich caps a flow may send on, spawn with, or delegate. Fn::spawn_confined starts at CapRights::NONE. Delegate only intersectsResource consumption. A flow with no rights can still spin
Quotas and RuntimeConfig::sandboxCPU, heap, spawn/send rate, live flows, links, asks, host awaits, registry names, process memoryThat the bytecode is correct or that the host’s other code is isolated by the type system
Attestation (fingerprint_bf + Runtime::with_attested)The bytes are the module the host intended to loadThat those bytes are harmless
Native table / NativeMaskWhich host functions CallNative may reachScheduler effects such as Spawn, Send, and Jump

Runtime::new stays permissive (QuotaConfig::permissive, no process-wide caps). A sandbox is opt-in via RuntimeConfig::sandbox and QuotaConfig::sandbox. The embedder still owns sockets, files, and Tokio.

examples/untrusted.rs loads a .bf produced by assemble, rejects a bad listing and a bad byte buffer, checks the digest, spawns the guest with an empty native table, and uses bytecode Spawn with rights 0 plus Delegate of that same empty mask. The child is a jump loop. A tight cpu_budget finalizes that child. The host process prints the outcome and returns.

See also docs/beam-mapping.md for which ABI a module is written as, and docs/host-await.md for host work that must not run on a worker.