Skip to content

S04-04 - Per-VM Processes

Purpose: One 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. The wb-vmd-install entry of an image build is in S04-10-vmd-installS04-10-vmd-install: Installing macOS in `wb-vmd`The wb-vmd-install entry of an image build: its install rules, the restore image it reads, the build bundle it installs into, and its Install call..

Each VM has its own wb-vmd. wb-launcher has two fixed entries for them, wb-vmd-work and wb-vmd-isolated:

  • Each has that VM’s bundle as its profile parameter: <data>/vms/macos-work.noindex or <data>/vms/macos-isolated.noindex.
  • Each has an instance cap of one.

Each instance learns its slot from the WB_VMD_SLOT environment variable. The variable is part of its launcher entry’s fixed environment:

Entry WB_VMD_SLOT
wb-vmd-work work
wb-vmd-isolated isolated
wb-vmd-install (S04-10-vmd-installS04-10-vmd-install: Installing macOS in `wb-vmd`The wb-vmd-install entry of an image build: its install rules, the restore image it reads, the build bundle it installs into, and its Install call.) build
wb-vmd-layer (“wb-vmd-layer”, below) layer
wb-vmd-recipe (“wb-vmd-recipe”, below) recipe

The slot never comes from the program path or a request. So the slot and the bundle come from the same table entry. On hosts without wb-launcher, wb-hostd sets WB_VMD_SLOT when it starts wb-vmd, and the same refusals apply.

wb-hostd creates each bundle directory, never as a symbolic link, before it asks wb-launcher to start the entry. It checks the path with lstat and never follows it. A symbolic link, or anything but a directory, refuses the start with vm-bundle-not-directory. It creates a new, empty build bundle before each build.

Before it confines itself, wb-vmd refuses to start, logs the rule and exits:

So it never confines itself to a bundle its slot doesn’t own (SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another.). 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… tests each rule.

wb-vmd-install serves build. It has the install rules and the restore image check (S04-10-vmd-installS04-10-vmd-install: Installing macOS in `wb-vmd`The wb-vmd-install entry of an image build: its install rules, the restore image it reads, the build bundle it installs into, and its Install call.). Until the layer build is built (V1-M7-image-buildV1-M7-image-build: Image buildwb image build downloads the restore image and the Command Line Tools, installs and provisions a VM over the build network, installs the minimal base layer, and installs Claude Code in its own top layer.), wb-vmd refuses the layer slot (vmd-slot-layer-unsupported). wb-vmd-layer alone serves layer. It has no install rules and no restore image check, and it uses the build bundle too (“wb-vmd-layer”, below). Until the recipe build is built, wb-vmd refuses the recipe slot as well (vmd-slot-recipe-unsupported), and wb-vmd-recipe alone serves it.

wb-hostd reaches each instance only over the channels it handed that instance at spawn: its control channel and its hand-off socketpair (S04-02-vm-providerS04-02-vm-provider: VM Provider and StreamsHow wb-vmd hands guest connections and the NIC endpoint to other processes, the fixed device set of a VM, and where wb-proxyd takes a stream's identity from., “The VM provider passes descriptors, not bytes”). The channel a message arrives on says which VM it’s about. No request names a VM, a slot, or a path.

wb-hostd cuts each text a wb-vmd returns, in a refusal or a framework error, to a fixed bound before it logs it or passes it on.

wb-hostd treats the contents of every VM bundle as written by a possibly compromised wb-vmd. It opens, clones and deletes files in a bundle without following symbolic links. It checks a file’s identity before it uses one, as for the sealed disk of an image build (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., “Built by Wraith Box”).

The Claude Code layer build boots a clone of a sealed parent 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., “The Claude Code layer”). It installs nothing from a restore image, so it doesn’t run in wb-vmd-install. It runs in a fourth fixed entry, wb-vmd-layer:

wb-hostd clones the parent into the 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”.

A named image’s recipe runs in a clone of its parent with a network (S06-17-named-imagesS06-17-named-images: Named Images and RecipesThe build of a named image from a recipe on a clone of the sealed base., “The recipe VM”). It runs in a fifth fixed entry, wb-vmd-recipe, which differs from wb-vmd-layer only in these:

So wb-vmd-layer’s VM never has a network device, whatever a start call says.

wb-diskfmt formats a VM’s new data disk (S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk., X08-data-diskX08-data-disk: Data disk for homesGuest user homes on a second disk, surviving a system-disk replacement.), or an image build’s Xcode disk (S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records.). wb-launcher has three fixed entries, wb-diskfmt-work, wb-diskfmt-isolated and wb-diskfmt-xcode. Each takes no arguments, and has its slot’s bundle as its profile parameter (the build bundle and, for xcode, the parameters in S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records., “The entry”), and an instance cap of one. Its shim is started as the leader of a new process group, so that its parent can kill the shim with the diskutil it runs (S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk., “When wb-diskfmt doesn’t exit”). On hosts without wb-launcher, wb-hostd starts the entry itself, with the entry’s fixed environment and descriptors, as it starts wb-vmd.

Its start interface:

Before it confines itself, wb-diskfmt refuses to start, logs the rule and exits:

  • with an argument (diskfmt-arguments);
  • when the variable is missing (diskfmt-slot-missing);
  • when it holds any other value (diskfmt-slot-unknown);
  • when its slot’s bundle path doesn’t exist or isn’t a directory (diskfmt-bundle-missing);
  • when the real path of that bundle isn’t that slot’s bundle under the real path of <data> (diskfmt-slot-bundle-mismatch).

It finds <data> from the home directory in the user database, never HOME. 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… has a test for each rule.

  1. As wb-vmd does, it resolves the bundle path with realpath to get its profile parameter. It reads nothing from wb-hostd before it confines itself.
  2. After that, it exchanges version records with wb-hostd (S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs., “Between host processes”). A data disk entry receives the disk’s size in GiB, and refuses a size outside the bounds in code with diskfmt-size-invalid.
  3. A data disk entry sends the volume UUID back, renames the file when wb-hostd asks, and exits. The Xcode entry’s exchange (its size, the check-only request, and the version, build and hashes it reports) is in S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records., and joins diskfmt/v1 in IMG.8.

wb-hostd treats each answer as untrusted. It accepts a volume UUID only in canonical form, and a name only when it is the fixed one, and it cuts a refusal’s text to a fixed bound.

The compiled-in profile allows:

  • reading and writing the data disk’s temporary and final names in that bundle, and reading the bundle directory’s metadata. The bundle’s other files are guest-written, and the shim can’t open them;
  • its inherited descriptors;
  • starting /usr/sbin/diskutil and no other program, with the system’s libraries and settings read-only, and listing the root directory, which dyld reads to find the shared cache;
  • the metadata of the /dev/disk* nodes, whole disks and slices, but not their contents;
  • the services diskutil reaches: the disk image controller, Disk Arbitration, storagekitd, and Authorization Services (com.apple.authd), which the attach asks.

The file rules bind only the shim’s own opens. The disk services run outside the sandbox and act on the disk a request names, so a subverted shim could erase, mount or unmount any disk the host user may, and list the host’s disks. Seatbelt can’t filter what a request to a service asks for, so the profile can’t narrow that.

The authd rule lets a subverted shim ask for authorization rights. A right that needs authentication shows a real administrator password dialog, and gains nothing unless the user enters a password. A right that doesn’t is granted to an administrator’s session without a dialog, which is within the host user’s own powers. diskutil can’t attach an image without that service (I353I353 (closed): wb-diskfmt: measure its sandbox profile on the host and decide the iokit-get-properties rulePR #352 (#289) gives wb-diskfmt a self-sandbox profile (packages/wraithbox-go/cmd/wb-diskfmt/profile.go) that no confined run has measured yet.).

These rest on the shim’s inputs: it takes no guest input, only wb-hostd’s request, and it exits after one format and is never restarted. It denies the network and every other file, except the Xcode entry’s reads and programs in S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records.. The Xcode entry also reaches com.apple.trustd.agent, which codesign needs. That service runs outside the sandbox and may fetch from the network to evaluate a certificate, so a subverted shim can make the host user’s trust service fetch on its behalf (S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow the host builds the read-only disk that holds Xcode and the simulator runtimes for an image build, under the wb-diskfmt shim's profile, and what the build records., “The profile”). The service names are in code. They were measured on macOS 27 with the opt-in host test, which runs a confined format (I228I228 (closed): X08-data-disk follow-up: measure that a host-made data volume stays unencrypted and returns freed spaceX08-data-disk (PR #227) recommends option A: the host formats the data disk as APFS.).

wb-hostd keeps the wait for the shim’s answer, and decides when a shim that doesn’t exit is killed (S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk., “When wb-diskfmt doesn’t exit”). On macOS it can’t send the kill. Its profile denies signal to other processes, and it isn’t the parent, so it can’t tell whether the shim was reaped. So it asks wb-launcher on the request channel, in one fixed-format request that names the entry and the instance ID (S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Who starts whom”).

  • Refused. wb-launcher refuses a kill for an entry other than the wb-diskfmt entries, and for an instance ID it never returned. It signals nothing, and logs the refusal with the rule launcher-kill-refused.
  • Already exited. For an instance it started and has reaped, it signals nothing. Instance IDs aren’t reused (S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Who starts whom”), so that ID can’t name a newer shim.
  • Sent. Otherwise, while it hasn’t reaped the shim, it sends SIGKILL to the shim’s process group and to the shim, and logs the decision with the rule launcher-kill. The shim’s ID, which is also the group’s ID, isn’t reused before that reap.
  • The answer. Its answer is one of: sent, already exited, refused with its rule, or the signal failed. The exit report may come before the answer or after it, and wb-hostd matches the two by instance ID.

Where wb-launcher writes the lines for launcher-kill and launcher-kill-refused is decided in M3.11. They don’t go only through wb-hostd, so the wb-hostd that asked for a kill can’t hide it.

wb-hostd bounds its wait for the answer and for the exit report. No answer in time, or the end of the request channel, counts as a kill that failed. wb-hostd then logs data-disk-shim-exit with that outcome, as it does when its own kill fails today. Each outcome, the launcher’s rule included, is in that line (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).

Without wb-launcher, wb-hostd is the parent, and sends the kill itself under the same gate.

Status: Draft