X25 - Self-sandboxed wb-vmd
Purpose: Find out whether wb-vmd can confine itself with a
Seatbelt profile at start and still run a macOS VM, and which devices
that profile keeps wb-vmd from configuring.
Requirements: SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts., SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another., and the “Each host daemon is self-sandboxed” decision of S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.
For review
Section titled “For review”- Decides: how
wb-vmdconfines itself on macOS, its profile, and which parts of the device set the profile enforces and which onlywb-vmd’s own code enforces. - You are approving:
wb-vmdapplies a Seatbelt profile in process, as the Go daemons do (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…). The profile allows the VM bundles under<data>/vms, the Virtualization service, and a short list of system reads and sandbox extensions, and denies the rest. Under it, a confinedwb-vmdinstalls, boots, saves and restores a macOS VM and hands out vsock descriptors. Because the profile can’t refuse a NAT network,wb-vmdchecks its own description of every configuration against the fixed device set before it creates any device, and refuses and logs anything else, verified by a unit test, an in-guest conformance check, and a static check in CI. S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves., S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does., 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., S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq… 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. say so (changed in this pull request). - Controls touched: 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): kept, and
wb-vmdnow has a measured profile. SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise. (no host directory in the guest): kept, now enforced twice, bywb-vmd’s code and by the profile. SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable. (default-deny egress): kept, but only bywb-vmd’s code. The profile can’t stopwb-vmdfrom giving the guest a NAT network, which bypasseswb-netdandwb-proxyd. SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another. (per-project isolation, untrusted repositories in the isolated VM): kept under open decision 1’s recommendation. With onewb-vmdfor both VMs, a compromise ofwb-vmdfrom the isolated VM reaches the work VM’s bundle. No control is weakened. - Assumed: that Apple keeps
sandbox_init_with_parametersworking, as in 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…. That the profile holds for the signed release binary with the hardened runtime: the spike was ad-hoc signed without it. That the SPICE clipboard device can’t reach the host clipboard under the profile: the lookup of the pasteboard service is denied, but the guest had no SPICE agent to show the effect. That the sandbox extensions the profile allows fit the final device set: they 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 had a Mac graphics device and a USB keyboard and pointer, and are ablated again once S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does. fixes the set. - Decisions: decided 2026-10-12, as recommended, in the I64I64 (closed): X25-vmd-sandbox: Self-sandboxed wb-vmdFound while answering #34 (X23-sandboxed-daemons).
comment that starts
Decision (2026-10-12):. S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves. has them (I218I218 (closed): S04-architecture, S06-vm-lifecycle: one wb-vmd per VM and a fixed install entry, from B64-vmd-sandboxThe maintainer decided the two points of B64-vmd-sandbox on 2026-10-12, in the #64 comment that starts Decision (2026-10-12):.).- One
wb-vmdfor both VMs, or one per VM. Onewb-vmdreads and writes all of<data>/vms, so a compromise that starts in the isolated VM, through framework code inwb-vmd’s process, reaches the work VM’s disks and saved state (SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another.). Recommended: onewb-vmdper VM, started from two fixedwb-launcherentries, each with that VM’s bundle as its profile parameter. Every boot, save and restore of the spike already ran one VM per process. Keeping onewb-vmdneeded a T00-indexT00-indexboundary 6 is the host terminal stream. entry for the residual risk. Decided: onewb-vmdper VM, which learns its slot from a fixed environment variable in its launcher entry. - How
wb-vmdis started to install from a restore image, given thatwb-launcherpasses no arguments. Recommended: a fixed launcher entry,wb-vmd-install, whose compiled-in profile adds the three install rules, with the restore image at a fixed path under<data>/images/, so no request chooses the mode or a path. Decided: that entry, with a fixed build bundle as the install target, so the install can’t write into a session VM’s bundle.
- One
- Brief: B64-vmd-sandboxB64-vmd-sandbox: Can wb-vmd confine itself and still run a macOS VM?Yes, with conditions.
Question
Section titled “Question”From X00-indexX00-index: SpikesThe open questions that must be answered by a throwaway prototype before work builds on them, in the order they are taken up.: 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? If not, what does it need instead?
From the maintainer’s comment on I64I64 (closed): X25-vmd-sandbox: Self-sandboxed wb-vmdFound while answering #34 (X23-sandboxed-daemons). (the security review of PR87PR87 (merged): docs(spikes): X18-vsock-handoff result, brief, and spec updatesResult of the X18-vsock-handoff spike (#29): yes, with conditions.):
which device types can the profile keep wb-vmd from configuring, so
that S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves. can say whether the device set is enforced by the
sandbox or only by wb-vmd’s code?
Answer
Section titled “Answer”Yes, with conditions. A Swift wb-vmd stand-in applied a profile
to itself with sandbox_init_with_parameters, then installed macOS from
a restore image, booted, saved, restored, and passed a vsock descriptor
out with SCM_RIGHTS. Besides the bundles and the Virtualization
service, the profile allows a few system reads and the sandbox
extensions the framework hands to that service. It doesn’t allow the
user’s other files, the network, or starting programs. App Sandbox and dropping confinement aren’t needed. The
conditions:
- Resolve the cache directory before confining. The framework
asks for the per-user cache directory
(
confstr(_CS_DARWIN_USER_CACHE_DIR)), and that lookup goes to thecom.apple.bsd.dirhelperservice.wb-vmdcallsconfstronce before it confines itself, and libSystem keeps the answer. Without that call, start fails with “Failed to retrieve cache directory”. The profile then doesn’t need a dirhelper rule. - Allow the CPU name. A state saved by a process that can’t read
machdep.cpu.brand_stringrestores only in a process that can’t read it either, and the other way round. The restore fails with “invalid argument”. A boot doesn’t need the rule, so it’s easy to drop by mistake. With it, states move freely between confined and unconfined runs. - Keep the framework’s own bundle readable. Without read access to
Virtualization.framework, a configuration error can’t load its message text and the process ends in an uncaught exception instead of returning the error. A boot doesn’t need the rule otherwise. - Installing needs three more rules, for the restore image: read
it, issue a read extension for it, and look up the
com.apple.Virtualization.Installationservice. They belong in the profile only whilewb-vmdinstalls an image (X17-image-buildX17-image-build: Unattended image buildCan a macOS guest installed from an Apple restore image get past Setup Assistant, with wb-guestd running as a root LaunchDaemon, without SSH, scripted clicks, or MDM?), and open decision 2 is how that mode is chosen. - The profile can’t keep a NAT network from the guest. It enforces
part of the device set and not the rest (below). Which network a VM
gets is up to
wb-vmd’s code, and SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable. depends on it. That code checkswb-vmd’s own description of the configuration before it creates any device object. A disk outside the bundle otherwise ends the confined process in an uncaught exception.
What the profile enforces in the device set
Section titled “What the profile enforces in the device set”Each device was added to the VM configuration, pointing at a file or
directory outside the bundle, once with wb-vmd confined and once
unconfined. Unconfined, every device below except the bridged network
starts. Confined, the framework offered no host interface to bridge
to at all (dev-final-bridged.jsonl).
| Device | Confined | Enforced by |
|---|---|---|
| Shared directory (virtio-fs) | refused at start. Outside the bundle the process can’t read the directory, and inside it the fuse sandbox extension is denied |
profile, and wb-vmd’s code |
| Host microphone (audio input) | refused at start: the audio-input sandbox extension is denied |
profile, and wb-vmd’s code |
Extra disk image outside <data>/vms |
refused: the process can’t read it (and ends in an uncaught C++ exception) | profile, and wb-vmd’s code |
Serial port that writes to a file outside <data>/vms |
refused at configuration: “Operation not permitted” | profile, and wb-vmd’s code |
| SPICE agent with clipboard sharing | starts. The pasteboard lookup is denied, so the process can’t reach the host clipboard (not checked from the guest) | profile (inferred), and wb-vmd’s code |
| Bridged network | refused: the framework lists no host interface to bridge to. Unconfined, it lists one and refuses the attachment without the com.apple.vm.networking entitlement, which wb-vmd doesn’t get |
profile and code signing, and wb-vmd’s code |
| NAT network | starts, and the guest reached https://www.apple.com/ (HTTP 200) |
only wb-vmd’s code |
Disks and files inside <data>/vms |
allowed | only wb-vmd’s code |
Devices on a descriptor wb-vmd holds: file-handle network, serial port on a file handle |
allowed | only wb-vmd’s code |
Unconfined, the guest mounted the shared directory and read the
secret file in it, saw the marker of the extra disk, and reached the
internet through NAT (guest-unconfined-check.txt). Confined, with
NAT only, it reached the internet, and mount_virtiofs didn’t find a
share (guest-confined-nat-check.txt).
The NAT attachment doesn’t need any right in wb-vmd’s process: vmnet
runs in Apple’s Virtualization service. A NAT network would give the
guest a path to the internet that skips wb-netd and wb-proxyd, and
only wb-vmd’s code keeps it out. wb-vmd doesn’t read guest bytes
(S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.), so getting a NAT network attached takes a bug in
wb-hostd’s requests or in wb-vmd itself.
S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves. now has wb-vmd check each configuration against its
fixed device set before every start and restore, and three checks
verify it: a unit test that passes each refused device to the check,
an in-guest check for one network interface with its lease from
wb-netd, and a static check in CI that rejects the NAT, bridged,
shared directory and audio input classes in wb-vmd’s sources
(S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq…).
Measurements
Section titled “Measurements”Host: Apple M2, 8 cores, 16 GB, macOS 27.0.1 (26A434), Xcode 27.0.
Guest: macOS 27.0.1, 4 vCPU, 4 GiB, 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,
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? guest daemon answering gRPC on vsock port 1024. The spike
code and its recorded output are on the spike branch:
spikes/x25-vmd-sandbox at abb23b0
(results/ holds the output of each run, and the Sandbox log lines it
caused).
How the profile was found
Section titled “How the profile was found”- A run under
(allow default (with report))logged every operation the process did during a boot, a save, and a restore (discover-*.sandbox.txt). - Starting from
(deny default)with the bundle and the Virtualization service, each run added what the last one was denied, until boot, save and restore worked (vmd-v1tovmd-v5). - Three ablation rounds booted once per rule without that rule
(
ablate-*.txt). Dropped: the disk image service,vfs.disk-space, the ICU data file, read and write on the cache directory, the read-write extension on the bundle,kern.maxfilesperproc, and the CPU name, which step 4 put back. - Restores across confined and unconfined saves found the CPU name
rule (
matrix-*,addon-round1.txt,addon-round2.txt). - The read-write extension on the cache directory was narrowed to the
two entries the discovery runs showed,
com.apple.metal-*andcom.apple.paravirtualizedgraphics-*. Boot, save and restore worked under it (narrow-*, profilevmd-final-narrow.sb).
The VM in every run had 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? devices: a Mac graphics device with one display, a USB keyboard and pointer, vsock, the file-handle network device, two disks and entropy. Several extension classes serve the graphics and USB devices. If S06-vm-lifecycleS06-vm-lifecycle: VM Lifecycle, Images and the Guest AgentHow guest images are built, how VMs are kept warm, how projects and sessions map onto guests, and what wb-guestd does. drops one of them, the classes are ablated again against that set.
The profile
Section titled “The profile”BUNDLE is one VM’s bundle in the spike runs, and a run with the
parent of all bundles as the parameter booted the same
(final-vms-root). Open decision 1 is which one wb-vmd gets. CACHE is the cache
directory from confstr, resolved (/private/var/folders/...),
without the trailing slash.
(version 1)(deny default)(allow file-read* file-write* (subpath (param "BUNDLE")))(allow mach-lookup (xpc-service-name "com.apple.Virtualization.VirtualMachine"))(allow sysctl-read (sysctl-name "kern.hv_support" "hw.memsize" "machdep.cpu.brand_string"))(allow file-read* (literal "/System/Library/CoreServices/SystemVersion.plist"))(allow file-read* (subpath "/System/Library/Frameworks/Virtualization.framework"))(allow file-read-metadata (literal "/var") (literal "/private/var/folders"))(allow generic-issue-extension (extension-class "com.apple.virtualization.extension.avp.rtc" "com.apple.virtualization.extension.fp" "com.apple.virtualization.extension.io-surface" "com.apple.virtualization.extension.paravirtualized-graphics" "com.apple.virtualization.extension.strong-identity" "com.apple.virtualization.extension.usb-hci" "com.apple.virtualization.extension.videotoolbox"))(allow file-issue-extension (require-all (subpath (param "BUNDLE")) (extension-class "com.apple.app-sandbox.read")))(allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") (prefix (string-append (param "CACHE") "/com.apple.metal-") (string-append (param "CACHE") "/com.apple.paravirtualizedgraphics-"))))What each part is for, and what happened without it:
| Rule | Without it |
|---|---|
read and write BUNDLE |
the bundle’s files can’t be read |
| the Virtualization service | “The virtual machine failed to start” |
kern.hv_support |
“Virtualization is not available on this hardware” |
hw.memsize |
memorySize is greater than maximumAllowedMemorySize |
machdep.cpu.brand_string |
boots, but saved states don’t move between this profile and an unconfined process (condition 2) |
SystemVersion.plist |
“Unsupported hardwareModel” |
Virtualization.framework |
boots, but a configuration error ends in an uncaught exception (condition 3) |
metadata of /var and /private/var/folders |
“Failed to retrieve cache directory” |
| each of the 7 extension classes | “Failed to issue … sandbox extension”, one per class |
read extension in BUNDLE |
“Failed to issue sandbox extension for auxiliary storage device” |
read-write extension in CACHE (before narrowing) |
“Failed to issue sandbox extension for ParavirtualizedGraphics cache directory” |
The extensions are how the framework passes access to its service
process: the auxiliary storage file, the graphics caches, and the
device classes. The disks are opened in wb-vmd’s own process.
Writing the saved state doesn’t need more than the bundle rule.
Denied in the confined runs, with no effect on the VM: the disk
image service lookup, mach-task-name on the service process,
kern.maxfilesperproc, vfs.disk-space, the SystemVersion.bundle
strings, and the syslog socket.
Right after confining, the stand-in tried to read /etc/passwd and
~/.ssh/known_hosts, write in /tmp, connect over TCP to loopback,
and start /usr/bin/true. Each was denied, in every confined run.
Boot, save, restore, install, hand-off
Section titled “Boot, save, restore, install, hand-off”| Run | Result |
|---|---|
sandbox_init_with_parameters |
5.9 ms (p50 of the 73 calls across all runs, 5.1 to 15.2 ms) |
| cold boot to the guest daemon answering on vsock | 9 to 16 s, confined and unconfined alike |
| save, confined | 3.0 to 3.7 s |
| restore from a fresh clone, confined | 3.40 s p50, 3.57 s max. vsock answers at 3.60 s p50 (10 runs) |
| restore from a fresh clone, unconfined | 3.40 s p50, 3.53 s max. vsock answers at 3.60 s p50 (10 runs) |
| restore, save, restore again, all confined | works |
| state saved confined, restored unconfined, and the other way round | works with condition 2. Without it, “invalid argument” in all 9 tries |
| install from the restore image, confined, with the 3 install rules | 240 s, completes |
pass a vsock descriptor with SCM_RIGHTS over a socketpair made before confining, and speak HTTP/2 to the guest on the received copy |
the guest answers with a SETTINGS frame |
Confinement doesn’t make a restore measurably slower. The installed VM wasn’t booted: it had no guest daemon to answer.
What it means for the specs
Section titled “What it means for the specs”- S04-03-self-sandboxingS04-03-self-sandboxing: Self-SandboxingHow each host daemon confines itself at startup, and the wb-launcher that starts confined programs on macOS., “Each host daemon is self-sandboxed”: a
wb-vmditem with the profile’s shape and where its parameters come from, condition 1 as a second bounded exception to “confine first”,wb-vmd’s log on an inherited pipe towb-hostd, and open decisions 1 and 2 (changed in this pull request). - 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” (new):
the check before any device object is created, which devices the
profile enforces, that NAT and the other devices in the table are
only enforced by
wb-vmd’s code, and the three checks that verify it (changed in this pull request). - 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., “Devices”: the graphics and USB devices the spikes used are open, and the profile is ablated again against the final set (changed in this pull request).
- S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections., “Packet transport”: “no other network path” points to the device-set check (changed in this pull request).
- S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq…: the unit test of the device-set check and the in-guest interface check (changed in this pull request).
- 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., “Warm start”: “invalid argument” also comes
from a state saved under a
wb-vmdprofile that read different host facts, which the existing rules already treat as permanent (changed in this pull request). - S12-01-platform-interfacesS12-01-platform-interfaces: Platform InterfacesHow platform-specific code is isolated behind interfaces, and what each host OS uses for each., “Self-sandbox” row: names 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? next to 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… for macOS (changed in this pull request).
- Cloning a base image from
<data>/imagesinto a bundle isn’t in this profile. Ifwb-vmddoes it, the profile also reads<data>/images. Who clones is for the implementation.
Not covered
Section titled “Not covered”- The release signing: hardened runtime and a Developer ID signature.
The spike was ad-hoc signed with
com.apple.security.virtualizationand no hardened runtime. - The SPICE clipboard seen from inside the guest. The guest has no SPICE agent.
- Two VMs at once under one
wb-vmd. Each run had one VM. - App Sandbox through entitlements. The Seatbelt profile works, so it wasn’t needed.
- Other devices: USB mass storage (the same file rules as a disk
apply), Rosetta directory shares (a directory share, so the
fuseextension applies, untested), and network block devices.
Status: Answered 2026-10-06: yes, with conditions. Only wb-vmd’s code keeps a NAT network from the guest. Decided 2026-10-12 (I64I64 (closed): X25-vmd-sandbox: Self-sandboxed wb-vmdFound while answering #34 (X23-sandboxed-daemons).): 1A, one wb-vmd per VM, and 2A, the wb-vmd-install entry