WEFT OS is a Wayland compositor and application runtime where every app is a WebAssembly component rendered in an isolated Servo WebView.
Find a file
Marco Allegretti 076ed95eb1
fix(mount-helper): confine what a setuid caller can mount and unmount
weft-mount-helper is meant to be installed setuid root, but it trusted
its caller entirely: it ran veritysetup, mount and umount from the
caller's PATH, mounted a caller's image at any directory, such as over
/etc, and unmounted any mountpoint. Any local user could have gained
root through it.

It now mounts only at an empty directory
/run/user/<uid>/weft/mnt/<name> of the real user, where weft-appd puts
its mountpoints, with every component from <uid> on owned by that user,
not writable by others and opened without following symbolic links,
and mounts through the opened directory, so the path cannot be swapped
meanwhile. It opens the image and hash tree with the real user's
permissions, checks the root hash is a hex digest, mounts read-only with
nosuid, nodev and noexec through mount(2), and unmounts only an EROFS
filesystem at such a directory. veritysetup runs from the absolute path
fixed at build time (WEFT_VERITYSETUP, /usr/sbin/veritysetup by
default), with an empty environment. Devices are named
weft-<uid>-<name>, so a user reaches only their own; a device left by an
interrupted mount is closed by the next mount or unmount at that
directory, and a user may have at most 64 open, counted from the
kernel's list of device-mapper devices under a root-owned lock. Closed standard streams
are reopened on /dev/null before anything else is opened, and errors and
panics are printed as one-line messages.

Run setuid as nobody with a PATH holding a hostile veritysetup and
mount, the helper refuses /etc and another user's directory as
mountpoints, a symbolic link to /etc, a file nobody cannot read, a
malformed root hash, and unmounting /etc or a directory with no image;
a valid request reaches veritysetup at its fixed path, also with the
standard streams closed, and the hostile programs never run. Unit tests cover the mountpoint rules.
2026-10-09 20:56:52 +00:00
.agents docs: describe the portable profile without implying other hosts 2026-10-09 08:57:00 +00:00
.github Merge remote-tracking branch 'origin/main' into fix/enforce-session-grants 2026-10-09 11:30:01 +00:00
.vscode feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening 2026-03-12 12:49:45 +01:00
crates fix(mount-helper): confine what a setuid caller can mount and unmount 2026-10-09 20:56:52 +00:00
docs fix(mount-helper): confine what a setuid caller can mount and unmount 2026-10-09 20:56:52 +00:00
examples fix(notes): show loading status and check the editor after a failed load 2026-10-09 09:07:27 +00:00
infra fix(session): start the session as user units through its own target 2026-10-09 20:35:58 +00:00
protocol feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening 2026-03-12 12:49:45 +01:00
scripts feat: weft-file-portal -- sandboxed file access broker 2026-03-11 15:52:33 +01:00
tests Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package 2026-10-09 10:18:47 +00:00
.gitattributes Initialize Rust workspace and repository metadata 2026-03-10 18:47:06 +01:00
.gitignore Merge remote-tracking branch 'origin/fix/enforce-session-grants' into fix/separate-app-data 2026-10-09 11:36:27 +00:00
AGENTS.md docs: add engineering contract, contributor toolkit and templates 2026-10-09 08:34:48 +00:00
BLUEPRINT.md docs: add stability blueprint for 0.1.0 2026-10-08 22:58:47 +00:00
Cargo.lock fix(mount-helper): confine what a setuid caller can mount and unmount 2026-10-09 20:56:52 +00:00
Cargo.toml fix(runtime): enforce effective capability grants per session 2026-10-09 08:08:58 +00:00
CONTRIBUTING.md docs: stop runner toolchain installs and widen maintenance form 2026-10-09 08:34:48 +00:00
flake.lock build(nix): lock flake inputs for nixos-25.05 + rust-overlay 2026-03-12 23:47:00 +01:00
flake.nix build(nix): use Rust 1.93.0 via rust-overlay for all package builds 2026-03-12 21:28:14 +01:00
justfile Add repository validation and CI checks 2026-03-10 18:47:16 +01:00
README.md Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package 2026-10-09 11:43:01 +00:00
rust-toolchain.toml Initialize Rust workspace and repository metadata 2026-03-10 18:47:06 +01:00

WEFT OS

WEFT OS is a Wayland compositor and application runtime where every app is a WebAssembly component rendered in an isolated Servo WebView. No capability is granted by default; all resource access is declared in a per-app manifest and enforced at runtime.

What is implemented

Compositor — weft-compositor is a Smithay-based Wayland compositor with DRM/KMS and winit backends. It implements the zweft-shell-unstable-v1 protocol extension, which typed shell slots (panel, application) register against.

System shell — weft-servo-shell embeds Servo (feature-gated, --features servo-embed) and renders system-ui.html as a Wayland panel. Without servo-embed, the binary exits with an error instead of rendering. Navigation gestures from the compositor are forwarded to weft-appd over WebSocket.

App shell — weft-app-shell is a per-process Servo host for application WebViews. It shows the UI document weft-appd resolved from the package, injects a weftIpc WebSocket bridge into the page, and registers with the compositor as an application surface. Also feature-gated behind servo-embed.

App daemon — weft-appd supervises sessions: spawns weft-runtime, waits for its READY, spawns weft-app-shell and reports the session running only after the app shell's READY, manages the per-session IPC relay between the Wasm component and the WebView, and handles session teardown. Wraps processes in systemd scopes (CPUQuota=200%, MemoryMax=512M) when available.

Runtime — weft-runtime runs WASI Component Model binaries under Wasmtime 30 (--features wasmtime-runtime). Provides weft:app/notify, weft:app/ipc, weft:app/fetch, weft:app/notifications, and weft:app/clipboard host imports. Preopens filesystem paths according to declared capabilities.

Package management — weft-pack handles check, sign, verify, install, uninstall, list, build-image (EROFS dm-verity), and info. Validates capability strings at check time. App data is stored apart from packages and survives uninstall.

File portal — weft-file-portal is a per-session file proxy with a path allowlist and .. blocking.

Mount helper — weft-mount-helper is a setuid helper for EROFS dm-verity mount/umount via veritysetup.

Demo apps — examples/org.weft.demo.counter and examples/org.weft.demo.notes are pre-built Wasm Component binaries (wasm32-wasip2, wit-bindgen 0.53) with HTML UIs, signed with a committed demo keypair.

Repository layout

crates/           Rust workspace members
examples/         Demo app packages (wasm32-wasip2, not workspace members)
  keys/           Demo Ed25519 keypair
protocol/         zweft-shell-unstable-v1 Wayland protocol XML
infra/
  nixos/          NixOS VM configuration and package derivations
  scripts/        check.ps1, check.sh
  shell/          system-ui.html, weft-ui-kit.js
  systemd/        service unit files
  vm/             build.sh, run.sh (QEMU)
docs/
  architecture.md Component map, IPC, capability table, env vars
  security.md     Capability model, process isolation, SpiderMonkey security boundary
  building.md     Build instructions for all targets

Building

Linux system packages required (openSUSE):

sudo zypper install -y \
  libwayland-devel libxkbcommon-devel libglvnd-devel \
  libgbm-devel libdrm-devel libinput-devel seatd-devel libudev-devel \
  systemd-devel pkg-config clang cmake python3

Build non-Servo crates:

cargo build --workspace --exclude weft-servo-shell --exclude weft-app-shell

Build Linux-only crates (no Servo):

cargo build -p weft-compositor -p weft-servo-shell -p weft-app-shell

Build with Servo embedding (30–60 min, requires clang + python3):

cargo build -p weft-servo-shell --features servo-embed
cargo build -p weft-app-shell --features servo-embed

See docs/building.md for full instructions including Wasm component builds, NixOS VM, and signing.

CI

Jobs on every push to main and on pull requests:

  • portable — fmt, clippy and tests for the crates that need no Linux system libraries
  • linux-only — clippy and tests for compositor and shell crates
  • runtime-grants — clippy for weft-runtime with its Wasm engine and fetch, and tests/runtime/check_grants.py
  • servo-embed-linux — cargo check --features servo-embed for both servo crates
  • contributor-toolkit — links, metadata and catalog of the contributor toolkit, and runner tests

Security

See docs/security.md. Key points:

  • Capabilities declared in wapp.toml, validated at install, enforced at runtime
  • Per-app OS processes with systemd cgroup limits
  • WASI filesystem isolation via preopened directories
  • Ed25519 package signing; optional EROFS dm-verity
  • Optional seccomp BPF blocklist in weft-runtime
  • SpiderMonkey is not sandbox-isolated beyond process-level isolation (see docs/security.md)

Servo fork

  • Servo: https://github.com/marcoallegretti/servo at e5d9a518, pinned by revision
  • Stylo: https://github.com/marcoallegretti/stylo at f1ba4969, through the root [patch]
  • Patches: backdrop-filter parsing (Stylo) and rendering (Servo), rooting of compiled classic scripts and navigator.servo exposure (Servo)
  • See crates/weft-servo-shell/SERVO_PIN.md for Servo integration status and known limitations

Contributing

See CONTRIBUTING.md. AGENTS.md is the engineering contract and BLUEPRINT.md the accepted direction toward 0.1.0.