X06 - Guest users and Xcode
Purpose: Whether Xcode builds, tests and simulators run for a project user that wb-guestd starts from root without a GUI login, and which Seatbelt exceptions they need.
For review
Section titled “For review”- Decides: the answer to X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login? (I20I20 (closed): X06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login?), which says what 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). can offer with full Xcode, and which work needs a GUI login session (S06-04-vms-and-placementS06-04-vms-and-placement: VMs and PlacementThe work VM and the isolated VM, Xcode in them, and which VM a project's sessions run in.).
- You are approving: the answer “yes, with conditions”. Without a
GUI login, a project user can build macOS and iOS apps, build and
test SwiftPM packages, sign to run locally, boot simulators, and run
iOS unit and UI tests on them. Every
xcodebuild teston macOS, a SwiftPM package’s included, and launching a macOS app need a GUI session. Onlyswift testruns macOS tests without one. Whether the isolated VM’s console user takes that work is open decision 1, and that fallback is not measured (I195I195 (open): macOS app tests need a console session: decide the isolated-VM fallbackFrom the X06-guest-xcode result (#20).). - Controls touched: none of the
SEC*controls changes. Layer 2 of S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. is weaker than its text implied: a simulator runs outside the session’s profile, andxcodebuild teston a simulator only finished under a profile that allows nearly every operation. Layer 2 adds to the host floor and never replaces it, so SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another. still rests on the project user, which the spike kept. S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. now says so (changed in this pull request). - Assumed: that the product image can get Xcode and the simulator runtimes the way the spike did, by copying the host’s Xcode from a read-only disk and downloading the runtime with no Apple ID (I194I194 (closed): Xcode image variant: getting Xcode and simulator runtimes into the imageFrom the X06-guest-xcode result (#20).). That a console session for macOS app tests can be had without a stored password in the image (I195I195 (open): macOS app tests need a console session: decide the isolated-VM fallbackFrom the X06-guest-xcode result (#20).).
- Open decisions:
- Whether v1 offers macOS tests through
xcodebuildand macOS app launches at all, and if so how the isolated VM gets a console session (I195I195 (open): macOS app tests need a console session: decide the isolated-VM fallbackFrom the X06-guest-xcode result (#20).). Recommended: not in v1. Nothing tellswb-hostdbefore a session that it will run such a test, so there is nothing to refuse it on. Instead the limit is documented, andwbturns thetestmanagerderror (“com.apple.testmanagerd.control was invalidated”) into an explained message that names it (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). - How the Xcode image variant gets Xcode and the runtimes (I194I194 (closed): Xcode image variant: getting Xcode and simulator runtimes into the imageFrom the X06-guest-xcode result (#20).).
- How a project that uses simulators is profiled (B20-guest-xcodeB20-guest-xcode: Can Xcode builds, tests and simulators run for a project user without a GUI login?Yes, with conditions., decision 2, I196I196 (open): Simulators leave the session: per-user launchd domain and the Seatbelt profileFrom the X06-guest-xcode result (#20), for S13-guest-confinement layers 1 and 2.). As specified now, no Layer 2 profile runs simulators, so a confined session can’t use them. Recommended: option 2A, a simulator profile for projects that declare simulators, as described in “The draft profile and its exceptions” below. The alternative is to keep looking for a narrower profile.
- Whether v1 offers macOS tests through
- Brief: B20-guest-xcodeB20-guest-xcode: Can Xcode builds, tests and simulators run for a project user without a GUI login?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 builds and simulators run for a guest user without
a GUI login? If not, Xcode sessions go to the isolated VM’s console
user. I20I20 (closed): X06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login? asks for xcodebuild build and test of a macOS app and an
iOS app, a simulator booted with simctl with tests run on it, SwiftPM
with a resource bundle, and code signing to run locally, each as a
non-admin user started from a root daemon. Then the same under a draft
Seatbelt profile, noting the exceptions it needs.
Answer
Section titled “Answer”Yes, with conditions. For a project user with no GUI login,
everything runs except every xcodebuild test on macOS (a SwiftPM
package’s included, where only swift test works) and launching a
macOS app. Each task, from the final run on a
fresh boot (results/final-matrix.txt):
| Task | setuid |
asuser |
Under the draft profile |
|---|---|---|---|
| SwiftPM build and test, resource bundle | yes, 48 s | yes, 280 s | yes, p1 |
xcodebuild build, macOS app (App Sandbox) |
yes, 14 s | yes, 13 s | yes, p1 |
xcodebuild build, iOS app for the simulator |
yes, 12 s | yes, 17 s | yes, p1 |
xcodebuild build, iOS app for a device, unsigned |
yes, 9 s | yes, 9 s | not run |
| Sign to run locally (ad hoc), and with a self-signed identity in a keychain the user creates | yes | yes | yes, p1 |
xcodebuild test, macOS app, hosted unit tests |
no | no | not run |
xcodebuild test, macOS UI tests |
no | no | not run |
xcodebuild test, SwiftPM package on macOS |
no | no | not run |
simctl create, boot, install, launch, screenshot |
yes, 143 s | yes, 166 s | yes, p1 |
xcodebuild test, iOS hosted unit tests, simulator |
yes, 35 s | yes, 31 s | p1: hangs. p2: yes |
xcodebuild test, iOS UI tests, simulator |
yes, 46 s | yes, 20 s | p2: yes |
setuid is how 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.’s session helper starts a session: the
child’s user, group and groups set directly, a new POSIX session, and
a PTY as its controlling terminal. asuser goes through
launchctl asuser <uid> first, which puts the child in launchd’s
per-user domain (user/<uid>, session type Background). A
setuid child stays in the system domain. The two answered the same
for every task. Without a PTY, the iOS tests passed and the macOS tests
failed the same way.
- Builds, SwiftPM and signing: yes. No step needed a login, a
keychain unlock prompt, or an Apple ID. The macOS app is signed ad
hoc with its App Sandbox entitlements and verifies with
codesign --verify --strict. A user can create a keychain in its home, import a self-signed code signing identity and sign with it, all from the command line. - Running a macOS app: no.
openfails with “Domain does not support specified action”, because there’s nogui/<uid>domain. Started directly, the App Sandbox app crashed in the system domain and kept running without a window in the Background domain. - macOS tests through
xcodebuild: no.testmanagerd’s LaunchAgent is limited to theLoginWindowandAquasession types, soxcodebuild testfails with “The connection to service named com.apple.testmanagerd.control was invalidated”. Loading a copy of that agent into the user’s Background domain made the SwiftPM package’s tests pass throughxcodebuild, but a hosted test still failed: RunningBoard launches the test host app into the missinggui/<uid>domain.swift testdoesn’t usetestmanagerdand works. The fallback the question names, the isolated VM’s console user, is not measured (I195I195 (open): macOS app tests need a console session: decide the isolated-VM fallbackFrom the X06-guest-xcode result (#20).). - Simulators: yes. CoreSimulator starts on demand for the
project user. Its services run in launchd’s
user/<uid>domain whichever way the session started, and render on the VM’s paravirtualized GPU. The app showed its window in a screenshot (results/g3-sim-setuid.jpg). Hosted iOS unit tests and an iOS UI test passed. - The simulator’s processes are outside the session.
CoreSimulatorService,launchd_simand the simulated device’s processes have launchd as their parent and POSIX session 0, so the session helper’s POSIX session doesn’t hold them. In the g3 run, a booted simulator brought the project user to 308 processes. In the final run, killing every process of the user in a loop found 218, then 11, then none. None came back in 5 seconds, andlaunchctl bootout user/<uid>then returned 0 with no process of the user left. The script’s next step printed the user’s domain withlaunchctl print. Two later checks found one process of the user,distnoted agent, started by launchd 11 s before the second check, with no session running (results/final-setup.jsonl,killuser,mem-after-kill,ps-after-kill). What started it, theprintor something else, wasn’t recorded. Whether a booted-out domain stays down while the user is locked is not checked yet (I196I196 (open): Simulators leave the session: per-user launchd domain and the Seatbelt profileFrom the X06-guest-xcode result (#20), for S13-guest-confinement layers 1 and 2.).
The draft profile and its exceptions
Section titled “The draft profile and its exceptions”The draft (p0) is the agent-safehouse v0.12.0 default selection as
X27-vsock-confinementX27-vsock-confinement: vsock confinement of project usersCan a non-root process in a macOS guest open AFVSOCK, and bind or listen on wb-guestd's port while wb-guestd is running or being restarted? rendered it, with S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection.’s grants
added: reads of /Applications/Xcode.app, reads and writes in the
project user’s home and worktree, and the vsock rule last. It runs the
task under sandbox-exec. Each exception was added after reading the
sandbox denials of a failed run.
Under p0, xcodebuild refuses to start (exit 69), and simctl can’t
load CoreSimulator. SwiftPM passed in the final run. In the first run
it failed the license check, which reads
/Library/Preferences/com.apple.dt.Xcode.plist.
p1, what builds, SwiftPM, signing and simctl need
(guest/xcode.sb). S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection.’s build profile takes the
build rows. The rest belong to option 2A below.
| Exception | For |
|---|---|
read /Library/Preferences/com.apple.dt.Xcode.plist |
the license check of xcodebuild and swift |
read /Library/Developer |
the CoreSimulator and CoreDevice frameworks that -runFirstLaunch installs. xcodebuild doesn’t start without them |
mach-lookup com.apple.SecurityServer, com.apple.security.syspolicy, and read /Library/Keychains |
a keychain in the user’s home, and codesign with an identity in it |
mach-lookup CoreSimulator’s XPC services and com.apple.CoreSimulator.simdiskimaged |
simctl and xcodebuild reaching the simulator service |
read /private/var/run/com.apple.security.cryptexd/mnt, metadata of /Volumes |
the mounted simulator runtime |
iokit-open-user-client IOSurfaceRootUserClient, AppleParavirtDeviceUserClient |
rendering |
mach-lookup com.apple.PowerManagement.control |
xcodebuild test refuses to start without a sleep assertion |
mach-lookup com.apple.distributed_notifications@1v3, the CoreDevice XPC service |
test progress notifications |
process-info-pidinfo and the procargs sysctls, and the base’s (deny process-info-pidinfo) left out |
xcodebuild watching the test runner |
The safehouse base denies process-info-pidinfo with a rule that a
later (allow process-info-pidinfo) doesn’t undo. Even (allow default) after it left xcodebuild test hanging. With that one rule
removed and (allow default) added, the test passed, so the generator
has to leave the rule out rather than allow pidinfo after it.
p2, what xcodebuild test on a simulator needs
(guest/xcode-simtest.sb). With p1 plus file-read*,
file-issue-extension, any mach-lookup and outbound Unix sockets,
the tests ran
and passed, but xcodebuild didn’t exit until the spike killed it, and
the log showed no Seatbelt denial. The runs’ outputs and exit codes
are in results/g3-bisect-tasks.jsonl, but the profile of each run
wasn’t kept, so the sets below come from the spike’s notes and are not
recorded.
The one lead is xcodebuild’s own message “attempt to post
distributed notification ‘IDETestProgressNotification’ thwarted by
sandboxing”, which it logs for any sandboxed process (I196I196 (open): Simulators leave the session: per-user launchd domain and the Seatbelt profileFrom the X06-guest-xcode result (#20), for S13-guest-confinement layers 1 and 2.). The
narrower sets tried all hung: file* alone, file* with
mach* and network*, file* with mach*, ipc* and process*,
and file* with network*, signal, iokit*, sysctl* and
system*. What finished was an allow of nearly every operation class:
file*, mach*, ipc*, network*, signal, process*, iokit*,
sysctl*, system*, user-preference* and a few more. With file*
allowed, the profile no longer confines the file system.
The simulator leaves the profile. Under p1, the session’s own
write to /Users/Shared was refused, and the same write through
xcrun simctl spawn <device> defaults write /Users/Shared/...
succeeded, as the project user. The simulator’s processes are started
by launchd, which S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection.’s “Known gaps” already names.
So any project that may use a simulator has no Layer 2 file
system confinement in practice. It keeps the project user’s Unix
permissions, which is what SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another. rests on.
Option 2A, a simulator profile (B20-guest-xcodeB20-guest-xcode: Can Xcode builds, tests and simulators run for a project user without a GUI login?Yes, with conditions., decision 2).
Only a project that declares simulators would get it. That
declaration is a host-side project setting that wb sets, never read
from .wraithbox/, even with config_trust (SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy.). On
top of the build profile of S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection., it would add:
- reads of the
cryptexdruntime mounts (/private/var/run/com.apple.security.cryptexd/mnt) and the metadata of/Volumes; - lookups of CoreSimulator’s services,
com.apple.CoreSimulator.simdiskimaged,com.apple.PowerManagement.control, distributed notifications and CoreDevice; - the
IOSurfaceRootUserClientandAppleParavirtDeviceUserClientuser clients; process-info-pidinfoand theprocargssysctls, with the base’s deny left out;- p2’s allow of nearly every operation class, for
xcodebuild test.
Unfiltered pidinfo shows the session every process in the VM with
its executable path. That the guest kernel still hides the arguments
and environment of other users’ processes from procargs is
unverified: the spike didn’t test it. Under this profile only the
AF_VSOCK deny is left, and it wasn’t checked again under it, so the
generator’s tests would run the X27-vsock-confinementX27-vsock-confinement: vsock confinement of project usersCan a non-root process in a macOS guest open AFVSOCK, and bind or listen on wb-guestd's port while wb-guestd is running or being restarted? check on every
profile they generate.
Measurements
Section titled “Measurements”Host: Apple M2, 8 cores, 16 GB, macOS 27.0.1 (26A434), Xcode 27.0
(27A266a), no sudo. Guest: an APFS clone of 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?’s sealed
bundle, macOS 27.0.1, 4 vCPU, 8 GiB, one file-handle network attachment
with nothing behind it, plus a read-only raw disk with a copy of the
host’s Xcode. The project user x06p was made with sysadminctl -addUser, is in staff only (not admin), and never logged in.
| Step | Time |
|---|---|
| Copy Xcode (3.9 GB) from the read-only disk | 125 s |
xcodebuild -runFirstLaunch as root |
62 s |
xcodebuild -downloadPlatform iOS (arm64, 8.05 GB, NAT boot), no Apple ID |
1202 s |
simctl boot to bootstatus finished |
44 to 70 s |
| Cold boot of the guest to the daemon answering | 9.7 to 11.8 s |
- SwiftPM under
asusertook 280 s in the final run, against 48 s undersetuid. The first run’sasusertime wasn’t recorded, and the final run had a booted simulator from the run before it. The spike didn’t find out why. - The hosts seen in the guest’s log during the runtime download
include
updates.cdn-apple.com,mesu.apple.comandgdmf.apple.com, which 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. expects to refuse an inspected leaf. Which of them the download used was not measured.
What was not measured
Section titled “What was not measured”- The console-user fallback for macOS app tests. Automatic login
for the project user writes
/etc/kcpassword, which the sealing scan forbids, and the agent’s permission policy refused turning it on in the spike clone (I195I195 (open): macOS app tests need a console session: decide the isolated-VM fallbackFrom the X06-guest-xcode result (#20).). - Signing with an Apple development certificate, and building for a device with signing. Both need an Apple ID.
- A narrower set for
xcodebuild teston a simulator. The spike stopped at p2 (I196I196 (open): Simulators leave the session: per-user launchd domain and the Seatbelt profileFrom the X06-guest-xcode result (#20), for S13-guest-confinement layers 1 and 2.). - watchOS, tvOS and visionOS simulators, and Xcode’s GUI.
- The time a cold boot adds before the first simulator boot, and the memory a booted simulator takes. The guest’s free memory went from 88% to 82% of 8 GiB with one booted simulator.
What it means for the specs
Section titled “What it means for the specs”- S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection., “Layer 2”: the Xcode build profile, which
runs no simulators, and in “Known gaps” the simulator processes
outside every profile and agents launchd starts again. B20-guest-xcodeB20-guest-xcode: Can Xcode builds, tests and simulators run for a project user without a GUI login?Yes, with conditions.
decision 2 would add a simulator profile. “Layer 1”: where
wb-guestdkills every process of a project user, the kill loop and abootoutof the user’s launchd domain repeat until none is left, for at most 10 rounds and 30 seconds. Both bounds are chosen, not measured: the spike’s loop needed two rounds. Past themwb-guestdlogs the failure, leaves the user locked and reports the project as not cleaned up (changed in this pull request). - The build profile in S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection. wasn’t run as written: the spike’s p1 also had the simulator rules. The generator’s tests run every build task under it (I196I196 (open): Simulators leave the session: per-user launchd domain and the Seatbelt profileFrom the X06-guest-xcode result (#20), for S13-guest-confinement layers 1 and 2.).
- 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., “Leftover processes”: the same
bootout(changed in this pull request). - 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., “VMs”: every
xcodebuild teston macOS and launching a macOS app need a GUI login session, which the work VM doesn’t have (changed in this pull request). Where that work goes is open decision 1. “Images” is unchanged until I194I194 (closed): Xcode image variant: getting Xcode and simulator runtimes into the imageFrom the X06-guest-xcode result (#20). decides how Xcode and the runtimes get in. - 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…, “Spikes”: lists X06-guest-xcodeX06-guest-xcode: Guest users and XcodeCan builds and simulators run for a guest user without a GUI login? (changed in this pull request).
- 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). stays as it is. Full Xcode works for builds and SwiftPM under the Layer 2 profiles as specified. iOS simulators and their tests work only with decision 2’s option 2A, outside those profiles.
Spike code
Section titled “Spike code”Branch spike/x06-guest-xcode, at
25dacb5:
the Swift wb-vmd stand-in, the guest daemon with runas, the task
scripts, the generated test projects, the profiles and their
exceptions, and the raw results in results/. The spike’s bundle g1
and its Xcode disk are spike artifacts, and no product image may
descend from them.
Follow-up (I624): the host export and the Xcode disk
Section titled “Follow-up (I624): the host export and the Xcode disk”For review
Section titled “For review”- Decides: nothing new. It measures the steps 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. specifies, on the host and in a guest, and corrects the spec where a measurement contradicts it. After the attended steps, the license check drops the Xcode version, and the Xcode code requirement gets a third branch.
- You are approving: the corrections to 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. listed in “What it means for the specs” below. The largest: an exported runtime is a directory with a signed disk image in it, and the runtime rules now check the directory and what it holds.
- Controls touched: none weakened. SEC12-least-privilegeSEC12-least-privilege: Least privilege on the hostNo root or administrator rights at run time and no extra host user accounts.: the
shim’s profile needs more than
wb-diskfmt’s. S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow 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. names the additions: the one Mach service,com.apple.trustd.agent, and the system reads. “The profile” below lists the measured rules, the list 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. SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.: the Xcode disk is sized from file sizes, and the build VM needs room for every runtime. 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.: the shim mounts the blank volume only on its own directory in the bundle, under the existing exception. The runtime’s disk image has an Apple signature, which the shim now checks withidentifier image and anchor apple, and a changed byte fails it. The Xcode requirement’s new third branch usesanchor apple, which only Apple’s own signing certificates meet, notanchor apple generic, which every Developer ID meets. - Assumed: nothing beyond the measurements. The maintainer ran the attended steps on 2026-11-10, and their results settle what this section first left open: the license check compares the license ID only, and the code requirement has a third branch for the developer-site install.
- Decided by the maintainer: the blank volume is never mounted in
/Volumes(S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow 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., “Never mounted in/Volumes”). Other local accounts as an adversary in general are left to a separate review.
Question
Section titled “Question”From 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)., for 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. as written:
- What does
xcodebuild -downloadPlatform iOS -exportPathwrite, and in what form? - Do the code requirements hold on the host’s Xcode and the exported runtime, and does a changed byte fail them?
- Where is the license record, and what does it hold?
- Do the guest steps work with the network off and the Xcode volume read-only?
- Does the build of the Xcode disk work under a profile like
wb-diskfmt’s, and how long does each step take?
Answer
Section titled “Answer”- A directory per runtime. The export wrote two directories, one
per runtime, named
<platform>_<version>_<build>.exportedBundle:iphonesimulator_27.2_24B8117.exportedBundleandiphonesimulator_27.2_24B91016s.exportedBundle(the second is the iPhone19-4 variant). Each is 8.3 GB. In each,Restore/holds one disk image,BuildManifest.plistandRestore.plist, andRestore/Firmware/holds the image’s.cryptex_info,.root_hashand.trustcachefiles.ExportedMetadata.plistis at the top. The whole download and export took 542 s. After the run,xcrun simctl runtime liston the host showediOS 27.2 (24B8117)andiOS 27.2 (24B91016s), both Ready, two disk images of 15.5 GB in total (attended step 2). - Yes, with a third branch. On the App Store Xcode,
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 first code requirement holds, and plain
anchor appleexits 3. Xcode 27.2 from the developer site’s.xipis signed differently: its leaf is Apple’s Software Signing certificate, under Apple Code Signing Certification Authority and Apple Root CA, with team59GAB85EFG. Its designated requirement isidentifier "com.apple.dt.Xcode" and anchor apple. The first and second branches exit 3 on it, and that requirement as a third branch exits 0. The requirement with all three branches holds on both installs.pkgutil --check-signaturecalls the.xip“signed Apple Software”, under Software Update, Apple Software Update Certification Authority and Apple Root CA. The runtime’s disk image is signed with identifierimageby Apple’s macOS Software Signing certificate, andidentifier image and anchor appleholds. One byte changed in a framework of a copy of the App Store Xcode fails the check with “invalid signature (code or signature have been modified)”, and so does one byte changed in a copy of the disk image.codesigndoesn’t find a signature on the other files of an export. /Library/Preferences/com.apple.dt.Xcode.plist, owned by root, mode 0644. It holds the accepted license’s ID per type (IDELastGMLicenseAgreedTo = EA2002) and the Xcode version that accepted it (27.0, while the host runs 27.2). The app names its license inContents/Resources/LicenseInfo.plist:licenseIDEA2002,licenseTypeGM. Xcode 27.2 counts the record from 27.0 as accepted:xcodebuild -license checkexits 0 on the host (attended step 1).- Yes, with another import command. With every interface down
and the volume mounted read-only, the copy, the signature check,
xcodebuild, the license, the first launch and the runtime import all worked, and an iOS simulator booted on the runtime in 33 s.xcodebuild -importPlatformfailed, both on the exported directory and on its disk image. It copied its input into root’s temporary directory first. It then refused with “Cannot copy the image because the disk is almost full” at 22 GiB free, and left that copy behind.xcrun simctl runtime addon the disk image imported it in 46 s. - Yes, with more rules. A throwaway shim, confined by
selfsandboxwithwb-diskfmt’s profile plus the rules below, read the license record, checked Xcode and the runtime, made a 24 GiB image, formatted it, mounted it on a directory in the bundle, copied Xcode without_MASReceiptand one runtime into it, checked the copy and ejected it. A read outside its parameters was refused.
Measurements
Section titled “Measurements”Host: Apple M2, 16 GB, macOS 27.2 (26B123), Xcode 27.2 (27B52) from
the App Store, in /Applications, 4.0 GB on disk and 10 GB of file
sizes (APFS compression). Guest: an APFS clone of the dev base bundle,
macOS 27.2 (26B123), 4 vCPU, 4 GiB, a 64 GiB system disk, and the
shim’s xcode.img as its second disk. The guest had a NAT network for
SSH, and the script turned every interface but lo0 down before each
step below. curl then failed with “no route”.
On the host, unconfined:
| Command | Result | Time |
|---|---|---|
codesign --verify --deep --strict -R=<S06-14 requirement> Xcode.app |
exit 0 | 14.5 s |
the same with -R='anchor apple' |
exit 3, “code failed to satisfy specified code requirement(s)” | 15.2 s |
the same on a ditto copy without _MASReceipt and extended attributes |
exit 0 | 15.0 s |
the same on a copy with one byte of IDEFoundation changed |
exit 1, “invalid signature (code or signature have been modified)” | |
| the three-branch requirement on the App Store Xcode | exit 0 | 37.3 s |
codesign --verify --strict -R='identifier image and anchor apple' on the runtime disk image |
exit 0, spctl: accepted, source Apple System |
22 to 24 s |
| the same on a copy with one byte changed | exit 1, “invalid signature” | 22.6 s |
On Xcode 27.2 (27B52) expanded from the developer site’s .xip, on the
host, unconfined:
| Requirement | Result | Time |
|---|---|---|
| first branch, App Store leaf | exit 3 | 15.2 s |
| second branch, Developer ID with Apple’s team | exit 3 | 13.8 s |
third branch, identifier "com.apple.dt.Xcode" and anchor apple |
exit 0 | 15.9 s |
| all three branches | exit 0 | 20.4 s |
anchor apple generic and identifier "com.apple.dt.Xcode", never accepted, for reference |
exit 0 | 67.7 s |
The attended steps on the host, run by the maintainer:
| Command | Result |
|---|---|
xcodebuild -license check, record at 27.0, Xcode 27.2 (27B52) |
exit 0 |
xcrun simctl runtime list |
both iOS 27.2 runtimes Ready, 2 disk images, 15.5 GB |
pkgutil --check-signature on the .xip |
“signed Apple Software” |
codesign -d -r- on the expanded app |
leaf Software Signing, team 59GAB85EFG |
The runtime list’s output began with “Install Started” and “Install
Succeeded”, and with a line from CoreSimulator: “Framework version
(1174.21) does not match existing job version (1174.9.2)”. It is
recorded as seen. What caused it wasn’t looked into.
The shim’s steps, confined, over five runs:
| Step | Time |
|---|---|
| Deep check of the host’s Xcode | 53 to 107 s |
| Check of one runtime disk image | 22 to 27 s |
| SHA-256 of one runtime disk image | 4.4 s |
diskutil image attach --noMount, eraseDisk, unmount, mount -mountPoint |
0.25, 1.2, 0.3, 0.2 s |
ditto of Xcode |
78 to 81 s |
ditto of one runtime |
10 to 11 s |
| Deep check of the copy | 45 to 46 s |
unmount, eject |
0.6, 0.2 s |
The copy on the volume took 10 GB, because ditto without
--hfsCompression writes files uncompressed. The 24 GiB image had
19.1 GB allocated after Xcode and one runtime. With
--hfsCompression, confined, ditto failed to write a file, still
exited 0, and the check of the copy failed with “code object is not
signed at all”.
In the guest, as root:
| Step | Result | Time |
|---|---|---|
diskutil mount readOnly wb-xcode, then a write |
“Read-only file system” | |
ditto --norsrc --noextattr --noacl --noqtn to /Applications |
167,224 entries owned by UID 99 | 88.9 s |
chown -R root:wheel, chmod -R go-w |
9.3 s, 4.2 s | |
| Deep check of the copy with the requirement | exit 0 | 59 s |
spctl --assess |
accepted, source Mac App Store | |
xcodebuild -version (first run) |
Xcode 27.2, 27B52 | 43 s |
xcodebuild -license accept |
exit 0, writes the record with version 27.2 |
0.11 s |
xcodebuild -license check |
exit 0 | |
xcodebuild -runFirstLaunch |
“Install Succeeded” | 22.8 s |
| Check of the runtime disk image | exit 0 | 29.8 s |
xcodebuild -importPlatform on the directory, 8.4 GiB free |
“Cannot copy the image because the disk is almost full”, exit 70 | 22 s |
ditto ... --hfsCompression of Xcode, after removing the first copy |
4.0 GB, check of the copy exit 0 | 139.6 s |
xcodebuild -importPlatform on the directory, 22 GiB free |
the same message, a 7.7 GB copy left in root’s temporary directory | 26 s |
xcrun simctl runtime add on the disk image, 30 GiB free |
iOS 27.2 (24B8117) ... (Ready), 7.7 GB |
46 s |
xcrun simctl bootstatus -b on an iPhone 18 Pro |
Finished | 33 s |
-runFirstLaunch added three com.apple.* system jobs
(CoreDevice.CoreDeviceDDIUpdaterService,
CoreSimulator.simdiskimaged, PerformanceTrace.PerformanceTraceService)
and no file in /Library/LaunchDaemons or /Library/LaunchAgents.
Everything it wrote outside /Users is owned by root: the frameworks
in /Library/Developer/PrivateFrameworks, the developer disk images in
/Library/Developer/DeveloperDiskImages, and CoreSimulator’s
directories. No new file outside /Users was owned by a UID of 500
or more, so the sealing scan has nothing to refuse.
The import didn’t add any file outside /Users owned by a UID of 500 or
more. Its disk image went to
/Library/Developer/CoreSimulator/Cryptex/Images/Inbox, owned by
root. The failed imports left a copy of their input in root’s
temporary directory and one in that Inbox. A later -importPlatform
of the same input then failed with “an item with the same name already
exists”.
What was not measured
Section titled “What was not measured”- A Developer ID install. The developer-site install is signed with Software Signing, so the second branch matched no install measured here.
- A guest with no network device. The guest had a NAT device with
its interfaces turned down.
wb-dev-bundleattaches a network to every VM it starts, and a start without one is a new option there. - The shim’s file and
sysctlrules are not minimal. They arewb-diskfmt’s with every rule the runs needed added, and no rule was taken out to see whether it is needed. The Mach services were narrowed afterward (“The profile” below). - The launchd jobs’ program paths. The guest run listed the three new labels, not where their programs are.
- An import without the runtime’s
Firmwarefiles. - Xcode’s GUI, and the iPhone19-4 runtime.
The profile
Section titled “The profile”The throwaway shim ran with wb-diskfmt’s profile plus these rules,
for 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). to start from:
- read
/Applications/Xcode.app’s real path,<data>/xcode-runtimesand/Library/Preferences/com.apple.dt.Xcode.plist, and the metadata of/Applications; - read, write,
file-mountandfile-unmountunderxcode-mntin the build bundle; process-execof/usr/bin/dittoand/usr/bin/codesign;mach-lookupofcom.apple.trustd,com.apple.trustd.agent,com.apple.SecurityServer,com.apple.ocspdandcom.apple.system.opendirectoryd.libinfo;sysctl-readofkern.bootargs,kern.osproductversion,kern.osvariant_status,kern.iossupportversion,hw.ephemeral_storage,security.mac.lockdown_mode_stateandsecurity.mac.amfi.qa_root_certs_allowed;system-infovfs.disk-space;- metadata of
/System/Cryptexes/OS,/System/Cryptexes/App,/etc,/var,/Users, and each parent of the build bundle and of the runtimes folder, and read of/usr/share/icu.
The Mach services were then measured one by one with sandbox-exec,
with every file read and sysctl-read allowed, and codesign and
ditto run directly (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).’s builder, and again in 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.’s security
review):
Profile’s mach-lookup |
Runtime disk image | Xcode, three branches |
|---|---|---|
| none | exit 1, CSSMERR_TP_NOT_TRUSTED, 0.1 s |
exit 1, 1.0 s |
com.apple.trustd only |
exit 1, CSSMERR_TP_NOT_TRUSTED |
|
com.apple.trustd.agent only |
exit 0, 26.1 s | exit 0, 16.7 s |
| both trust services | exit 0, 25.2 s | exit 0, 31.2 s |
| both, with a wrong requirement | exit 3, 20.6 s |
ditto --norsrc --noextattr --noacl --noqtn of an exported runtime
didn’t need a service, and the copy’s disk image equals the source’s. That
copy was on the same volume. So com.apple.trustd.agent is the one
service S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow 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. allows. com.apple.SecurityServer, which
serves the keychain, com.apple.ocspd and the user database lookup
aren’t needed for these checks.
The same security review measured what codesign --verify --deep --strict with the requirement doesn’t catch, on a ditto copy of an
App Store app signed like Xcode. A planted executable in
Contents/_MASReceipt, a new _MASReceipt in a nested .appex or
framework, a .DS_Store with arbitrary bytes in Resources, mode 6755
on the main executable, and mode 0777 on Info.plist and Frameworks
all passed with exit 0. Its second round found the same for arbitrary
bytes in Contents/PkgInfo and in a locversion.plist directly in a
Resources/*.lproj, in every nested bundle. Its third round found the
same for an unsealed CodeResources at a bundle’s resource root and an
Info.plist at a framework’s version root. A new file in Resources
and a file in _CodeSignature failed with exit 1.
Those files are the omit rules of each bundle’s rules2 in
_CodeSignature/CodeResources, plus _MASReceipt. In the host’s
Xcode, all 996 CodeResources files omit ^(.*/)?\.DS_Store$,
^Info\.plist$ and ^PkgInfo$. 834 omit
^Resources/.*\.lproj/locversion.plist$, and the other 162
^.*\.lproj/locversion.plist$. Its 33 PkgInfo files are regular
files of 8 bytes. The third round found that only 529 of the 996
belong to a bundle that an enclosing bundle’s files2 lists with a
cdhash, and so govern their paths. The other 467 are plain files
under the enclosing seal. MacOSX.platform’s
^.*\.lproj/locversion.plist$ would otherwise refuse the
locversion.plist it ships, which its enclosing seal covers. On the
installed Xcode, three files were outside every seal: the receipt and
two PkgInfo files.
S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow 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., “What the signature doesn’t seal”, turns that into
checks in the shim and in install-xcode.
Attended steps
Section titled “Attended steps”.scratch/attended/624-host.sh on the branch’s worktree, run by the
maintainer on 2026-11-10, each step writing a file that the builder
read. The .xip and the expanded app were deleted afterward:
{ xcodebuild -version; xcodebuild -license check; echo "license check rc=$?"; } 2>&1 | tee .scratch/m/attended-license-check.txtxcrun simctl runtime list 2>&1 | tee .scratch/m/attended-host-runtimes.txtpkgutil --check-signature .scratch/xip/Xcode_27.2.xip 2>&1 | tee .scratch/m/attended-xip-signature.txt(cd .scratch/xip && xip --expand Xcode_27.2.xip)codesign -d -r- -vvvv .scratch/xip/Xcode.app 2>&1 | grep -E 'Authority|designated|TeamIdentifier' | tee .scratch/m/attended-xip-codesign.txtWhat it means for the specs
Section titled “What it means for the specs”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., changed in this pull request:
- “Where the runtimes come from”: the export is a directory per
runtime.
xcode-runtime-namechecks the directory’s name, the newxcode-runtime-layoutchecks that it holds only the files above, and the size cap counts the sum of the files’ sizes. One export can write more than one runtime. - “The checks on the host”: the runtime’s check is
codesignwithidentifier image and anchor appleon its disk image. The code requirement for Xcode gets a third branch,identifier "com.apple.dt.Xcode" and anchor apple, for the developer-site install. The license record doesn’t name a build, and Xcode accepts a record from an older version. The license check compares the license ID for the app’s type only. - “Where the runtimes come from”: after the export, the host listed
both runtimes as installed and
Ready. - “In the build VM”: the guest checks each runtime’s disk image before
it imports it, refuses a receipt, a
.DS_Storeor a file not owned by root in the copy, and clears setuid and setgid bits. The sealing scan accepts the three launchd jobs of-runFirstLaunch, and only in an Xcode image. - “In the build VM”: the guest copies Xcode with
--hfsCompressionand sets the owner itself, imports each runtime withxcrun simctl runtime addon its disk image, and needs room for Xcode and every runtime on its system disk.
S06-15-xcode-diskS06-15-xcode-disk: The Xcode DiskHow 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., new in this pull request, takes “The Xcode disk” and “What the build records” 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., which had grown past a page’s length:
- the image is sized from the sum of
st_size, not from blocks; eraseDiskmounted the new volume in/Volumesin this run. The shim instead creates it without that mount and mounts it only on a directory in the bundle, withaddVolume -nomountanddiskutil mount, which 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. It checks the mount’s flags, finds the volume by device only, and requires an empty volume before the copy and only what it copied before the unmount;- the copy drops
_MASReceiptand.DS_Storeat any depth, and holds every other file to the seal of the bundle that governs it; - the copy is checked again, runtimes included, and the reported values come from the copy;
- the profile’s additions are named, with
com.apple.trustd.agentas the one Mach service, and the timings above set the deadlines; - the build records the SHA-256 of each copied runtime disk image.
Spike code
Section titled “Spike code”The throwaway shim (main.go, profile.go) and the guest scripts
stayed in the builder’s worktree under .scratch/, and were not
committed.
Status: Answered 2026-10-08: yes, with conditions. Follow-up measured 2026-11-10 (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 export is a directory per runtime with a signed disk image, both code requirements hold and fail on a changed byte, the confined shim builds the Xcode disk, and the guest steps work offline with simctl runtime add. Attended steps 2026-11-10: Xcode accepts an older license record, and the check compares the license ID only. The developer-site install needs a third requirement branch, identifier "com.apple.dt.Xcode" and anchor apple