Can the Go daemons confine themselves on macOS?
Answered 2026-10-04. Decided 2026-10-04: A, the wb-launcher, with the wb-git shim. Source: 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…, I34I34 (closed): X23-sandboxed-daemons: Self-sandboxed Go daemons on macOSX23-sandboxed-daemons (added to S11-verification-and-spikes in #14). Affects S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves. and 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.. The wb-proxyd Keychain part is I61I61 (closed): X23-sandboxed-daemons: wb-proxyd profile with Keychain and Secure EnclaveSplit from #34 (X23-sandboxed-daemons) during triage on 2026-10-04..
The picture
Section titled “The picture”Figure 1. Option A. The launcher starts before wb-hostd confines itself. The daemons it starts can then each apply their own profile. A child that the confined wb-hostd starts directly (red) inherits the wb-hostd profile, and the kernel refuses its own (forbidden-sandbox-reinit). The git box shows the fallback, as the spike ran it: a child of wb-hostd inside its profile. Recommended option A instead starts git through the launcher, as a wb-git shim with a profile for one repository.
Options
Section titled “Options”The spike settled the mechanism: an in-process profile, without cgo. The real choice is how wb-hostd starts the other daemons.
Impact
Section titled “Impact”| Requirement | A. Launcher | B. Inherit | C. hostd open | D. launchd jobs |
|---|---|---|---|---|
| SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts. least privilege on the host | every daemon | netd too wide | hostd open | every daemon |
wb-netd: only inherited descriptors (S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.) | measured | hostd’s rights | measured | plus a socket path |
wb-hostd: its state directories only | measured | plus all others | none | plus launchd |
| Descriptor hand-off (S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.) | as now | as now | as now | connect back |
| Code and spec work | small launcher | none | spec change | launchd jobs |
Evidence
Section titled “Evidence”- verified A Go program that calls
sandbox_init_with_parametersinmain, without cgo, keeps goroutines, garbage collection, preemption, timers,crypto/randand ECDSA working under(deny default), and is denied every file open,stat, connect, listen, DNS lookup, and program start. The profile covers all 32 OS threads tried (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…, “What a confined Go program can still do”). - verified A
wb-netdstand-in on gVisor moves 4 streams of 64 MiB each way over an inherited socket and hands each stream to a proxy withSCM_RIGHTS, at the same throughput confined as unconfined: 438 against 420 MiB/s, medians of 5 (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…, “wb-netd: gVisor over inherited descriptors”). - verified Denying the
hw.ncpuread makes Go 1.27 setGOMAXPROCSto 1 within seconds and cuts that throughput to 258 MiB/s. The runtime re-reads the CPU count every second (runtime/cgroup_stubs.go,sysmonUpdateGOMAXPROCSinruntime/proc.go). An explicitruntime.GOMAXPROCScall before confining turns that off: it stays at 8 under a bare(deny default)(437 MiB/s, median of 3). The security review on PR65PR65 (merged): docs(spike): X23-sandboxed-daemons result, yes with conditionsResult of spike X23-sandboxed-daemons, approach steps 1 and 2 (the scope set by the 2026-10-04 decision on #34). found this. - verified Paths pasted into generated profile text let a crafted path turn the profile off (reproduced in the security review on PR65PR65 (merged): docs(spike): X23-sandboxed-daemons result, yes with conditionsResult of spike X23-sandboxed-daemons, approach steps 1 and 2 (the scope set by the 2026-10-04 decision on #34).). Paths go in as parameters instead.
- verified A child of a confined process can’t apply its own profile. The kernel logs
deny(1) forbidden-sandbox-reinitand the call fails with “Operation not permitted”. Through a launcher started before confinement, the child’s profile applies. - verified Under its profile, a
wb-hostdstand-in reads its configuration, writes and locks its state file, appends to its log, serves its Unix socket, and runs a git push and clone into a landing repository with Homebrew git and with the Xcode git binary. Writes to its configuration, files outside its directories, and network connections are denied. - verified
sandbox-execneeds extra rules to start a Go binary at all: running and reading it,/usr/lib, the dyld cache, and thesysctlvalues the runtime reads at start. - verified Apple’s SDK header marks
sandbox_init“No longer supported” since macOS 10.8, and thesandbox-execman page says “DEPRECATED”. Both work on macOS 27.0.1. - inferred The launcher doesn’t give an attacker in
wb-hostdany right it lacks today, but only while the conditions under option A hold.wb-hostdalready starts these programs, and each one confines itself before it reads anythingwb-hostdsends. The spike’s launcher didn’t meet them: it passed on arguments and the profile fromwb-hostd, so a compromisedwb-hostdcould have started an unconfinedwb-netd(code review on PR65PR65 (merged): docs(spike): X23-sandboxed-daemons result, yes with conditionsResult of spike X23-sandboxed-daemons, approach steps 1 and 2 (the scope set by the 2026-10-04 decision on #34).). - assumed That the
wb-gitshim works with a profile for one repository. Not built in the spike. - assumed That Apple keeps
sandbox_init_with_parametersworking in later macOS versions. Apple doesn’t promise it. - assumed That
wb-vmdcan confine itself with the Virtualization framework running. Not tested: I64I64 (closed): X25-vmd-sandbox: Self-sandboxed wb-vmdFound while answering #34 (X23-sandboxed-daemons)..
What this unblocks
Section titled “What this unblocks”- I61I61 (closed): X23-sandboxed-daemons: wb-proxyd profile with Keychain and Secure EnclaveSplit from #34 (X23-sandboxed-daemons) during triage on 2026-10-04.: the
wb-proxydprofile with Keychain and Secure Enclave rules, starting fromproxyd-net.sb. - I64I64 (closed): X25-vmd-sandbox: Self-sandboxed wb-vmdFound while answering #34 (X23-sandboxed-daemons).: the
wb-vmdprofile. - I67I67 (closed): wb-hostd can't read the user's repository under its sandbox profile (S08 upload-pack)Found in the review of #65 (X23-sandboxed-daemons result).: how
wb-hostdgets the user’s repository without reading it. - I68I68 (closed): wb-proxyd must bind stream identity to the connection, not to wb-netd's tagsFound in the security review of #65 (X23-sandboxed-daemons result).:
wb-proxydties a stream to its VM by the connection, not by a tag fromwb-netd. - The S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves. supervision change from I48I48 (closed): S04-architecture: process supervision, failure, version skew and host resource limitsS04-architecture names the processes but not how they are supervised, what happens when one fails, or how they are upgraded:, which now includes the launcher.
- The
internal/platformself-sandbox code for macOS, once V1-M1-spikes-closedV1-M1-spikes-closed: Spikes answered and spec gaps closedX01-model-credential to X09-keychain-unsigned and X17-image-build to X28-git-alloc-limit written up in docs/spikes/, the spec issues of the first implementation plan decided, and specs updated. closes and the implementation issues are written.
Details and glossary
Why in process, not sandbox-exec. With sandbox-exec, the profile is in force before the program is loaded. It must then also let the process read the system libraries and run its own binary, until the process exits. In process, the call comes after loading, and the profile only allows what the daemon does from then on. It also keeps the profile inside the binary, so the parent can’t swap it. That last point follows from the design and was not tested.
Why no cgo. cgo would make each macOS build need a C toolchain for macOS and stop cross-compiling from Linux or Windows. The spike calls the function through a few lines of Go assembly, the way the standard golang.org/x/sys/unix package calls the C library on macOS. That links to a function in package syscall (syscall6) which Go keeps for golang.org/x/sys and lets other packages use (syscall/syscall_darwin.go in Go 1.27, go.dev/issue/67401). A later Go release could restrict that, and the build would then fail rather than run unconfined.
Why git gets its own profile. The git gateway runs git upload-pack and git receive-pack on data the guest sends. Under the wb-hostd profile, a bug in git reaches everything in the wb-hostd directories: policy, approvals, every landing repository, the audit log. A wb-git shim with a profile for one repository limits it to that repository. Either way, git runs without the user’s git configuration, and the profile allows only the git installation (bin/git, libexec/git-core/, share/git-core/ and the libraries git links), not all of /opt/homebrew.
A gap this found. wb-hostd can’t read the user’s repository under its profile, which S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem. needs for the project clone. I67I67 (closed): wb-hostd can't read the user's repository under its sandbox profile (S08 upload-pack)Found in the review of #65 (X23-sandboxed-daemons result). has the options.
Glossary
- Seatbelt: the macOS kernel sandbox. A profile is a list of rules (“deny everything, allow reading this directory”) in a small Lisp-like language.
sandbox_init_with_parameters: the C function that applies a profile to the calling process. Nothing can remove it afterward.sandbox-execis the command-line tool that applies one and then starts a program.- cgo: Go’s way of calling C code. It needs a C compiler for the target platform at build time.
GOMAXPROCS: how many CPU cores the Go runtime uses at once.- Descriptor,
SCM_RIGHTS: a handle to an open socket or file, and the Unix mechanism that passes one to another process. - gVisor: the userspace network stack
wb-netdruns (S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host.).