S04-03 - Self-Sandboxing
Purpose: How each host daemon confines itself at startup, and the
wb-launcher that starts confined programs on macOS.
Design
Section titled “Design”Each host daemon is self-sandboxed
Section titled “Each host daemon is self-sandboxed”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.).
Confined first thing in main
Section titled “Confined first thing in main”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 withEPERM. 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 before it confines itself
Section titled “wb-hostd before it confines itself”wb-hostd is one exception. Before it confines itself, it:
- reads its own configuration;
- sets
GOMAXPROCS; - loads the local time zone;
- starts
wb-launcher(on macOS); - resolves the git binary from
<config>or the fixed platform path, never fromPATH; - 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”); - works out the paths for its profile.
None of that reads anything the guest sent.
wb-vmd before it confines itself
Section titled “wb-vmd before it confines itself”wb-vmd on macOS is a second, bounded exception. Before it confines
itself, it:
- reads the macOS version from
ProcessInfo, to refuse an older host (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., “Slot checks”); - calls
confstr(_CS_DARWIN_USER_CACHE_DIR)once. The framework needs the per-user cache directory, and the lookup goes to a system service the profile denies. libSystem keeps the answer. - reads its slot from the
WB_VMD_SLOTenvironment variable that its launcher entry sets (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.); - looks up the user’s home directory with
getpwuid(getuid()), never fromHOME; - resolves its slot’s bundle path with
realpath, for its profile parameter; - in the
buildslot, opens the restore image once and checks that descriptor (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., “The restore image”).
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 wb-vmd profile
Section titled “The wb-vmd profile”The profile’s parameters are:
- the bundle path, from the fixed platform path (S12-01-platform-interfacesS12-01-platform-interfaces: Platform InterfacesHow platform-specific code is isolated behind interfaces, and what each host OS uses for each., “Paths”) resolved to its real path;
- the cache directory from
confstr; - in the
buildslot only,IPSW, the restore image’s real path for its install rules (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., “The restore image”).
The gRPC contract carries no path.
The profile allows:
- reading and writing that one bundle;
- the Virtualization service;
- the
sysctlvalues 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-andcom.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
/varand/private/var/folders, where the framework finds the cache directory whose pathconfstrgave 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.
wb-proxyd and the secret store on macOS
Section titled “wb-proxyd and the secret store on macOS”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.).
Daemon logs
Section titled “Daemon logs”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.
wb-launcher
Section titled “wb-launcher”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.
What keeps wb-launcher narrow
Section titled “What keeps wb-launcher narrow”wb-launcher doesn’t widen what a compromised wb-hostd can do only
while all of these hold:
- A small program of its own. It uses only the Go standard
library. It is not
wb-hostdstarted in another mode. - A fixed request channel. The channel is a
SOCK_SEQPACKETorSOCK_DGRAMsocketpair inherited at start, never a path. macOS has noSOCK_SEQPACKETfor Unix domain sockets, so it usesSOCK_DGRAM. Each message is one fixed-format request. A request with unexpected descriptors has them closed and is refused. - Fixed starts. It starts each program with no arguments and a
fixed environment. It passes only the descriptors
wb-hostdhands it. The one bounded exception iswb-git(S04-06-git-confinementS04-06-git-confinement: Git and the `wb-hostd` ProfileHow git runs on data from the guest, what the wb-hostd profile lets it write, and what wb takes from wb-hostd.). - Profiles not from the request. Each program’s profile and its
parameters are compiled into it, or come from configuration
wb-hostdread before it confined itself. They never come over the request channel. - Paths in the bundle. Its program table holds absolute paths in
the installed bundle, never under
<config>,<data>or<logs>. It checks that when it starts. - Kills only its own
wb-diskfmt. A kill request names an instance ID of awb-diskfmtentry that it started, never a process ID. It signals that shim and its process group only before it reaps the shim (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., “wb-diskfmt’s kill”). - Instance caps. Each program has an instance cap
(SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.). The
wb-downloadentries also have a file size limit.
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-proxydentry namesContents/Helpers/wb-proxyd.app/Contents/MacOS/wb-proxyd; - the
wb-guestadmin-build,wb-guestadmin-rotateandwb-guestadmin-cleanupentries nameContents/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