S06-15 - The Xcode Disk
Purpose: How the host builds the read-only disk that holds Xcode
and the simulator runtimes for an image build, under the
wb-diskfmt shim’s profile, and what the build records.
Requirements: FR06-native-toolsFR06-native-tools: Native guest toolsAgent tool calls run tools native to the guest operating system (on macOS guests: Homebrew packages, Xcode command line tools, optionally full Xcode)., SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise., SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts., SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped., SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.
Design
Section titled “Design”The entry
Section titled “The entry”The Xcode disk is a disk image the host builds. It isn’t a shared directory (SEC02-no-host-fs-shareSEC02-no-host-fs-share: No host filesystem sharingNo host directory is mounted into the guest, read-only or otherwise.). The checks it starts with, and what the guest does with it, are in S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch..
wb-diskfmt builds it, started through a third fixed wb-launcher
entry, wb-diskfmt-xcode, whose WB_DISKFMT_SLOT is xcode
(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”). Only wb-hostd starts it, during
an image build. wb-hostd clones the parent into the new, empty build
bundle, then starts wb-diskfmt-xcode, and starts no wb-vmd in that
bundle until wb-launcher has reported the shim’s exit. Then it starts
wb-vmd-layer. As for the data disk entries, its instance cap is one,
and its shim is started as the leader of a new process group.
The entry’s profile parameters are the build bundle,
<data>/images/macos-build.noindex, the real path of the Xcode app and
<data>/xcode-runtimes. The shim resolves /Applications/Xcode.app
with realpath itself before it confines itself, and applies the
/Applications/*.app rule (S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch., “Where Xcode comes
from”). The shim takes none of these paths from the request or the
environment. For the xcode slot, the slot’s bundle of
diskfmt-slot-bundle-mismatch is the build bundle.
The profile
Section titled “The profile”The profile is wb-diskfmt’s (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
profile”), with xcode.img and its temporary name in the build bundle
in place of the data disk’s names, plus:
- reading the Xcode app, the exported runtimes and the license record (S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch., “The checks on the host”), and no other file outside the build bundle;
- creating the directory
xcode-mntin the build bundle, by that literal name, writing under it, and mounting and unmounting on it (file-mount,file-unmount); - starting
/usr/bin/dittoand/usr/bin/codesign, and reading the metadata of the build bundle’s parent directories, whichdittowalks; mach-lookupofcom.apple.trustd.agent, whichcodesignneeds;- the system reads
codesignanddittomake:sysctl-readof seven names,system-infovfs.disk-space, the metadata of/System/Cryptexes/OS,/System/Cryptexes/App,/etc,/varand/Users, and reading/usr/share/icu.
X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “The profile”, lists every rule the measured runs
needed, and I681I681 (open): wb-diskfmt-xcode: check the host's Xcode and runtimes and build the read-only Xcode diskPackage IMG.8 of docs/implementation-plan.md, part 1 of 4 (IMG.8a). starts from that list. Each rule the shim’s profile
adds to wb-diskfmt’s, a Mach service or any other, needs a measured
failure without it, and this page then says what a subverted shim
gains from it.
codesign with no Mach service refuses Apple’s own signatures with
CSSMERR_TP_NOT_TRUSTED. With com.apple.trustd.agent alone, the
deep check of Xcode against S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch.’s requirement and the
check of a runtime’s disk image both pass, and a wrong requirement
still fails. ditto doesn’t need one (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up
(I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”, “The profile”). The profile doesn’t allow another service:
not com.apple.trustd, com.apple.SecurityServer (the keychain) or
com.apple.ocspd, nor the user database lookup the base profile denies.
com.apple.trustd.agent runs outside the sandbox as the host user, so
a subverted shim can ask it to evaluate any certificate, and it may
fetch from the network to do so (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
profile”). The names are in code, and the opt-in host test’s confined
run checks them (I681I681 (open): wb-diskfmt-xcode: check the host's Xcode and runtimes and build the read-only Xcode diskPackage IMG.8 of docs/implementation-plan.md, part 1 of 4 (IMG.8a).).
Finding its volume
Section titled “Finding its volume”The shim knows its volume only by device. diskutil image attach
reports the device it attached. The shim’s volume is a volume of the
APFS container whose one physical store is that device, read from the
I/O Registry. APFS reports a mounted volume’s f_mntfromname as a
volume of that synthesized container, never as the attached device.
The shim never looks a volume up by its name or its mount point, so it
never takes a leftover volume named wb-xcode for its own. When the
I/O Registry can’t be read, or the container holds more than one
volume, the build refuses (xcode-volume-unknown).
The steps
Section titled “The steps”As for a data disk (S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk., “The shim”), the shim:
- creates
xcode.imgin the build bundle under a temporary name, with the same identity checks. Its size is the sum of the inputs’ file sizes (st_size) plus slack, within a bound in code. The copy drops APFS file compression, so the blocks the source takes on the host are too few: an Xcode of 4.0 GB on the host took 10 GB on the volume; - attaches it, makes an APFS container on it with a volume named
wb-xcode, and mounts the volume only onxcode-mnt, a new directory in the build bundle, as “Never mounted in/Volumes” below says. An existingxcode-mntrefuses the build (xcode-mnt-exists). Before any write,statfsonxcode-mnthas to give that path asf_mntonnameand a volume of its container asf_mntfromname(xcode-mount-mismatch). Itsf_flagshave to holdMNT_NOSUID,MNT_NODEVandMNT_DONTBROWSE, and notMNT_IGNORE_OWNERSHIP(xcode-mount-options). The volume’s root has to be empty, apart from a fixed list in code of what macOS makes on a new volume (xcode-volume-not-empty). Its owner and mode have to be the measured ones, with no group or other write and no ACL (xcode-volume-root-mode); - copies the app to
Xcode.appon the volume, and each exported runtime toRuntimes/, withditto --norsrc --noextattr --noacl --noqtn; - removes every
_MASReceiptand every.DS_Storefrom the copied app, at any depth, with a walk that useslstatand never follows a symbolic link. An App Store install’s receipt names the host’s purchase and device. Removing them is also an integrity step (“What the signature doesn’t seal” below). The copy without them still meets the code requirement, and Gatekeeper in the guest accepts it; - checks the copy, which catches a change to the source during the
copy, and a short copy, since
dittoexited 0 after a file it failed to write:- the app’s signature with S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch.’s requirement, and each
runtime’s disk image with
identifier image and anchor apple; - a walk of the volume with
lstat, which accepts onlyXcode.app,Runtimesand step 2’s fixed list at the root and, underRuntimes, only the checked runtimes in the layout of S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch., “Where the runtimes come from” (xcode-volume-unexpected). It holds each entry of the fixed list to its name, its type and no content, and makes the checks of “What the signature doesn’t seal”; - Xcode’s version, build,
LicenseInfo.plistand minimum macOS version, read again from the checked copy, with the license and macOS version checks of S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch. made again on them, and the SHA-256 of each copied disk image;
- the app’s signature with S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch.’s requirement, and each
runtime’s disk image with
- checks the device and the root again, as in steps 2 and 5, with
step 2’s fixed list accepted at the root. It then unmounts the
volume by its device and detaches it, neither with force, and
renames the file to
xcode.img. A busy volume or device refuses the build (xcode-unmount-busy).
The copy keeps each exported runtime’s other files. The guest’s import
is given only the disk image (S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch., “In the build VM”),
but it was measured only beside its Firmware files. I684I684 (open): Xcode image on the maintainer's Mac: build a named image with the host's Xcode and a runtime, and check it in a sessionPackage IMG.8 of docs/implementation-plan.md, part 4 of 4 (IMG.8d). tries an
import with the disk image alone. If that works, the shim copies only
the disk image. If not, the import reads those files unsigned, and the
build records their SHA-256 too. Until then the walk in step 5 holds
them to their names and types.
With owners, the files the shim writes belong to the host user’s ID
on the volume. install-xcode reads only Xcode.app and Runtimes,
and gives the copy to root:wheel whatever owner the volume shows.
Each ditto and codesign run has a deadline in code, as each
diskutil step has, set above the times X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up
(I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”, measured. The deep check took 53 to 107 s on the source and
45 to 46 s on the copy. Each runtime’s disk image took 22 to 27 s, and
is checked on the source and again on the copy. The kill of
S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk., “When wb-diskfmt doesn’t exit”, applies to
the shim as to the data disk entries, and wb-hostd’s wait covers
the sum of its deadlines.
What the signature doesn’t seal
Section titled “What the signature doesn’t seal”A path in the copy is governed by the resource rules (rules2 in
_CodeSignature/CodeResources) of one bundle, relative to its resource
root (Contents, Versions/<v>, or the bundle itself). That is the top
bundle, or a nested bundle that an enclosing governing bundle’s files2
lists with a cdhash. Any other bundle, its CodeResources included,
is plain files under the enclosing seal (X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up
(I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”).
codesign --verify --deep --strict doesn’t check _MASReceipt, nor a
path that a governing omit rule matches: .DS_Store at any depth,
Info.plist and PkgInfo at the resource root, and a
locversion.plist in a .lproj directory. Step 4 removes _MASReceipt
and .DS_Store. After the signature check, the shim in step 5
(xcode-volume-unexpected) and install-xcode (xcode-copy-invalid)
accept a file or symbolic link in Xcode.app only when it is:
- in the
files2of the governing bundle whose seal covers it; - in that bundle’s
_CodeSignature, its main executable, or theInfo.plistits code directory binds; - one of a framework’s root symbolic links;
- an omitted
PkgInfothat is a regular file of 8 bytes.
A governing CodeResources without rules2, without ^.* set to
true, or with an omit rule outside that list refuses the build
(xcode-seal-rule-unknown).
Never mounted in /Volumes
Section titled “Never mounted in /Volumes”diskutil eraseDisk mounts a new volume in /Volumes at once
(X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?, “Follow-up (I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant).)”), where another local account may
be able to write to it until the unmount. So the shim doesn’t use
eraseDisk. It runs diskutil apfs createContainer, then diskutil apfs addVolume -nomount, then diskutil mount -mountOptions owners,nobrowse,nosuid,nodev -mountPoint on xcode-mnt. addVolume -mountpoint needs root on macOS 27.2, and I681I681 (open): wb-diskfmt-xcode: check the host's Xcode and runtimes and build the read-only Xcode diskPackage IMG.8 of docs/implementation-plan.md, part 1 of 4 (IMG.8a). doesn’t run diskutil
as root. I681I681 (open): wb-diskfmt-xcode: check the host's Xcode and runtimes and build the read-only Xcode diskPackage IMG.8 of docs/implementation-plan.md, part 1 of 4 (IMG.8a). measures this route. If a step of it mounts the volume in
/Volumes, I681I681 (open): wb-diskfmt-xcode: check the host's Xcode and runtimes and build the read-only Xcode diskPackage IMG.8 of docs/implementation-plan.md, part 1 of 4 (IMG.8a). stops and reports it, and doesn’t accept the window.
Before the mount, <data>, each directory from it down to the build
bundle, the build bundle and xcode-mnt have to be directories the
host user owns, with no group or other permission and no ACL. So no
other account can enter any of them (xcode-mnt-exposed). The
empty-root check of step 2 and the exact-contents check of step 5 also
catch a writer in the host user’s own account.
The SEC15 exception
Section titled “The SEC15 exception”The mount on xcode-mnt is SEC15-no-guest-disk-mountSEC15-no-guest-disk-mount: The host never mounts a guest-written diskA disk image is guest-written once a guest has run with it attached, and every copy or clone of a guest-written image is guest-written too.’s one exception,
as for a data disk (S06-05-disksS06-05-disks: DisksA VM's system disk and data disk: how the data disk keeps what the guest flushes, and how the guest mounts it., “Formatting a data disk”): a blank
image the host itself created, before any guest has run with it. The
shim fills the volume as the bundle build fills the guest tools disk.
The host never mounts or opens the file again once a guest had it, and
it is deleted with the build bundle. That delete doesn’t follow links,
and stops at a directory whose st_dev isn’t the bundle’s. A volume
left mounted on xcode-mnt refuses the build with xcode-mount-left,
which names the mount point.
A killed shim can leave its volume attached, or mounted on xcode-mnt.
As with a killed data disk shim, wb-hostd logs the temporary image,
and the device is attached until the user ejects it or the host restarts
(S06-13-data-disk-formatS06-13-data-disk-format: Data Disk FormatHow the host formats a VM's new data disk, the one exception SEC15-no-guest-disk-mount makes, and the checks before a VM starts with its disk., “When wb-diskfmt doesn’t exit”). That volume
never reaches a guest, because its file is never renamed to xcode.img,
and a later build finds its own volume by device.
What the build records
Section titled “What the build records”The shim reports Xcode’s version and build and the SHA-256 of each
runtime’s disk image, all read from the checked copy, to wb-hostd,
which treats them as untrusted, as it treats every answer of the
shim. state.db records them for the image.
wb-hostd never reads Xcode, the runtimes or the license record itself.
It decides between the layer-only path of S06-01-image-layersS06-01-image-layers: Image Layers and the Toolchain PrefixThe layers of a guest image, and the toolchain prefix that project layers install into., “Only the
layer”, and a full build after a check-only run of the shim, which makes
the checks of S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch., reports the same values from the
source, and builds no disk. That run also gets a new, empty build
bundle. The layer-only path requires them to equal the recorded ones. A
new Xcode on the host changes nothing until the next wb image build.
That build then builds every layer.
Open for I681
Section titled “Open for I681”- The route of “Never mounted in
/Volumes” run on the host: no mount in/Volumes, and the options kept onxcode-mnt. - What macOS makes on the root of a new volume mounted with
owners,nobrowse, which is the listxcode-volume-not-emptyallows, whether each entry stays empty during the copy, and the root’s owner and mode. - The I/O Registry lookup of the container, and the profile rule it needs.
- Whether the confined shim needs any service besides
com.apple.trustd.agent.
Decisions
Section titled “Decisions”A page of its own
Section titled “A page of its own”The host’s build of the Xcode disk has its own page, apart from S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch..
- Why: the measurements of I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant). made S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch. longer than a spec page may be. The host’s part of the build is one piece with its own profile and its own launcher entry.
- Rejected: shortening S06-14-xcode-imageS06-14-xcode-image: The Xcode ImageHow an image gets full Xcode and the simulator runtimes from the host, as a read-only disk the host builds, and who runs Xcode's first launch.’s measured detail to keep one page, which would leave the checks without the numbers that set their deadlines.
- Decided: I624I624 (closed): S06-14-xcode-image: measure the host export, signature checks and offline import of Xcode and runtimesFrom #194 (S06-14-xcode-image, the Xcode image variant)., 2026-11-10.
Never mounted in /Volumes
Section titled “Never mounted in /Volumes”The blank volume is only ever mounted on xcode-mnt in the build
bundle, which no other account can enter.
- Why: while the volume is in
/Volumes, another local account may be able to write to it, and what it writes would reach the guest’s root. - Rejected: accepting the window of
eraseDisk’s mount and relying on the content checks alone. The checks don’t stop a write from another account that races the copy. - Decided: the maintainer on PR748PR748 (merged): docs(spec): measure the Xcode export, signatures and offline importThe Xcode image design held back the build until a real Mac showed how Xcode and its simulator runtimes are exported, signed, licensed and imported., 2026-11-10. Treating other local accounts as adversaries in general is left to a separate review, and T00-indexT00-indexboundary 6 is the host terminal stream. is unchanged.
Out of scope
Section titled “Out of scope”- Other local accounts as an adversary beyond this volume.
- Building the disk on a host other than macOS, which Xcode doesn’t run on.
- Removing the runtimes that the export leaves installed on the host.
Status: Draft