Skip to content

S04-03 - Self-Sandboxing

Purpose: How each host daemon confines itself at startup, and the wb-launcher that starts confined programs on macOS.

Host processes confine themselves at startup with the platform’s mechanism (S12-platformsS12-platforms: PlatformsWhich host and guest operating systems Wraith Box targets, how platform-specific code is isolated, what each platform uses, and how wb works inside WSL.). Each then gets only what it needs:

Process What it keeps
wb-netd no filesystem, and no network beyond inherited descriptors
wb-proxyd outbound network, certificate checks, and its credential store items (“wb-proxyd and the secret store on macOS”)
wb-download outbound HTTPS and its inherited descriptors
wb-guestadmin its wbadmin/* store items and inherited descriptors
wb-credset its binding/* store items and its standard streams (S15-02-secret-storeS15-02-secret-store: The Secret StoreWhere credentials are held: the secret store, its backends, and the guarantees a backend must give., “Keychain”)
wb-hostd its state directories; on macOS also read access to the installed bundle’s Info.plist (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., “Upgrades”) and to each helper bundle’s embedded.provisionprofile (S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed., “Development builds on macOS”)
wb-vmd the hypervisor and its VM’s bundle

This hardens our own code. It is not how the agent is contained: the VM is. The sections below say how it is done (X23-sandboxed-daemonsX23-sandboxed-daemons: Self-sandboxed Go daemons on macOSCan wb-netd, wb-proxyd and wb-hostd confine themselves at start with a sandbox profile, as S04-architecture says, while the Go runtime, inherited descriptors, and Keychain and Secure Enclave access in wb-proxyd keep w…, SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts.).

A daemon confines itself first thing in main, from a profile compiled into it, and exits if that fails. Nothing before that reads an inherited descriptor, the arguments or the environment. Right after, it tries one operation its profile denies, and exits if that succeeds.

One shared call in internal/platform/selfsandbox confines the process and runs the probe, so no daemon can leave the probe out:

  • Before it confines, it refuses a profile whose parameter names don’t equal the names of the values given, and a value that is empty or holds a NUL byte. The process is then still unconfined, and the daemon exits.
  • The probe reads /etc/passwd, which every profile denies. The read has to fail with EPERM. Success, or any other error, makes the daemon exit. The probe shows that the profile applied. It doesn’t show that the profile denies all it should: each daemon’s own self-checks and the profile’s review do that.

wb-vmd is written in Swift, so it has its own call, Confinement in WraithBoxVMD. Its parameter names are fixed in code. It refuses an empty value or one with a NUL byte with vmd-sandbox-param-invalid, and runs the same probe.

wb-hostd is one exception. Before it confines itself, it:

  1. reads its own configuration;
  2. sets GOMAXPROCS;
  3. loads the local time zone;
  4. starts wb-launcher (on macOS);
  5. resolves the git binary from <config> or the fixed platform path, never from PATH;
  6. checks that git’s version is at least the minimum (S08-08-host-gitS08-08-host-git: Host GitWhich git binary runs on the host, the oldest version Wraith Box accepts, and where that is checked.), and that git honors GIT_ALLOC_LIMIT (S08-04-push-checksS08-04-push-checks: Push ChecksThe checks that bound the memory and work of a push before git unpacks it: git's allocation limit, the pack scanner, and the pre-receive check., “Pack scanner”);
  7. works out the paths for its profile.

None of that reads anything the guest sent.

wb-vmd on macOS is a second, bounded exception. Before it confines itself, it:

It doesn’t read anything from the guest or wb-hostd before it confines itself.

How wb-vmd is started, its descriptors and its gRPC socket, is in S04-11-vmd-startS04-11-vmd-start: Starting `wb-vmd`What wb-vmd inherits from its spawner, the socket it serves gRPC on, its lifeline, and the checks on each connection..

The profile’s parameters are:

The gRPC contract carries no path.

The profile allows:

  • reading and writing that one bundle;
  • the Virtualization service;
  • the sysctl values and system files the framework checks. The CPU name is among them: without it, saved states don’t restore across profiles.
  • the sandbox extensions the framework hands to its service process. The cache directory extension is limited to its com.apple.metal- and com.apple.paravirtualizedgraphics- entries.
  • reading Virtualization.framework. Without it, a configuration error can’t load its message text, and the process ends in an uncaught exception instead of returning the error.
  • the metadata of /var and /private/var/folders, where the framework finds the cache directory whose path confstr gave before confinement.

It denies the user’s other files, the other VMs’ bundles among them. It also denies the network, starting programs, and other services (X25-vmd-sandboxX25-vmd-sandbox: Self-sandboxed `wb-vmd`Can wb-vmd confine itself at start with a Seatbelt profile that allows the Virtualization framework, its VM bundles under <data>/vms and nothing else, and still create, start, save and restore a macOS VM?).

It doesn’t allow reading the metadata of the bundle’s parent directories. So realpath of a bundle file fails once wb-vmd is confined, and the bundle file checks take a file’s real path from a descriptor on it instead (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 device set is fixed and checked”).

The extension classes were measured with the X18-vsock-handoffX18-vsock-handoff: Host-guest socket and descriptor hand-offCan wb-guestd, written in Go, open AFVSOCK sockets in a macOS guest? configuration, which has the device set of S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host.. Both session VMs’ profiles allow the same two cache entry prefixes. So does the build VM’s, because the wb-vmd-install profile is this profile plus the install rules (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.). The entries stay on the host’s disk between runs. The VMs share a graphics cache through them, and a session VM can leave entries that a later image build may read in the service process of the build VM (T21-shared-graphics-cacheT21-shared-graphics-cache: The VMs share a graphics cacheThe graphics device, keyboard and pointer stay in the device set for now (S06-06-devices-and-warm-start, "The graphics device").).

V1-M6-release-gateV1-M6-release-gate: Release gateThe Seatbelt profiles of wb-hostd and the sessions, confinement self-checks, warm start and suspend, the full conformance suite and benchmarks, packaging and upgrades. checks whether the set can drop the graphics device, keyboard and pointer (S06-06-devices-and-warm-startS06-06-devices-and-warm-start: Devices, Warm Start and TimeA VM's devices and resources, saving and restoring its state, and how the guest clock follows the host., “The graphics device”). If it drops them, the profile is ablated again against the new set.

On macOS, “the secret store service” in a profile is two Mach services:

  • com.apple.securityd.xpc, the data protection keychain;
  • com.apple.ctkd.token-client, the Secure Enclave token.

Those two alone make the store-only profile of wb-credset and wb-guestadmin. The profile can’t name Keychain items. The access groups in the program’s code signature decide which items it reaches (S15-02-secret-storeS15-02-secret-store: The Secret StoreWhere credentials are held: the secret store, its backends, and the guarantees a backend must give.). The profile decides only whether it reaches the store at all.

The store-only profile blocks the read of the process’s own signature, which the store’s open needs (I505I505 (closed): platform: Keychain item calls in the cgo shim, run in a team-signed test bundle and through wb cred on the maintainer's MacPackage M3.8 of docs/implementation-plan.md, part 3 of 3 (M3.8c).). So a program with store access opens the store, which reads nothing else, just before it confines.

The wb-proxyd profile allows outbound TCP to any port, DNS, the resolver files and mDNSResponder as in S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet. (“Confinement”), certificate checks, and the two store services. Its BUNDLE parameter is the real path of its own helper bundle, Contents/Helpers/wb-proxyd.app. Certificate checks against the system roots need the metadata read of that directory, with com.apple.trustd.agent. wb-proxyd works the path out before it confines itself.

The profile denies files, listening, starting programs, UDP other than DNS, and the login keychain (X23-sandboxed-daemonsX23-sandboxed-daemons: Self-sandboxed Go daemons on macOSCan wb-netd, wb-proxyd and wb-hostd confine themselves at start with a sandbox profile, as S04-architecture says, while the Go runtime, inherited descriptors, and Keychain and Secure Enclave access in wb-proxyd keep w…, I61I61 (closed): X23-sandboxed-daemons: wb-proxyd profile with Keychain and Secure EnclaveSplit from #34 (X23-sandboxed-daemons) during triage on 2026-10-04.).

These write their logs to an inherited pipe or socket to wb-hostd: wb-netd, wb-vmd, wb-guestadmin, wb-build-ssh, wb-diskfmt, wb-release-check and wb-download. wb-hostd frames, attributes and rate-limits each line. None of them holds a descriptor on any file in <logs> or <data> for its log.

On macOS a confined process can’t confine itself again, and its children inherit its profile. So wb-hostd starts these through wb-launcher, which has no profile: wb-vmd, wb-netd, wb-proxyd, wb-git, wb-prover, wb-guestadmin, wb-build-ssh, wb-diskfmt, wb-release-check and wb-download.

On Linux, Landlock and seccomp restrictions stack. A child can confine itself further and needs no launcher. That is assumed from their documentation, not tested, and is to be confirmed when Linux self-sandboxing is built.

wb-launcher doesn’t widen what a compromised wb-hostd can do only while all of these hold:

A program that holds a Keychain access group is the main executable of its own helper bundle (S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps.):

  • the wb-proxyd entry names Contents/Helpers/wb-proxyd.app/Contents/MacOS/wb-proxyd;
  • the wb-guestadmin-build, wb-guestadmin-rotate and wb-guestadmin-cleanup entries name Contents/Helpers/wb-guestadmin.app/Contents/MacOS/wb-guestadmin.

The entries of programs without a group name Contents/MacOS. The paths are the same in every build, ad-hoc included.

Status: Draft