Skip to content

S06-17 - Named Images and Recipes

Purpose: The build of a named image from a recipe on a clone of the sealed base. The recipe, the built-in Homebrew recipe, the VM and network of a recipe build, what makes the result trusted, its provenance, and which image a VM runs.

Requirements: FR06-native-toolsFR06-native-tools: Native guest toolsAgent tool calls run tools native to the guest operating system (on macOS guests: Homebrew packages, Xcode command line tools, optionally full Xcode)., FR07-toolchain-manifestFR07-toolchain-manifest: Declared toolchainA project's toolchain is declared host-side (on macOS guests, a Brewfile) and reconciled automatically before a session starts., NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host., SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy., SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter., SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.

Tests: C09-guest-and-sessionsC09-guest-and-sessions: Guest and SessionsThe test cases for what a project user can reach inside the guest, wb-guestd's update and the guest clock, the shared toolchain prefix, the guest admin password, and the session lifecycle., C11-host-daemonsC11-host-daemons: Host Daemons, Audit, and DisksThe test cases for the host daemons' own checks: wb-vmd's device set and slots, the image build bundle, supervision, the accounting and event channels, the daemon log pipes, the audit writer, free space, and the data…

Brief: B150-named-imagesB150-named-images: Which VM runs a recipe, and how does a recipe build get through the proxy?A new recipe VM, `wb-vmd-recipe`, with a network of its own and the build CA installed at runtime and removed before sealing.

host: trusted wb-hostd recipe from user settings, clone, steps, audit, take wb-vmd-recipe recipe slot, one network device wb-proxyd build policy, CA wb-netd the recipe VM's own Homebrew's hosts github.com, ghcr.io, formulae start streams allowed only audit records recipe VM: a clone of the sealed base wb-guestd named operations, CA removal, comparison and sealing scan _wbtool Homebrew, formula snapshot, bottles into /opt/homebrew host-guest socket frames boots
A recipe build. wb-hostd clones the sealed base into the build bundle and starts wb-vmd-recipe, which boots it with one network device. wb-hostd sends the recipe's steps to wb-guestd over the host-guest socket, and wb-guestd runs them as the toolchain user. Their fetches go through the recipe VM's own wb-netd and wb-proxyd, under the compiled-in build policy, to Homebrew's hosts, and wb-hostd audits each one. Before sealing, wb-guestd removes the build CA and compares the image with its parent. After wb-vmd-recipe exits, wb-hostd takes the sealed image.

A named image is a clone of the sealed base, with a recipe run on it, sealed again before any agent or project code runs (I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image.). Many sessions start from the same named image. Its Claude Code layer goes on top, as on the base (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Derivation”).

A recipe is a TOML file in the user’s settings, <config>/images/<name>.toml. The file name is the image’s name:

# <config>/images/python-dev.toml
include = ["homebrew"]
formulae = ["python@3.13", "uv", "mise"]
xcode = false

The keys are closed. wb-hostd refuses a recipe with any other key, a name outside the rule, an include it can’t find, or an include cycle, and logs the file, the rule and the line. It bounds the file’s size, the include depth, and the number of names in code. A recipe with formulae and no path to the homebrew recipe through its includes is refused with recipe-needs-homebrew. The parser has a fuzz target.

An image’s name matches ^[a-z][a-z0-9-]{0,31}$. base and the names of the built-in recipes are reserved for those, and a user recipe with one is refused with recipe-name-reserved.

An image is trusted by every session that uses it. So recipes come only from <config>/images/. A repository’s .wraithbox/ never defines one, whatever its config_trust (SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy., S09-03-project-settingsS09-03-project-settings: Project SettingsWhat a project's settings hold, and what a repository's own .wraithbox/ configuration may add., “Closed keys”). Wraith Box has no organization layer. Recipes an organization supplies wait for an organization design.

The base has no Homebrew (S06-16-base-layerS06-16-base-layer: The Base LayerWhat the base layer holds, how the image build installs Apple's Command Line Tools from a package the host fetched, and the toolchain user that named images and project layers install as.). The built-in recipe homebrew adds it, compiled into wb-hostd, and never read from a file. It runs these named operations of wb-guestd, as the toolchain user:

  1. install-homebrew fetches Homebrew from https://github.com/Homebrew/brew at the pinned tag into the prefix. It refuses a checkout whose commit isn’t the pinned commit.
  2. write-formula-snapshot writes the snapshot of Homebrew’s formula API that keeps project layers from upgrading kegs (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “A reconcile only adds”).

The tag and the commit are in one place in the code, which Renovate bumps. A bump changes the recipe’s hash. The next build then rebuilds every image that includes homebrew.

A plain wb image build builds the base, the homebrew image, and the image of each recipe in <config>/images/. So every machine has a package manager for FR07-toolchain-manifestFR07-toolchain-manifest: Declared toolchainA project's toolchain is declared host-side (on macOS guests, a Brewfile) and reconciled automatically before a session starts. (a project’s declared toolchain) without a recipe of its own. wb image build <name> builds one named image, and the base first when the base is out of date.

A recipe’s steps run in wb-vmd-recipe, the wb-launcher entry of the recipe slot (S04-04-vm-processesS04-04-vm-processes: Per-VM ProcessesOne wb-vmd for each VM, the wb-vmd-layer entry of the Claude Code layer build, the wb-vmd-recipe entry of a named image's recipe, and wb-diskfmt, which formats a VM's new data disk.). It is a maintenance VM, so it borrows the isolated VM’s slot, and one maintenance VM runs at a time (S06-07-slot-admissionS06-07-slot-admission: Slot AdmissionHow wb-hostd admits every macOS VM it starts against the limit of two, and lends the isolated VM's slot to a maintenance VM., NFR05-two-macos-vmsNFR05-two-macos-vms: Platform limitmacOS permits at most two concurrently running macOS guests per host.).

  1. wb-hostd clones the sealed parent into a new, empty build bundle, with the identity check of S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Taking the sealed image”. The parent is the base, or the sealed result of the recipe’s Xcode step.
  2. It starts wb-vmd-recipe, which boots the clone with one network device, and no Xcode disk.
  3. At first contact, wbadmin’s password is rotated, as in the Claude Code layer build (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “The Claude Code layer”).
  4. wb-guestd installs the recipe VM’s CA (“TLS during a recipe build”).
  5. wb-hostd sends the resolved recipe’s steps, one named operation at a time. A failed step fails the build.
  6. wb-guestd removes the CA, and the image is sealed (“What makes a named image trusted”).
  7. After wb-vmd-recipe exits, wb-hostd takes the sealed image as in S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Taking the sealed image”.

The named image is then the parent of its Claude Code layer.

The recipe VM has its own wb-netd and wb-proxyd path, as a session VM has, with the VM name recipe. Its policy is the build policy, compiled into wb-hostd:

No user, project or repository policy applies to it, and it gets neither approvals nor learn mode. Every other destination is refused and logged (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.). Each decision is an audit record of the build, not of a session (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.). Its only credential binding is the anonymous ghcr.io value of S07-10-anonymous-credentialsS07-10-anonymous-credentials: Anonymous CredentialsHow wb-proxyd answers hosts that want a token even for public reads, without forwarding the guest's token..

wb-proxyd accepts the recipe VM’s hand-off in session mode only, with the build policy only (S07-05-stream-hand-offS07-05-stream-hand-off: Stream Hand-offHow wb-netd hands each stream to wb-proxyd, and the checks that keep a compromised wb-netd from widening what a stream may reach.). The dependency gate doesn’t check what a recipe fetches. A recipe installs homebrew/core bottles, and bottles aren’t gated (S07-12-dependency-gateS07-12-dependency-gate: Dependency GateHow wb-proxyd keeps young and vulnerable package versions from the guest on the gated registries., “Homebrew”, T08-homebrew-ungatedT08-homebrew-ungated: Young Homebrew bottlesHomebrew bottles from homebrew/core are not age-gated or checked against OSV.).

The sealed image contains no Wraith Box CA (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Layers”). The recipe VM gets a CA of its own, as every VM does (S09-07-ca-certificatesS09-07-ca-certificates: CA CertificatesThe profile and scope of each TLS inspection CA, the leaf certificates it signs, and its rotation., “Scope”).

  • At first contact, wb-guestd writes it to the trust files of S09-08-guest-trustS09-08-guest-trust: Guest TrustHow wb-guestd makes the guest's clients trust the VM's CAs., as for a session VM.
  • Before sealing, the named operation remove-trust deletes /etc/wraithbox/, without following symbolic links. It first checks that the directory belongs to root, isn’t a symbolic link, and holds only trust/. Otherwise it fails with trust-remove-refused, and the build fails.
  • The sealing scan refuses an image that holds /etc/wraithbox/, or the build CA’s certificate, in DER or PEM, in a file it reads.

The scan reads every regular file in the prefix, the toolchain user’s home and /Users, which the comparison doesn’t cover. It also reads every file the comparison finds added or changed elsewhere (“The comparison” below).

The CA’s key goes on the removal list when the build ends (S09-06-ca-keysS09-06-ca-keys: CA KeysHow the key of each TLS inspection certificate authority is made, stored and restored, and when a CA is valid.).

The recipe runs as the toolchain user. wb-guestd runs a recipe step only through its named operations, and none of them takes a command, a path or a URL. The privileged operations of a recipe build are only the rotation, the CA’s install and removal, and the seal.

Each seal ends with wb-guestd writing the seal manifest, a root-owned file of mode 600. It lists every entry outside /Users: its path, type, owner, group, mode, flags, change time, and a link’s target. Every seal writes one, the base’s included (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”). wb-hostd keeps the manifest’s SHA-256 in state.db: with the image record, and for the sealed result of an Xcode step, which isn’t an image, with the build record of its named image.

Before the recipe VM is sealed, wb-guestd compares the image with the parent’s manifest. wb-hostd first checks that the manifest’s hash equals the one it kept. The seal fails with seal-changed-outside-toolchain, and names the first path, on an entry added, removed or changed outside:

Then the full sealing scan runs (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”).

A local privilege escalation from the toolchain user to root in the recipe VM defeats these checks in the guest, as it would any seal. The recipe narrows that to homebrew/core bottles and Homebrew’s own code (T15-shared-toolchainT15-shared-toolchain: Projects in one guest share the toolchain prefixEvery project user runs tools from the one prefix that the toolchain user owns (S06-01-image-layers, "Toolchain prefix").).

state.db records for each named image:

  • its parent image;
  • the SHA-256 of the resolved recipe, in a canonical encoding with the includes expanded;
  • the path of its build log;
  • the range of its build’s audit records.

wb image list shows the parent and the recipe hash next to each image (S05-03-management-commandsS05-03-management-commands: Management CommandsThe commands of wb other than the agent commands., “wb image”).

wb image shell [<name>] boots a clone of the base, or of the named image’s parent, in wb-vmd-recipe with the build policy. It runs /bin/zsh -l as the toolchain user, with the environment of S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “The environment”. When the shell ends, wb-hostd deletes the build bundle. It never seals or stores the image. It takes the maintenance slot, as a build does.

The work VM runs one image, which the user picks with wb image use work <name>. The isolated VM does too, with wb image use isolated <name>. A new VM runs the homebrew image.

A project may name the image it needs, in its image setting (S09-03-project-settingsS09-03-project-settings: Project SettingsWhat a project's settings hold, and what a repository's own .wraithbox/ configuration may add., “Settings contents”):

The project layer still installs at session start, on top of the image (S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Toolchain prefix”).

The build CA installed at runtime, and removed before sealing

Section titled “The build CA installed at runtime, and removed before sealing”

Status: Draft