WEFT_OS/crates/weft-runtime/Cargo.toml
Marco Allegretti c28a829624
fix(runtime): enforce effective capability grants per session
Every host import was registered and callable whatever the package
declared, read-only directory capabilities were preopened read-write,
and appd launched packages whose capabilities it could not satisfy. The
fetch import also could not be linked: the host returned a tuple where
the WIT declares the response record, so any component importing
weft:app/fetch failed to instantiate.

One capability vocabulary now lives in weft_ipc_types::capability and
is used by weft-pack, weft-appd and weft-runtime. weft-appd derives a
session's grants once, before the session exists, and refuses the launch
with error 403 when a capability is unknown, unsupported (hw:gpu:*) or
unsatisfiable (documents without an XDG documents directory). The
documents directory now comes from user-dirs.dirs instead of a guessed
~/Documents.

The runtime receives grants explicitly (--grant CAP, --preopen
HOST::GUEST::ro|rw), preopens read-only directories read-only, and checks
the grant on every notifications, clipboard and fetch call. Fetch accepts
only http and https to granted hosts, returns redirects and HTTP error
statuses as responses instead of following or failing them, and bounds
connect time, total time and response size. The file portal takes
read-only directories with --allow-read and refuses writes there.

tests/runtime/check_grants.py runs the real runtime on a probe component
under each kind of grant and checks the outcome of every operation; it
fails when read-only data is writable or an import ignores its grant.
The appd dispatch tests that read WEFT_RUNTIME_BIN now hold the env lock
shared with the tests that set it.
2026-10-09 08:08:58 +00:00

28 lines
824 B
TOML

[package]
name = "weft-runtime"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
[[bin]]
name = "weft-runtime"
path = "src/main.rs"
[features]
default = []
wasmtime-runtime = ["dep:wasmtime", "dep:wasmtime-wasi", "dep:cap-std"]
seccomp = ["dep:seccompiler", "dep:libc"]
net-fetch = ["dep:ureq", "dep:url"]
[dependencies]
anyhow = "1.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
wasmtime = { version = "30", optional = true }
wasmtime-wasi = { version = "30", optional = true }
cap-std = { version = "3", optional = true }
seccompiler = { version = "0.4", optional = true }
libc = { version = "0.2", optional = true }
ureq = { version = "2", optional = true }
url = { version = "2", optional = true }
weft-ipc-types = { path = "../weft-ipc-types" }