wardend README.md
56 kB 957 lines
Markdown
at main

wardend #

A small suite of daemons that supervises a confidential-compute guest. The warden is the keeper of the castle: the security controller. The regent is the minimal init system that stands in when the warden falls. Around them, staff with carefully assigned roles and privileges: one owns the wire, one the evidence, one the storage, one the logs, and (optionally) one the back door. Everything a unit is isolated by is a moat: a boundary the warden controls, not the workload.

As long as the warden stands, the castle is secure: nothing non- supervisory runs without a moat, the wire is owned by exactly one daemon, and secrets move only under attestation.

Repo: codeberg.org/lrvick/wardend. A Rust workspace: one crate per daemon, a set of shared core crates (the SDK, §7.5), and moat crates behind one universal contract (§8). The contract lives in core; the moats live under the controller and are linked only by it.

The boot chain starts below the suite: demit, an almost-formally- verified tiny C init, unpacks the read-only root and mounts the runtime filesystems, then execs the regent. It is the only process before the suite, and it is small enough to verify — not to supervise.

Status: the wire owner, the evidence daemon, the back door, the local trusted admin client, and the disk daemon are IMPLEMENTED. bastiond (the wire owner: LLA + DHCP + lease, the bounded background IMDS user-data fetch, the directive grammar, the expose/offline/unit relays, the OCI pull path, the fleet spec parser, the domain-binding + ACME + SNI-routing path (the DNS poll, the RFC 8555 ACME worker, the :80 challenge face, the :443 vhost face, the seal-derive anchor)) is live. seald (the evidence daemon: TPM2 + SEV-SNP, the attestation policy gate, the 6-op userdata control surface, the one-way latch, the secret store, the HSM — the delegated-sign / decrypt ops (the key never leaves seald), the per-unit key ACL, the three protocol surfaces (PKCS#11-like / OpenPGP smartcard / WebAuthn CTAP2), the PIN gate + the TPM monotonic counter, the per-unit HSM socket accept loop (the documented seam, wired), the admin face (the wardenctl target over a UDS + an optional in-sandbox TCP face)) is live. posternd (the back door: the SOLE :22 service — it serves the SSH face AND the wardenctl frame on :22, proxying the frame to the seald's admin UDS; in-process SSH, the userdata CLI verbs, the journald-style log reader, the status exec; the key gate is per-connection, not per-process) is live. wardenctl (the local trusted admin client: attest-first, verify-locally via the bootproof lib; the attest / facts / state / verify-receipt commands are wired end-to-end — the full attest VERIFIED round-trip through posternd from outside the VPC is wire-accepted; the userdata / seal / unit / keys commands are thin wrappers that print the seald's clean refusal for the not-yet-wired opcodes) is live. keepd (the disk daemon: LUKS lifecycle, two-stage PCR migration, named volumes, the OCI store, the data-integrity marker) is live. The warden's secret broker + dpfast escalation are implemented in the lib; the regent (including the SEALST01 seal-state persistence + the xdp param logic) and scribe (the lib, 42 tests) are implemented; their device/sink I/O is the integration seam. The gVisor stack (runsc/sentry/xdp_loader) is Go and stays; the bundle is shell-free at the init level (bastiond + co-tenants are native binaries) and posternd is in-process (no shell). Runtime linkage note (the distro consumer's contract): bastiond links bootproof, and bootproof UNCONDITIONALLY links the tss2 C stack (bootproof-tpm[esys] is a non-optional dependency). Its build.rs OWNS the whole link line (the tss2 .pc files' Libs lines are emptied in the Containerfile, so pkg-config emits no flags) and forces, in order: -ltss2-esys -lcrypto -ltss2-rc -ltss2-sys -ltss2-tcti-device -ltss2-tctildr -ltss2-mu (mu last: "referenced by most of the above") + the TCTI trampoline. So any distro bundling bastiond into its own rootfs MUST carry those libs or bastiond exit-127 crash-loops at init. The stagex COPY of the whole user-tpm2-tss package (+ core-openssl) covers all of them regardless of which specific NEEDED edges exist - bastiond booting alive proves the sufficiency; the flag list documents WHY the copy is needed, not a minimal set to hand-pick. This is the seald-bundle precedent; it applies to bastiond since the 2ce7277 serve seam (the first commit where bastion depends on bootproof - the gate only EXPOSED what was latent since then). Do NOT "disprove" this with a local ldd: on a Debian-family debug build the --as-needed linker drops unreferenced libs and shows no tss2 NEEDED; the stagex PRODUCTION link records them (build.rs forces them + the trampoline references the symbols), and the production link is what the rootfs contract governs. Each per-crate README states its status (what is proven prior-art vs. what is new work) so the implemented-vs-planned line is explicit, not implied.

Per-crate docs #

Crate README One line
core src/core/ the shared crates; the importable SDK
core/unit src/core/unit/ wardend-unit: the unit file format (parse/lower/validate/topo, implemented) + the compose/k8s converter (PLANNED) + bailiffd
core/moat src/core/moat/ the universal Moat contract
warden src/warden/ wardend (PID2): the keeper; units, moats, caps, syslog agent
regent src/regent/ regentd (PID1): reap + warden heartbeat/respawn
bastion src/bastion/ bastiond: the only thing that owns the wire
seal src/seal/ seald: tpm0 + sev-snp exclusive; the generic secret store (attest/seal/unseal/quorum)
keep src/keep/ keepd: disk/LUKS, named volumes, OCI store
scribe src/scribe/ scribed: RFC 5424 bus → store + serial + rsyslog
postern src/postern/ posternd: the administrative back door (the SOLE :22 service: SSH + the wardenctl frame + the proxy to seald's admin UDS); optional
wardenctl src/wardenctl/ wardenctl: the local trusted admin client (attest-first, verify-locally)
bailiff src/bailiff/ bailiffd: the optional k8s-worker adapter (Pod → units via the converter); reserved
moat-container src/warden/moats/container/ the default moat: kernel namespaces
moat-gvisor src/warden/moats/gvisor/ runsc user-space-kernel moat (proven)
moat-firecracker src/warden/moats/firecracker/ reserved microVM: REST/vsock
moat-nova src/warden/moats/nova/ reserved microVM: NOVA+Genode+Seoul (research-grade)
moat-sev-snp src/warden/moats/sev-snp/ reserved hardware moat: SEV-SNP CVM
moat-tdx src/warden/moats/tdx/ reserved hardware moat: Intel TDX

1. Why this shape #

The previous generation: a monolithic enclaved daemon plus a netstack supervisor shell plus two netstack co-tenant daemons; proved the stack but concentrated trust: one supervised shell loop owned DHCP, XDP, liveness, escalation, and two co-tenants. When that loop wedged on the wire, the recovery it owned died with it, and a terminal netstack dark needed a manual EC2 reboot. The suite is the structural answer:

  • no single supervised process owns both a workload and its recovery;
  • no suite daemon runs without a moat (the none primitive exists as an explicit per-unit trust decision, never as a default);
  • the wire is owned by exactly one daemon;
  • the controller is generic over how a unit is isolated, so a moat is a swappable, feature-flagged crate, not knowledge baked into the controller.

2. Security principles (designing to) #

  1. Minimal trust root. Only regentd (PID1) and wardend (PID2, the controller) run native. regentd is the thinnest possible PID1 — reap, heartbeat, fork — and cannot wedge. Everything else is behind a moat.
  2. Recovery never co-locates with its surface. No process owns both a workload and the recovery of its failure surface. The regent restarts the warden; a full guest reboot is the last resort below that.
  3. UDS-only internal comms. Every inter-daemon channel is AF_UNIX. bastiond is the only binary that knows TCP/IP; the rest may depend on at most "use a Unix socket."
  4. Network default-deny. bastiond is the only path to the wire, structurally: the kernel netns holds no lease.
  5. Isolation by default, permissions opt-in. Every unit is behind a moat (default container). No undeclared capabilities, devices, or mounts; the warden grants only what it holds, else fail-closed. none (no moat) is an explicit per-unit trust decision, never a default.
  6. Per-environment boundary. Each moat is its own feature-flagged crate; a build links only the moats its environment needs, so a binary's supply-chain surface is exactly what it was compiled with.
  7. Attestation-gated secrets. Every secret is sealed to a seald key (ephemeral, persist, or quorum); the persist and quorum keys are gated on all configured attestations passing. Secrets are released to wardend only, exactly once per boot, and injected as an env var (§6.5). seald is a generic store: it knows nothing about what a secret is for.
  8. No shell by default. No getty. The only shell is posternd — an optional back door, droppable from high-risk builds.
  9. Measured boot. The disk hash is a deterministic function of (commit, dirty); every phase that moves the tree ends with a re-BOUND (byte-level) + attestation PROVEN.
  10. Supervision without wait. Never waitpid a sandbox-control child: background + /proc poll + kill at deadline. A wedged child costs a zombie, not the supervisor.
  11. Honest degradation. Each moat declares a capability matrix; a feature a moat cannot provide fails closed at parse, never at runtime; a moat with unresolved gaps is reserved, not silently enabled.
  12. One daemon: one unit. A unit owns exactly one daemon; resources (wire, volumes, the log bus, sockets, secrets) are consumed, not co-owned.

3. The suite at rest #

Unit Moat Wire Owns
regentd native, PID1 none orphan reaping; wardend heartbeat + respawn
wardend native, PID2 none units, moats, capability grant, per-unit syslog agent, fleet provisioning
bastiond gvisor (the netstack) owns it uplink, netstack, DHCP/lease, AF_XDP, bridge, port/WS/TCP exposure, OCI download, user-data/IMDS
seald gvisor, no wire UDS-only /dev/tpm0 + /dev/sev-guest exclusive; attest.sock; the generic secret store (seal.sock/unseal.sock)
keepd gvisor, no wire UDS-only disk format + LUKS, named volumes, folder mounts, persistent OCI image store
scribed gvisor (no wire) UDS-only (+ serial) RFC 5424 bus → store + serial + rsyslog (via bastiond)
posternd (optional) gvisor UDS-only (bridged) the administrative back door: SSH + shell tools; log access
bailiffd (optional, reserved) gvisor UDS-only (tunneled) the k8s-worker adapter: Pod assignments → unit files (the converter), unit state → Pod status
user units container (default) / gvisor / microVM / CVM per-unit their entrypoint

4. Boot flow #

In the standard configuration demit execs regentd (PID1), which spawns wardend (PID2), the warden. In the thinnest configuration demit execs the warden directly (PID1) and the regent is simply absent.

heartbeat file / respawnunseal.sock (once per boot)env var (injected)seal.sock / quorum.sock(upload)attest.sock (nonce in,attestation out)named volumes, /var/log (rw|ro)OCI imagespublished ports / WS / TCPuser-data / IMDSdemittiny C init: unpacks erofs,mounts runtime fsregentd (PID1)wardend (PID2) : thewardensealdtpm0 + sev-snp : the secretstorekeepddisk / LUKS / volumesbastiondthe wirescribedthe log busposternd (optional)the back dooruser unitsthe outside world

Dependency order: seald first (device access + the secret store, needs nothing). wardend resolves each unit's declared secrets from unseal.sock (once per boot) before launching it, so a unit is blocked until its secrets are resolved (§6.5); keepd is blocked until its LUKS secret lands; bastiond (uplink → user-data → images); scribed; user units; posternd last — and it can unblock a unit by uploading a secret or providing a quorum share.

5. The wire surface: three exposure primitives #

bastiond is the only thing that touches the wire, and it exposes a unit to the outside by exactly one of three primitives, all of which keep the unit's own contract a Unix socket:

  1. Port forward. A unit with network = true listens on a TCP port in its netns; bastiond publishes it (veth pair, peer on the bastion side, forwarded to the wire). For workloads that already speak TCP.
  2. UDS → WebSocket. A unit listens on a Unix socket at a bind-mounted path under /run; bastiond bridges it to a WebSocket with no protocol knowledge. A "nonce in, attestation out" unit becomes an RPC-over-WS to the outside for free. This is the seald path.
  3. UDS → TCP. Same as (2) but the external side is a raw TCP session, not a WebSocket. For session protocols (SSH). This is the posternd path, so posternd's sshdt can stay UDS-only; bastiond relays host:22 ↔ the unit's UDS.

The two canonical dogfoods are suite daemons:

  • posternd exercises the UDS→TCP path (SSH on :22, published). It is the sole :22 service: it serves the SSH face AND the wardenctl framed protocol on the same port (the first 4 bytes of each connection disambiguate: an SSH- banner goes to the russh session; a small length prefix goes to the wardenctl frame, which posternd proxies to the seald's admin UDS). wardenctl is the host-side client for that frame: it connects to host:22, runs the attestation challenge first, verifies the bundle locally (the bootproof lib), and only then sends a control-plane command. The wire path is wardenctl → posternd :22 → seald admin.sock — seald is not directly reachable from outside.
  • seald exercises the UDS→WS path: attest.sock is "send a nonce, get back the attestation bound to it", which bastiond plumbs to ws://host:port/attest. This absorbs the old in-guest attestation face: the standalone bootproof repo remains the verifier; the in-guest face is now seald + the bastiond WS bridge.

bastiond also serves the fleet faces when the fleet is configured (BASTION_ACME set; empty = the fleet is skipped and the wire stays up): the :80 http-01 challenge face and the :443 vhost face (SNI peek + SNI routing + the TLS 1.2 relay; TLS 1.3 is supported — the supported_versions negotiation + the P-256 ECDHE + the HKDF-SHA256 key schedule + TLS_AES_128_GCM_SHA256). When the fleet is up, the vhost face is the :443 listener (a bind conflict with the attest.sock relay is logged, not fatal); when it is skipped, the attest.sock relay owns :443. So :443 is the attestation face by default, and the vhost/SNI face when the fleet is configured.

The other secret-store sockets (seal.sock, unseal.sock, quorum.sock) are never exposed; they are the internal secret store (§6.5).

WS connect + noncerelay nonce over attest.sock (UDS)fresh report / nonce-bound quoteattestationattestation documentattestation over WSoutside clientbastiond (WS)sealdtpm0 / sev-snpoutside clientbastiond (WS)sealdtpm0 / sev-snp

MicroVM/CVM moats: when a unit lives inside a VM, the moat crate proxies UDS ↔ vsock (host UDS ↔ in-VM vsock port), so bastiond still sees a host-side UDS and the external contract (WS/TCP) does not change when the moat does (§8.3).

6. Internal communication: the UDS socket map #

All inter-daemon channels are AF_UNIX sockets under /run/wardend/ (WARDEND_ROOT). Two liveness signals are deliberately files, not sockets: the anti-wedge primitive (a writer that dies just stops updating the file; a stale file is the signal, and nothing has to waitpid a peer):

Path Kind Writer Reader(s) Purpose
/run/wardend/caps.sock UDS wardend (listen) units (connect) capability discovery: a unit gates on a companion's caps before proceeding
/run/wardend/provision.sock UDS wardend (listen) CLI / external (connect) fleet provisioning control
/run/wardend/devices/scribe-write.sock UDS (SOCK_DGRAM) scribed (listen) wardend (connect, retried on every drain) log channel: the <unit>\0<severity>\0<line> datagram (the daemon's stdout/stderr, captured by the warden's log broker)
/run/wardend/attest.sock UDS seald (listen) bastiond (WS bridge) nonce → nonce-bound attestation (the only secret-store socket that is exposed)
/run/wardend/seal.sock UDS seald (listen) wardend; posternd encrypt + store named secrets; never exposed
/run/wardend/unseal.sock UDS seald (listen) wardend only read a named secret, exactly once per boot; never exposed
/run/wardend/quorum.sock UDS seald (listen) posternd supply m-of-n quorum key shares; never exposed
/run/wardend/postern.sock UDS posternd (listen) bastiond (TCP bridge) the sole :22 surface: the SSH face + the wardenctl frame (the first 4 bytes disambiguate)
/run/wardend/admin.sock UDS seald (listen) posternd (byte-pipe proxy) the seald admin face (the wardenctl target; the bootproof produce + the HSM state-log signing) — seald is NOT directly reachable from outside; the wire path is wardenctl → posternd :22 → this socket
/run/wardend/devices/hsm-<unit>.sock UDS seald (listen, per unit) the unit (connect) the per-unit HSM key socket: one per unit that declared secrets=; speaks the unit's proto= (pkcs11 / pgp / webauthn); ACL + PIN-gated
/run/wardend/bastion.ctl UDS bastiond (listen) wardend (connect) bastion control: publish port, expose socket, fetch user-data
/run/wardend/wardend.heartbeat file wardend regentd warden liveness (stale → regentd respawns)
/run/wardend/dp.status file bastiond (dpmon) wardend (watchdog) data-plane liveness (stale/dark → escalate)

Each unit also gets a writable runtime dir /run/<unit>/ (rbind), and may expose sockets there that bastiond bridges (§5). The rsyslog forward is not a scribed TCP socket: scribed writes to bastiond over a UDS and bastiond does the TLS-over-TCP to the rsyslog server, so scribed stays TCP-free (principle 3).

6.5 The secret store (seald) #

seald is a generic key/value secret store: it holds arbitrary secrets encrypted under one of three keys and knows nothing about what a secret is for — not LUKS, not API tokens, not who consumes it. What it knows: key names, the three keys, and the attestation policy.

The three keys.

  • ephemeral — created for this boot only; destroyed at shutdown. Secrets sealed to it do not survive a reboot.
  • persist — bound to the TPM and gated so it is usable only once all configured attestations pass (one TPM, two TPMs, one TPM + SEV-SNP, … — the policy is a composition, the key is still one). Secrets sealed to it are recovered automatically on every boot.
  • quorum — reconstructed from m-of-n shares, each share encrypted to the persist key and supplied to seald at any point during boot over quorum.sock. When the m-th share arrives the quorum key is reconstructed and itself sealed to the persist key, so it is available on later boots too.

The four sockets and their consumers.

Socket Consumer(s) Does
attest.sock bastiond (WS bridge) nonce in → nonce-bound attestation out
seal.sock wardend; posternd encrypt + store a named secret (first-time generation, or external upload — once per named key)
unseal.sock wardend only read a named secret, exactly once per boot
quorum.sock posternd supply quorum key shares

Only attest.sock is ever exposed (via the bastiond WS bridge, §5); the other three are internal. seald trusts its socket peers: anything holding unseal.sock access (only wardend) may read any secret by name.

The unit side: declared secrets. A unit declares the secrets it needs by name in its config (§7). wardend is the sole consumer of the store: before launch it fetches each declared secret over unseal.sock and injects it as an environment variable. The unit never touches seald, never sees the store, and does not know whether its secret is a LUKS key, an API token, or anything else. If a declared secret is not yet resolvable, wardend blocks the unit's launch until it is.

The lifecycle (the docker-compose model).

  • external = false (default) — create-if-first-boot, else reuse on unseal: on first boot wardend generates the secret and seals it (seal.sock); on every later boot it is unsealed under the persist key's attestation gate.
  • external = true — wardend never generates it; it must arrive via a posternd SSH upload (seal.sock, once per named key). This is the path for values like API tokens, where random generation is meaningless. A blocked unit is unblocked the moment the upload lands; once set, the secret is stored by seald and resolves on every future boot like any other.

Reboot semantics: a persist-key secret is unsealed again only if the PCR / attestation checks pass; a quorum-key secret additionally needs the quorum key (recovered from the persist key, or re-supplied via shares); an ephemeral secret does not come back at all.

6.6 User-data: the sole key source, the directives, and the seal #

The user-data is the sole key source. There are no baked keys and no config-drive merge: the EC2 instance user-data (on AWS, fetched by the wire owner; on QEMU, the seed file) is the one blob from which everything else is derived. It is measured (firmware hashes it into PCR 4), it is the input to the one-way seal (below), and it carries both the SSH public keys and the injection directives.

The directives (the real grammar, bastion::parse_seed). One directive per line; blank lines and # comments are ignored. A malformed line is logged and skipped (a bad directive must never take the wire down):

expose LISTEN=UDS      # publish a co-tenant UDS on a netstack TCP listener
offline UDS             # spawn + supervise an offline-srv on that UDS (UDS must be absolute)
unit UDS BIN [args...] [egress=yes|no]  # spawn + supervise a custom unit (UDS absolute)
  • expose LISTEN=UDS — publish a co-tenant's UDS on a netstack listener. The LISTEN side is a TCP address (0.0.0.0:443, 127.0.0.1:8080); the UDS side is the workload's Unix socket. The workload has no network of its own; the relay is its only way in. Canonical: expose 0.0.0.0:443=/run/wardend/seal.sock.
  • offline UDS — spawn + supervise an offline-srv co-tenant on that UDS (restart=always; the workload side of an expose pair).
  • unit UDS BIN [args...] [egress=...] — spawn + supervise a custom unit (any binary in the rootfs) with per-unit egress control (egress=yes|no; no = unshare --net, egress-less).

The SSH keys. The OpenSSH public key lines in the same blob (ssh-ed25519, ssh-rsa, ecdsa-sha2-*, sk-ssh-* — one key per line) are extracted by the back door and materialized as authorized_keys (0600, the keys dir 0700). The user-data is the ONLY key source: no baked keys, no config-drive merge. A blob with no key lines writes an empty authorized_keys, and the fail-closed key gate then refuses (no valid keys, no back door).

The IMDS fetch (bounded + background, the LLA-removal window). The wire owner runs the fetch in a background thread after the lease lands: it opens an LLA-removal window (drop the LLA 169.254.2.2/16, fetch 169.254.169.254/latest/user-data so the netstack sources the SYNs from the lease/ENI IP, re-add the LLA), then parses the body with the same parse_seed grammar as the seed file and merges the directives. Everything is bounded (a 5 s connect cap, an 8 s per-attempt deadline, a 64 KiB body cap, 5 attempts with a 2 s pause) — a wedged netstack must not hang the wire, and a blackholed IMDS (QEMU/slirp) just burns the attempts and falls back to the seed/argv config. The fetched body is also handed to the evidence daemon's latch over the userdata UDS (the same bytes that drive the relays become the attested, one-way latched control state).

A minimal user-data (the official docker hello-world container). Copy-pasteable, in the real grammar — the SSH key, the back-door face, the evidence daemon's face, and the fleet spec line that declares the docker.io/library/hello-world OCI image (the wire owner's OCI pull path; the fleet spec grammar, bastion::spec):

# SSH public key (the sole key source; materialized to authorized_keys)
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... operator@example

# the back door: the SOLE :22 service (UDS→TCP, bridged by the wire
# owner). The first 4 bytes of each connection disambiguate: the SSH
# banner goes to the russh session (human SSH + the userdata verbs),
# a small length prefix goes to the wardenctl framed protocol, which
# posternd proxies to the seald's admin UDS (a byte pipe; seald is
# not directly exposed).
expose 0.0.0.0:22=/run/wardend/postern.sock

# the evidence daemon: the attestation face (the framed binary
# protocol: [4-byte BE len][code][payload]; 1=attest). When the fleet
# is configured (BASTION_ACME set), the vhost face owns :443 instead.
expose 0.0.0.0:443=/run/wardend/attest.sock

# the container fleet: the official docker hello-world (offline by default)
container docker.io/library/hello-world:latest name=hello-world

The fleet spec line: container <image-ref> [sha256=<digest>] [name=<n>] [online] [ports=<csv>] [link=<l> …]. image-ref is a registry reference (host/repo:tag or host/repo@sha256:<digest>; defaults: host docker.io, a bare repo gets the library/ namespace). sha256= is the operator's pin (absent only when the ref itself is a digest ref). A link <name> containers=<a,b> [port=<p>] line declares a shared unix-socket link. A malformed spec line is a hard error (a half- parsed spec would let a typo'd pin silently drop out of the attestation check). The spec is part of the MEASURED user-data: the wire parses the lines to know what to pull, and the disk daemon parses the SAME lines from the SAME blob to know what to verify — the two never trust each other's output, only the blob and the store.

The back door as control plane (the posternd CLI surface) #

The back door is a self-contained control plane: in-sandbox, in-process, no shell. The operator-facing CLI (the current surface) maps onto the evidence daemon's 6-op wire protocol over the userdata UDS (WARDEND_USERDATA_SOCK, default /run/wardend/userdata.sock; the back door dials it in-process, one request line per connection):

verb wire op effect
get show print the current user-data state (hex, decoded)
set set_file replace the state; reads MULTIPLE kv pairs from STDIN (posternd set < /tmp/kv.txt)
seal seal one-way freeze of the user-data (the PCR 4 anchor becomes immutable; the LUKS data volume then only decrypts against the exact sealed value)
state state sealed/unsealed + the current / sealed hashes
verify verify re-run the persist-key-anchored verify (fail-closed on mismatch)
close close close the connection

Fail-closed: set_file after seal is refused (one-way latch; never silent); seal / verify with a gate-locked persist key fail closed (the honest reason, never a silent no-evidence); a connection failure (the evidence daemon is not up) is a clean error, never a panic.

Logs (journald-style, in-process, shell-free). The back door reads the scribe log store directly (no shell, no tail binary): per-unit folders at <store>/<unit>/unit.log (WARDEND_LOG_STORE, default /var/log).

form effect
logs all units, latest 10 lines
logs -n <N> all units, latest N lines
logs -u <unit> (repeatable) a named subset, latest N lines
logs -f live follow all units (ends on client disconnect / a bounded 30 s timeout)
logs -fu <unit> live follow one unit

status — the unit status exec (hostname / kernel / uptime / load / mem / net; each probe degrades to unknown rather than failing the whole status).

The seal: the two-phase PCR anchor model #

The seal is a one-way op. The model is two-phase, and the two PCR policies are the hinge:

  • Unsealed state = free modification. The user-data is malleable; the back door can add keys/units at will (re-injection, enrollment). The LUKS data volume opens under the seed PCR policy (WARDEND_LUKS_SEED_PCRS, default 5,7) — the safe default for a malleable state.
  • Sealed state = the user-data PCR (PCR 4) is immutable. The LUKS data volume (the disk daemon) then only decrypts against the exact sealed user-data value (the full PCR policy, WARDEND_LUKS_FULL_PCRS, default 4,5,7,9).

The persist-key anchor is the quote policy MINUS PCR 4 by default (WARDEND_PCR_ANCHOR). PCR 4 is input, not state: it is a configuration that changes per boot (a unit injection rewrites PCR 4), so anchoring the persist key to it would break the PCR-anchored unseal on every re-injection (PCR_CHANGED, fail-closed). The quote still covers PCR 4 (for transparency); only the anchor drops it (for stability). The anchor must be a subset of the quote policy.

The sealed state persists across reboots via the SEALST01 raw-disk-tail block. The devices dir is a per-boot tmpfs, so the sealed snapshot + sealed flag would be wiped on reboot. The regent mirrors the pattern: a fixed 512-byte block at the tail of the boot disk (immediately BEFORE the GPT-owned tail, not the last sector), layout `magic[8] ("SEALST01")

  • snapshot_len u32 LE + snapshot (≤256) + state_len u32 LE + state (≤64) + pad`. On boot, BEFORE the warden is spawned: read the block; if the magic is valid, restore the snapshot + state. All I/O failures are WARN-logged, never fatal (persistence, not the boot path).

The lifecycle (boot 1 → modify → seal → reboot → steady state):

  1. Boot 1 (first boot, seed PCR policy). The user-data is malleable. The disk daemon formats the LUKS volume under the seed PCR policy (keepd: first boot — formatted (seed PCR policy)). The operator modifies the state via the back door (set to add keys/units).
  2. seal. The one-way freeze. The PCR 4 anchor becomes immutable; the snapshot + sealed flag persist (SEALST01). The state file now says sealed.
  3. Reboot (steady state, full PCR policy). The disk daemon runs the seed→full PCR migration (keepd: migrated seed -> full PCR policy) and the volume opens only against the exact sealed user-data value (keepd: volume open (steady state)). A PCR-anchored verify runs at boot (fail-closed if the measured boot differs — but the gate passed, so it holds).

What the verify output looks like (the real shapes) #

The evidence daemon's gate line (bus log, one line per channel):

GATE PASS: tpm_quote=PROVEN, memory_encryption=PROVEN

(On QEMU, where /dev/sev-guest is absent, the SEV-SNP row degrades honestly rather than failing the gate: GATE PASS: tpm_quote=PROVEN, memory_encryption=NOT PROVEN (degraded). A present-but-bad channel is FAILED and fails the gate: GATE FAIL: tpm_quote=FAILED.)

The gate line is on the bus log (the seald's stdout/stderr, captured by the warden's log broker and shipped to the scribe — the gate.txt file is deleted; the log chain is the only channel). Read it back with the wardenctl / posternd logs verb:

<epoch> pass GATE PASS: tpm_quote=PROVEN, memory_encryption=PROVEN | <per-channel detail>

The state op's payload (posture + hashes):

posture=sealed hash=<hex of current> sealed_hash=<hex|none>

The verify op's response (the 6-op wire grammar: one line <status> [payload], where <status> is ok or err <reason>):

ok                                        # verify passed (sealed + consistent, or unsealed + open gate)
err latch: state hash mismatch (the state was altered, or the measured boot differs) — fail closed
err latch: persist key not available this boot (gate locked) — the state cannot be PCR-anchored; fail closed (nothing trusted)

The disk daemon's LUKS lifecycle lines (bus log):

keepd: first boot — formatted (seed PCR policy)
keepd: migrated seed -> full PCR policy
keepd: volume open (steady state)

(Other honest postures: keepd: volume open (seed policy; unsealed — user-data malleable), keepd: volume open (mkfs-recovery ran), keepd: volume locked (no key or unknown slot set; /home stays unmounted).)

7. The unit schema #

The full annotated schema, worked examples, and the symmetric k8s/wardend/compose table (the design) live in core/unit (wardend-unit); the bidirectional converter that maps them is PLANNED. The shape here:

name    = "app"                 # identity; one unit per daemon
command = ["/usr/local/bin/app", "--flag"]   # full argv, OPTIONAL (the unit
                                             # overrides the image entrypoint
                                             # when set; inherits it when not).
                                             # Required for `dir` rootfs.
user    = "0:0"
env     = { KEY = "value" }
env_file = ["/etc/app/env"]
rootfs  = { type = "oci", ref = "...", pin = "..." }   # or { type = "dir", path = "..." }
sandbox = {
  type    = "container"         # the default moat: kernel namespaces, native
  # type  = "gvisor"            # the proven user-space-kernel moat
  # type  = "none"              # built-in primitive: direct child, NO moat (explicit trust decision)
  # type  = "firecracker" | "nova"      # reserved microVM moats
  # type  = "sev-snp" | "tdx"           # reserved hardware CVM moats
  options = { ... }             # per-moat sub-block (§8)
}
capabilities = [ "CAP_NET_ADMIN" ]   # default-deny; granted iff wardend holds them, else fail-closed
devices    = [ "/dev/tpm0" ]
volumes = [ "home" ]
mounts  = [ { dest = "/var/log", volume = "logs", mode = "ro" } ]
network = false                 # bridges to bastiond when true
shares_netns_with = [ "..." ]   # a k8s-Pod-shaped group: shared netns
ports  = [ { internal = 8443, external = 443 } ]       # port-forward primitive
sockets = [ { path = "/run/seal/attest.sock", expose = "ws", external = 8443 } ]   # UDS→WS
sockets = [ { path = "/run/postern/postern.sock", expose = "tcp", external = 22 } ] # UDS→TCP
# a socket path is CANONICAL: reachable from any consumer in any moat
# (the moat provides the transparent bridge where the raw path cannot,
# core/unit §4)
secrets  = [ { name = "home-luks-key", external = false, key = "persist" } ]  # wardend injects as env var pre-launch; blocks until resolved (§6.5)
depends = { units = [ "..." ] }
when    = { file = "/run/db/ready" }   # file gate (anti-wedge; nothing waitpids a peer)
oneshot = false                   # run to completion, group proceeds, no restart
ready   = "/run/app/ready"        # this unit's readiness file
restart = "always"                # always | on-failure | no
resources = { cpu = "1", mem = "512M" }  # declared; enforcement pending cgroups (gap)
log     = { unit = "name", max = "32MB" }

The superset over docker-compose and k8s — and the bidirectional converter that maps them both ways (compose 1:1 over the shared-network / shared-dir primitives; a k8s Pod = a wardend guest / shares_netns_with group; superset deltas exported as comments/annotations rather than dropped) — is the PLANNED design in core/unit §5. Adding the optional bailiffd daemon makes a guest a kubelet-shaped k8s worker that emits unit files through that same converter (§6 there).

7.5 Repository layout, workspace, and the SDK #

wardend/
├── Cargo.toml                  # workspace root: members = every crate below
└── src/
    ├── core/                   # the shared crates (the SDK; universal, moat-agnostic)
    │   ├── unit/               # wardend-unit: unit schema (HCL parse, topo-sort, matrix check)
    │   │                       #   + the compose/k8s converter (§7)
    │   ├── moat/               # wardend-moat: the Moat trait + Handle + CapabilityMatrix (the contract)
    │   ├── caps/               # wardend-caps: capability model (ambient, default-deny, grant-if-able)
    │   ├── bus/                # wardend-bus: RFC 5424 over UDS (framing, identity stamps)
    │   └── bridge/             # wardend-bridge: the generic UDS↔WS / UDS→TCP bridge core
    ├── warden/                 # the controller: crate `warden` → binary `wardend`
    │   └── moats/              # moat crates: linked ONLY by the warden
    │       ├── container/      # moat-container (the default; kernel namespaces)
    │       ├── gvisor/         # moat-gvisor (proven; runsc user-space kernel)
    │       ├── firecracker/    # moat-firecracker (reserved microVM)
    │       ├── nova/           # moat-nova (reserved microVM; research-grade)
    │       ├── sev-snp/        # moat-sev-snp (reserved hardware CVM)
    │       └── tdx/            # moat-tdx (reserved hardware CVM)
    └── daemons/
        ├── regent/             # crate `regent`   → binary `regentd`
        ├── bastion/            # crate `bastion`  → binary `bastiond`
        ├── seal/               # crate `seal`     → binary `seald`
        ├── keep/              # crate `keep`    → binary `keepd`
        ├── scribe/             # crate `scribe`   → binary `scribed`
        ├── postern/            # crate `postern`  → binary `posternd`
        └── bailiff/            # crate `bailiff`  → binary `bailiffd` (optional; k8s worker)

Conventions and the three compile properties:

  • Folders/crates carry no d; the daemon binaries do. The crate seal is a library; it exports the daemon binary seald. Every daemon crate is a lib + a thin bin target. Moats are libraries only (no binaries).
  • Standalone. Every daemon compiles on its own: cargo build -p seal. A daemon's only in-repo dependencies are path deps on src/core crates. The controller is the one exception: it also links the moats enabled by its feature flags.
  • Whole workspace. cargo build at the root builds everything with the feature set that environment needs (--features gvisor etc.).
  • SDK. The src/core crates are self-contained libraries: they depend on no daemon and no moat, and on a deliberately small external dep set. An external project imports any of them by path or git dep: wardend-unit (parse/validate unit files), wardend-moat (the trait: implement your own moat), wardend-caps, wardend-bus, wardend-bridge. The moat crates are importable the same way (wardend-moat + moat-gvisor etc.) for projects that want to run a moat themselves.
  • Moats are warden-private. Moats live under src/warden/ and only the warden links them. Every other crate is moat-agnostic: it sees a unit through the universal wardend-moat contract and knows nothing about how the unit is isolated.
  • Direction of deps is one-way: daemons → core, warden/moats → core. Nothing in core knows about a daemon or a moat; no daemon links a moat. A CI dep-check enforces this, so the SDK boundary does not drift.

8. Moats: one universal contract, warden-private crates #

The controller (wardend) isolates units through a single Moat trait (crate wardend-moat, in src/core; contract docs at src/core/moat/). Each moat is a separate crate under src/warden/moats/ implementing that trait, selected by a cargo feature flag. wardend never names a moat in its supervision logic; it only calls the trait. No other crate in the repo links a moat: daemons are moat-agnostic by construction (the dep-check gate, §7.5).

The none sandbox type is not a moat. It is a built-in primitive of the warden: fork + exec a direct child in wardend's own environment (the kernel netns, full ambient caps, real host UDS). It exists so a no-moat build still runs, and so a user unit can explicitly opt into "no boundary, my own trust decision". Everything else about units is identical across moats: one process per unit, the same lifecycle, the same supervision discipline.

Per-environment builds: warden --features gvisor links only the gvisor moat; a build with no moat crates at all links only the core crates + the container moat (native, no external binary) + the none primitive. A build for an environment that will never run a VM does not compile, and therefore cannot be supply-chain-attacked through, the firecracker/nova/sev-snp/tdx crates.

8.1 The contract every moat must satisfy #

  1. spawn → handle (pid, control): one process per workload; pid for the process, control an opaque per-moat control endpoint.
  2. declarative pre-boot config: machine, kernel/rootfs, net, storage, caps, mounts.
  3. boot / liveness / stop / teardown: lifecycle over the control plane; teardown cleans up tap/cgroups/namespaces/files/socket.
  4. guest channel: a way to reach a UDS the workload listens on, so bastiond's WS/TCP bridge (§5) and the UDS socket map (§6) work unchanged. container/gvisor = rbind path; microVM/CVM = UDS↔vsock proxy.
  5. capability matrix: a static declaration of which unit fields the moat supports (§8.2); unsupported fields fail closed at parse.

8.2 Capability matrix (research-backed) #

none (built-in) container (default) gvisor (proven) firecracker (reserved) nova (reserved, research-grade) sev-snp (reserved) tdx (reserved)
family no boundary kernel namespaces user-space kernel microVM microVM (research) hardware CVM hardware CVM
control plane fork+exec unshare/mount/pivot (rustix, native) runsc CLI (external binary) REST/JSON over UDS (--api-sock) Genode run scenario / component tree; no host API today host-side VMM (QEMU/FC w/ CVM) host-side VMM (QEMU w/ TDX)
the handle the pid the pid + ns set runsc state + pid api-sock path + pid (jailer execs firecracker) Seoul VMM component; host handle must be built VMM pid + QMP/REST socket VMM pid + QMP/REST socket
guest channel real host UDS rbind path (host-visible) directfs / netns vsock (host UDS ↔ vsock port) + serial; no built-in agent: vsock is the channel, agent is ours no vsock, no virtio-net today: must be built vhost-vsock → UDS↔vsock proxy vhost-vsock → UDS↔vsock proxy
net kernel netns veth (bastiond) veth + AF_XDP redirect host creates the tap, virtio-net attach Seoul "intel network model" (not virtio-net); no host tap hand-off VMM tap, virtio-net VMM tap, virtio-net
storage direct /dev directfs rbind directfs rbind virtio-blk raw image ahci raw, or virtio-fs (FUSE folder, 2026) virtio-blk / virtio-fs virtio-blk / virtio-fs
rootfs source folder OCI extract / folder OCI extract / folder uncompressed kernel + ext4, no initramfs/UEFI (we provision both) OCI→raw (ahci) or OCI→folder (virtio-fs); conversion is our code kernel + ext4 (we provision) kernel + ext4 (we provision)
capabilities full ambient default-deny, grant-if-able OCI ambient, grant-if-able n/a: VM kernel is the boundary n/a: same n/a: CVM kernel is the boundary n/a: same
char-dev sinks direct mount-through mount-through not mountable: VM console / vTPM per-hypervisor vTPM / vsock / console per VMM vTPM / vsock / console per VMM
evidence guest-level only guest-level only guest-level only guest-level only (no VM-level) guest-level only (no VM-level) CVM-level attestation (sev-guest, VLEK chain) TD Quote (TDX quote, QGS)
self-protection (none) namespaces + ro rootfs + caps seccomp per runsc + user-space kernel firecracker seccomp; jailer ns/chroot capability model + (partial) formal spec the hardware boundary the hardware boundary

The strength ladder, weakest to strongest: none < container < gvisor < {firecracker, nova} < {sev-snp, tdx}. The hardware CVM moats are the only ones where the boundary itself produces evidence: the moat's own attestation (SEV-SNP report / TDX quote) is the evidence, not just the guest's. That is the distinguishing property of the confidential-computing moats, and the reason they are first-class rather than folded into the general microVM moats.

Schema consequence: capabilities and char-dev mounts are namespace-flavored; a VM/CVM moat must either map them (virtio-fs for mounts, vTPM for the char-dev sink) or reject the unit at parse, never silently drop them.

8.3 UDS ↔ vsock proxy #

For a microVM/CVM moat, a unit's UDS lives inside the VM on a vsock port. The moat crate runs a host-side proxy: a host UDS at the bind-mounted path ↔ the in-VM vsock port. bastiond and the UDS socket map (§6) only ever see the host-side UDS, so the external exposure (§5) and inter-daemon comms are moat-agnostic. This is the piece that makes "seald's attest.sock works whether it's in a container, a gvisor sandbox, or an SEV-SNP CVM" true.

9. What dissolves #

  • the netstack supervisor shell + data-plane watchdog → wardend-native supervision of the bastiond unit; regentd is the independent heartbeat at the top of the tree.
  • the gvisor-sandbox shell wrapper → native runsc management through the moat-gvisor moat.
  • the netstack attestation + SSH co-tenants → ordinary units: seald (UDS→WS) and posternd (UDS→TCP).
  • the monolith (attestation + storage + fetch) → seald + keepd + (fetch) bastiond.
  • getty/serial shell → posternd (the only shell, optional by default).

10. Green bar (redefined) #

  1. suite up: all units reach running and stay stable (no churn).
  2. real inter-unit communication: bastiond bridge (WS + TCP + ports) and shared-netns/socket paths exercised by the suite's own daemons.
  3. attestation face: ws://host:port/attest with a nonce returns the nonce-bound attestation, PROVEN by the standalone bootproof verifier.
  4. LUKS /home end-to-end: keepd declares its disk-key secret; wardend resolves it once the attestation gate passes.
  5. dmesg clean (0 traps / #GP / CFI / UBSAN).

Plus the standing bar: re-BOUND (byte-level) + attestation PROVEN on the rebuilt disk.

11. Accepted assumptions (the answered questions) #

  • UDS-only internal comms; only bastiond owns TCP/IP. Non-bastion daemons link at most a Unix-socket dependency.
  • Isolation by default; the none primitive is built-in to the warden (direct child, same environment, no moat) and is an explicit per-unit trust decision; capabilities are default-deny, opt-in.
  • Moats are warden-private (src/warden/moats, linked only by wardend); the contract is universal (wardend-moat in core); daemons are moat-agnostic. Per-moat crates, feature-flagged, so a build links only the moats its environment needs (supply-chain minimization). UDS↔vsock proxy in the microVM/CVM moats.
  • The SDK property (§7.5): every daemon builds standalone; the workspace builds whole; the src/core crates are importable by external projects.
  • bootproof stays a standalone repo (verifier); seald covers its in-guest face.
  • regentd/wardend native; scribe runs under gvisor (no wire); seal/keep gvisor (no wire); bastiond gvisor (the netstack is the proven wire path).
  • AF_XDP transport for bastiond now, abstracted for future transports.
  • Log store = /var/log/<unit>/ folders; /var/log ro in posternd.
  • rsyslog forward only if networked and a destination env var is set; TLS-over-TCP default; rides bastiond (scribed stays TCP-free).
  • Admin = posternd (SSH + shell tools, the back door), optional and droppable from high-risk builds; no getty anywhere else.
  • Moats: container (default, native) + gvisor (proven) now; firecracker/nova/sev-snp/tdx schema-reserved. nova is research-grade (no host spawn API, no vsock, no virtio-net today); sev-snp/tdx are hardware CVM moats (the boundary attests itself).
  • rootfs = OCI image | bare folder.
  • One daemon: one unit, always.

12. Phase plan (smallest-move-first; each ends re-BOUND) #

  • P0: the substrate (done). The gvisor-sandbox isolation fix is banked; the AF_UNIX-over-raw-rbind limit across gvisor sandboxes is recorded (a primitive-level fact, not a bug; the moats resolve it with a transparent socket lift, core/unit §4).
  • P0.5: docs (this mockup) (done). Root + per-crate + per-moat READMEs agreed before any code.
  • P1: regent split + warden substrate + the contract. regentd out; demit → regentd → wardend(PID2). The wardend-moat contract, the built-in none primitive, the moat-container (default) and moat-gvisor moats. wardend-unit (schema) + wardend-caps (default-deny, grant-if-able) + UDS capability discovery + the syslog UDS protocol (units buffer/serial-tail until scribe lands). SDK dep- check in CI. (done: the warden supervision core is implemented; the regent is implemented — the heartbeat/respawn + the reboot -f backstop are live, the SEALST01 persistence + the xdp param logic are in the crate; the device I/O is the integration seam.)
  • P2: bastiond (the keystone / main risk). AF_XDP transport (committed). Uplink ownership + bridge + port/WS/TCP exposure + user-data/IMDS + image download. Dogfood: seald's attest.sock→WS and posternd's :22 (UDS→TCP). Exit: kernel offline, netstack owns the wire, all three primitives proven on the wire. (done: the wire owner is live — LLA + DHCP + lease, the bounded background IMDS user-data fetch, the directive grammar, the expose/offline/unit relays, the OCI pull path, the fleet spec parser.)
  • P3: seald. Hardware channels + the secret store (attest/seal/unseal/ quorum, three keys) + wardend's secret broker (declared secrets → env vars, launch gating). Exit: seald up, attestation PROVEN through the bastiond WS bridge by the standalone verifier; a declared persist-key secret survives a reboot. (done: the evidence daemon is live — TPM2 + SEV-SNP, the policy gate, the 6-op userdata control surface, the one-way latch, the secret store; the warden's secret broker is implemented in the lib.)
  • P4: keepd. Disk lifecycle + named volumes + folder mounts + persistent OCI store; LUKS unseal from its declared secret. Exit: /home LUKS end-to-end; pull-once-forever image store. (done: the disk daemon is live — LUKS lifecycle, two-stage PCR migration, named volumes, the OCI store.)
  • P5: scribe + posternd. scribe lands (store / serial / rsyslog, under gvisor); posternd lands (SSH + shell tools, UDS→TCP, droppable, secret + quorum-share upload). Exit: PING→PONG between networked units on the designed path; an external-secret unit is unblocked by an SSH upload and stays resolved across a reboot; admin over the back door works and is absent from a no-postern build. (posternd: done — the back door is live, in-process, with the userdata CLI surface + the journald-style log reader; scribe: the lib is implemented + tested (42 tests); the UDS accept loop + the sink I/O are the integration seam.)
  • P6: cutover + proof. Green bar re-run, QEMU, AWS, re-BOUND + attestation PROVEN, netstack cost numbers unchanged.
  • P7 (later): microVM + CVM moats. firecracker (UDS↔vsock proxy, tap, virtio-blk); sev-snp + tdx (hardware CVM moats: the boundary attests itself); nova only once its host control channel + vsock are real (research).
  • P8 (later): the compose/k8s converter + bailiffd. the wardend-unit converter (§7, core/unit §5) over a golden compose + Pod corpus, both directions with the round-trip property tested (compose → units → compose, Pod → units → Pod; superset deltas preserved as comments/ annotations); then the optional bailiffd daemon makes a guest a kubelet-shaped k8s worker (Pod → units through that same converter; unit state → Pod status, the held state as waiting: Attestation). Reuses the exposure + secret + provision surface; adds no new trust (UDS-only on the guest side, bastiond-tunneled to the control plane).

13. Risks #

  • P2 transport is the real technical unknown (AF_XDP committed to de-risk it; the transport is abstracted so a swap is not a rewrite).
  • Every phase is a re-BOUND (the measured-boot tax): the cost of changing a proven, attested stack.
  • Minimal deps on wardend/regentd must be enforced (workspace boundary + a dep check), not merely intended, or they drift; the feature-flag moat isolation and the "moats are warden-private" rule are hard gates, not conventions.
  • regentd is the new trust root: keep it minimal; a wedged regentd has no supervisor (reboot is the backstop).
  • The UDS→WS / UDS→TCP bridges are generic by design: they must not grow per-protocol logic, or seald stops being "a socket that takes a nonce."
  • seald is a generic store by design: it must not grow knowledge of what a secret is for (LUKS, API tokens, …). A secret's meaning lives in the declaring unit's config and its consumer's code — seald knows names, keys, and the attestation policy, and nothing else.
  • posternd is the weakest point by construction (a shell into the guest). Mitigations: key-gated (authorized_keys from the provisioner), optional, droppable from high-risk builds, and the one unit a high-risk build omits entirely. It exists because the back door is more honest than the implicit getty it replaces.
  • The SDK boundary is a public surface from the moment an external project imports a src/core crate: the core crates' dep sets and APIs are frozen-by-intent, and the dep-check gate protects them.
  • The reserved moats are reserved for a reason: nova in particular has no host control API, no vsock, and no virtio-net today. Enabling a moat before its contract is fully backed is the "silently drop a field" failure the capability matrix exists to prevent.