Expand description
Shared wasmtime sandbox configuration.
Both the directive-plugin runtime (crate::runtime) and the WASM
importer host (rustledger-importer/src/wasm.rs) load untrusted
.wasm modules into wasmtime. They have the same security model
and should agree on:
- Which wasm proposals are enabled (attack surface)
- Whether fuel metering is on (
DoSbound) - How per-call
Storeresource limits are enforced - The cost of
Enginecreation (compilation cache + thread pool)
This module is the single source of truth for those decisions. Adding a feature flag here applies it to every WASM-loaded component in rustledger.
§⚠️ Breaking change for user WASM plugins
As of the v0.16-pre reshape, sandbox_config explicitly disables
these wasm proposals (full list — the rustdoc on sandbox_config
explains the rationale for each):
wasm_threads,wasm_shared_everything_threadswasm_multi_memory,wasm_memory64wasm_component_model(and all sub-flags)wasm_gc,wasm_function_referenceswasm_stack_switching,wasm_tail_call
A user-shipped .wasm plugin or importer that relies on any
disabled proposal will now fail to compile at load time with a
wasmtime validation error. This is intentional security
tightening, but plugin authors targeting earlier rustledger
versions may need to recompile against the new sandbox profile.
§Why share the Engine?
wasmtime’s Engine owns the JIT compilation cache and the
background-compilation thread pool. wasmtime documentation
explicitly recommends one Engine per process — sharing it
across all imported modules lets us amortize that cost. A
per-call Store still provides isolation; the Engine only
holds compiled-code state.
Structs§
- Memory
Limiter - Per-store memory limiter.
- Store
State - Store user-data — just the
MemoryLimitertoday.
Enums§
- AbiCheck
- Outcome of reading a freshly instantiated guest’s ABI version.
Constants§
- DEFAULT_
SANDBOX_ MAX_ MEMORY - Default per-instance linear-memory cap (in bytes) for any
sandboxed wasmtime
Storein rustledger. - DEFAULT_
SANDBOX_ MAX_ TIME_ SECS - Default per-call CPU-time budget (in seconds) for sandboxed wasmtime calls in rustledger.
- HOST_
ABI_ VERSION - The
plugin-typesABI version this host build speaks. - MAX_
TABLE_ ELEMENTS - Hard cap on the number of elements in any single WASM table.
Functions§
- apply_
proposal_ disables - Apply rustledger’s WASM-proposal disable list to an existing
Config. - check_
guest_ abi - Read a freshly instantiated guest’s ABI version and compare it to
HOST_ABI_VERSION. - make_
sandboxed_ store - Create a
Storewith rustledger’s sandbox enforcement wired in: - sandbox_
config - Build a wasmtime
Configwith rustledger’s locked-down security posture. Exposed for tests and embedders who need to construct anEnginewith the same flags but different lifetimes. - shared_
engine - Per-process shared wasmtime
Enginewith rustledger’s security posture. Cheap to clone (Arc).