Skip to content

X17 - Unattended image build

Purpose: Whether a macOS guest installed from an Apple restore image can get past Setup Assistant with wb-guestd running as a root LaunchDaemon, without SSH, scripted clicks or MDM, and how long a build takes.

Brief: B28-image-buildB28-image-build: Can an unprivileged host build a macOS guest image without SSH or clicks?No.

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 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? The candidate was writing files to the new guest’s Data volume from the host at build time, before any untrusted code has run. Measure the build time from the restore image. The maintainer’s comment on I28I28 (closed): X17-image-build: Unattended image buildX17-image-build (added to S11-verification-and-spikes in #14) adds: whatever provisioning 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? picks, show Remote Login off, the provisioning user removed, and the sealing scan of 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. extended to check for both (SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.).

No. A host without root can’t get wb-guestd running as a root LaunchDaemon by writing to the guest’s disk, and no other way without SSH that the spike tried worked. The build that works uses one SSH session. Each part, with the evidence in “Measurements”:

  1. The host can mount the Data volume as the user: yes. After the install, hdiutil attach and diskutil mount of the bundle’s disk worked without sudo. The Data volume wasn’t encrypted. The mount ignores ownership, so the host could write anywhere on it.
  2. Every file the host writes belongs to the host user: verified. New files and directories got the host user’s uid (501) and group 20, and chown to root failed with “Operation not permitted”. uid 501 is also the first account macOS creates in the guest, so a wb-guestd binary written this way would belong to whoever gets 501 there.
  3. launchd refuses what the host writes: no daemon ran.
    • A LaunchDaemon plist, the binary and /var/db/.AppleSetupDone, as the issue proposed: the guest booted and nothing answered on vsock in 150 s. At boot, smd bootstrapped the two plist files macOS ships in /Library/LaunchDaemons and skipped the one the host wrote. A second host-written daemon, which only touches a file, never ran either.
    • A LaunchAgent in /Library/LaunchAgents, with a provisioning user logged in automatically, meant to run sudo with a password the host left: launchd logged “Caller specified a plist with bad ownership/permissions” for it, for every user session including the provisioning user’s.
    • The same LaunchAgent in that user’s own ~/Library/LaunchAgents, owned by the user’s uid: it didn’t run, and launchd logged nothing about it. The spike didn’t find out why.
    • With root on the host the files could be owned by root, but SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts. rules out root on the host, so the spike didn’t try it.
  4. The provisioning options get past Setup Assistant: yes. VZMacGuestProvisioningOptions (macOS 27 host and guest, as in X18-vsock-handoffX18-vsock-handoff: Host-guest socket and descriptor hand-offCan wb-guestd, written in Go, open AFVSOCK sockets in a macOS guest?) created the user wbprov with a password and Remote Login on. The guest wrote /var/db/.AppleSetupDone itself, owned by root. Later boots go straight to the login window, and no Setup Assistant process runs.
  5. One SSH session installs wb-guestd: yes. SSH as wbprov answered 21 to 24 s after the start, and sudo install plus launchctl bootstrap put the test daemon in place as root. The host reached it over vsock 23 to 26 s after the start. From then on the spike talked to the guest over vsock only.
  6. Remote Login off: yes. Through the test daemon, launchctl bootout and launchctl disable of com.openssh.sshd stopped sshd, and systemsetup -getremotelogin reports Off. It stays off after a reboot.
  7. The provisioning user removed: no. wbprov holds the volume’s only secure token and is its volume owner. sysadminctl -deleteUser refuses (“it’s either last admin user or last secure token user”), sysadminctl -secureTokenOff refuses (“User cannot disable their own SEP credential”), and dscl . -delete fails with eDSPermissionError. Root also couldn’t delete its home: chmod -N on Desktop, Documents and Downloads, which have an “everyone deny delete” ACL, failed with “Operation not permitted”. The spike didn’t find out whether Full Disk Access would allow it.
  8. The provisioning user disabled: yes. The test daemon took wbprov out of admin and every other group it could, changed its password with sysadminctl -resetPasswordFor to a random one that nothing kept, disabled it with pwpolicy -disableuser, set its shell to /usr/bin/false, hid it, and removed its login keychain. After that, pwpolicy -authentication-allowed reports “account is disabled” and dscl . -authonly refuses the old password. It keeps the secure token. It stays a member of _lpoperator and a share point group, through nested groups every local user is in, and in com.apple.access_disabled.
  9. The sealing scan catches both: yes. Run as root by the test daemon on the provisioned guest, it failed with 8 findings, among them wbprov in admin with a password, com.openssh.sshd enabled and loaded, a listener on TCP port 22, wbprov’s files outside its home, and its login keychain. After the cleanup it passed, and it passed again on the next boot of the sealed image.

The conditions of the build that works:

  1. The host runs macOS 27 or later, for the provisioning options (open decision 3, I143I143 (closed): NFR04-host-platforms: macOS 27 host for wb image build (X17 decision 3)X17-image-build (PR #141, #28) found that wb image build needs a macOS 27 host.).

  2. The first boot is the only one with SSH. It uses the provisioning options with a random password, which a host process holds during the build (open decision 4, I145I145 (closed): SEC12-least-privilege: who holds the image build provisioning password (X17)X17-image-build (PR #141, #28) found that the image build needs a provisioning password: - wb-vmd sets it on VZMacGuestProvisioningOptions; - the build's one SSH session uses it; - wb-guestd's disable step needs the…), and one SSH session that installs wb-guestd and nothing else. No product image descends from a bundle that skipped the later steps.

  3. All later provisioning goes through wb-guestd, over vsock, starting with Remote Login off and automatic login off.

  4. The provisioning user is disabled, not removed (open decision 1). Its password is replaced with a random one that the build discards.

  5. The sealing scan runs in the guest, as root, through wb-guestd, before any project code has run (I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3. settles which user installs the base layer, and when). It fails the build on: an enabled account in admin or wheel other than root and the system accounts macOS ships in it; a non-system account other than one that is the volume owner, disabled, hidden, without a shell, and only in staff, everyone, localaccounts, _lpoperator, com.apple.sharepoint.group.* and com.apple.access_disabled (the group pwpolicy adds when it disables an account); Remote Login (sshd enabled or loaded, or a listener on port 22); screen sharing or remote management; automatic login or /etc/kcpassword; sudoers additions; files outside /Users owned by a non-system uid other than that user’s temporary folders; launchd jobs outside an allowlist of what macOS ships (com.apple.* and amsdstat.plist in /Library/LaunchDaemons) plus wb-guestd’s; and the secrets the scan already looked for. 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., “Sealing”, adds checks the spike’s scan didn’t have: membership through dsmemberutil, authorized_keys, sshd_config, SSH host keys, the kept user’s LaunchAgents, its secure token, and IsHidden.

    The spike’s scan treated an account as enabled when its AuthenticationAuthority had a ShadowHash entry, which is what a password login needs. macOS ships _mbsetupuser in admin without one.

  6. The host never mounts a guest disk to build an image. It doesn’t need to, and the host then parses no guest-written filesystem.

Host: Apple M2, 8 cores, 16 GB, macOS 27.0.1 (26A434), Xcode 27.0, Go 1.27.1, no sudo. Guest: macOS 27.0.1 from UniversalMac_27.0.1_26A434_Restore.ipsw (26.6 GB, already downloaded), 4 vCPU, 4 GiB, one 64 GiB sparse system disk, VZVirtioSocketDevice, and a file-handle network attachment with nothing behind it, or a NAT network for the provisioning boot. Each run started from a fresh APFS clone of one installed bundle. The clock starts when the boot tool starts the VM.

Step Time Runs
Install from the local restore image 271.6 s 1
Host mounts the Data volume, writes, unmounts 2.2 to 3.5 s 3
Provisioning boot: SSH answers 21 to 24 s 3
Provisioning boot: test daemon answers on vsock 23.1 to 26.0 s 3
Sealing scan, in the guest 19.4 to 32.2 s 11
Cleanup and disable requests, guest-side time 40.7 s 1
Provisioning boot, start to guest stopped (full pipeline) 127.1 s 1
Provisioned image, cold boot to the test daemon answering 8.5 to 11.0 s (median 8.8 s) 6

Branch spike/x17-image-build, at 6d3ff44: the Swift wb-vmd stand-in, the Go guest daemon, the host-side Data volume scripts, the provisioning script, the scan and cleanup scripts, and the raw results in results/, with passwords redacted. The spike’s bundles (base and e1 to e5) are spike artifacts, and no product image may descend from them.

Status: Answered 2026-10-07: no