S17-01 - The Bundle
Purpose: What a Wraith Box bundle holds, and how mise run build
builds and signs it.
Design
Section titled “Design”The bundle
Section titled “The bundle”On macOS the bundle is Wraith Box.app. It holds the programs and
helper bundles of S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps.:
- The programs without a Keychain access group are in
Contents/MacOS,wb-downloadandwb-diskfmtincluded. - The guest tools disk (S06-12-guest-agentS06-12-guest-agent: Guest AgentWhat wb-guestd, the service in the guest, does for the host, and how it updates itself., “
wb-guestd”) isContents/Resources/wb-guest-tools.img. - The app’s main executable is the notification helper. macOS shows a notification under the bundle of the process that posts it.
Info.plist holds the bundle identifier. It also holds the build
version that every program is stamped with, under the key
WBBuildVersion (S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps., “One build version”). wb-hostd
reads that key to notice an upgrade (S04-07-supervisionS04-07-supervision: SupervisionWho starts and restarts each host process, what happens when wb-hostd stops or the bundle is upgraded, and daemon outages., “Upgrades”).
Info.plist is an XML property list, because wb setup and wb-hostd
read it with a plain XML reader. So is each helper bundle’s. It holds
the app’s bundle identifier, the helper’s executable, the package type
APPL and LSUIElement.
Building a bundle
Section titled “Building a bundle”mise run build runs app:bundle on a macOS host, in this order.
Before step 1 starts, the build checks the signing identity (“Signing
identity” below). So a setting it refuses stops the build before
anything is built.
- One version stamp for the whole run (S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice.).
go buildof the host programs, and ofwb-guestdandgit-remote-wbfor the guest.swift build -c releaseofwb-vmd.xcodebuildof the app project,packages/wraithbox-swift/WraithBox.xcodeproj. It has one app target, whose executable is the notification helper. Signing depends onWB_TEAM_ID(“Signing identity” below).- The guest tools disk: the guest programs, signed as in step 7, and
a
VERSIONfile. They go in one APFS volume of a raw disk image, the format Virtualization attaches. - Assembly into the app from step 4. The app gets the programs,
wb-vmd, the guest tools disk andWBBuildVersion. Each program with a group gets a helper bundle, with the app’s profile copied in when there is one. - Signing from the inside out, with the hardened runtime: each
program, then each helper bundle, then the app. Only
wb-vmdgets the virtualization entitlement. Steps 6 and 7 run together: each program is signed when it goes into the app, and each helper bundle when its program is in it. The app is signed last. - The entitlement check (“The entitlement check” below), and
codesign --verify --deep --stricton the app. Either failing fails the build.
The entitlement check
Section titled “The entitlement check”The programs of the bundle are named in one layout table, in the code. The build takes the programs from that table, never every command it could build, so a dev tool never ships.
The check finds every Mach-O file in the bundle and on the guest tools disk by its magic number, not by its name or place. It reads each one’s signed entitlements. The build fails unless:
-
every Mach-O file is a program of the table, at its place, and every program of the table is there;
-
each Go program is built from its own command package, and no other program is Go;
-
no program is a test build with a test data root: none has the section
__wb_test_buildor__wb_test_datain any segment, and no Go program is built with the tagwbtestdataroot(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., “Test data root”); -
neither the bundle nor the disk holds a symbolic link;
-
every program is signed with the hardened runtime, by the build’s team, or without a team in an ad-hoc build;
-
the access groups follow S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps., “Helper bundles”. The check counts the groups of
keychain-access-groups,com.apple.application-identifierandcom.apple.security.application-groups, the group entitlements; -
only
wb-vmdhas the virtualization entitlement, and it has it; -
no program has an entitlement outside its build’s allowlist:
- without a team: the three group entitlements, refused by the group rule, and the virtualization entitlement;
- with a team:
keychain-access-groups,com.apple.application-identifier,com.apple.developer.team-identifierwith the build’s team, and the virtualization entitlement.
So
get-task-allow,disable-library-validationandallow-dyld-environment-variablesfail in both, and so doescom.apple.vm.networking, which S15-01-rightsS15-01-rights: RightsWhich rights Wraith Box takes on the host, and which entitlements its binaries hold., “Hardening and entitlements”, doesn’t give any process. The application identifier names a group, so the group rule still refuses it on every program; -
without a team, the bundle has no profile;
-
with a team, each helper bundle has a profile, and every profile in the bundle decodes with a
TeamIdentifierof exactly that team; -
each
Info.plistholds what “The bundle” above says, with the bundle identifier the build chose; -
the app’s
LSMinimumSystemVersionis the oldest macOS thatwb setupaccepts (NFR04-host-platformsNFR04-host-platforms: Host platformsFirst target: Apple Silicon, macOS 27 or later, because wb image build needs the guest provisioning options that are new in macOS 27 (X17-image-build).), so macOS doesn’t open the app on a Mac thatwb setuprefuses; -
every program,
WBBuildVersionand the disk’sVERSIONfile hold the run’s version stamp.
Signing identity
Section titled “Signing identity”With WB_TEAM_ID set:
- A value that isn’t ten uppercase letters and digits is refused before the build runs anything with it.
- The bundle identifier is
nl.wraithbox.dev.<teamid>, with the team ID in lowercase, orWB_BUNDLE_IDwhen that is set. xcodebuildbuilds with automatic signing for that team, and with-allowProvisioningUpdates, so Xcode registers a new bundle identifier and fetches its profile. Xcode makes a profile only for entitlements that need one. So the build passes it an entitlements file with one access group,<TEAMID>.nl.wraithbox.xcode-profile, as X29-dev-signingX29-dev-signing: Keychain access group for development buildsCan a developer's free personal team, an Apple ID signed in to Xcode without a paid membership, sign the helpers in Wraith Box.app (wb-proxyd, wb-hostd, wb-vmd) with a keychain-access-groups entitlement and a provisio… signed its app with one. That group is in no row of S15-02-secret-storeS15-02-secret-store: The Secret StoreWhere credentials are held: the secret store, its backends, and the guarantees a backend must give.. Step 7 signs the app again without entitlements, and the check refuses the group if the app still holds it.- The build fails, before it puts the bundle together, unless Xcode
gave the app a profile whose
TeamIdentifieris exactly that team (S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed., “Missing profile”). - Step 7 signs with the team’s one Apple Development identity: the
identity whose name starts with
Apple Development:and whose certificate has the team as its organizational unit. The build chooses it by the certificate, never by a part of the name. None, or more than one, fails the build with a list of the identities it found. - Step 7 signs the guest programs with that identity too. It doesn’t add a secure timestamp, as Xcode doesn’t for a development build.
- Each helper bundle gets a copy of the app’s profile, and its
entitlements hold only
keychain-access-groupswith its row’s groups (S10-02-packaging-and-signingS10-02-packaging-and-signing: Packaging and SigningHow Wraith Box is packaged and signed on each host, and the one version every build stamps., “Helper bundles”).wb-vmdkeeps only the virtualization entitlement, and the other programs get none. - The entitlement check runs for that team, and refuses a program another team signed, or none.
Without WB_TEAM_ID:
- The bundle identifier is
nl.wraithbox.dev.adhoc, orWB_BUNDLE_IDwhen that is set. - A
WB_BUNDLE_IDthat isn’t a reverse-DNS identifier is refused. - Xcode signs nothing (
CODE_SIGNING_ALLOWED=NO). - Step 7 signs ad-hoc (
codesign -s -).
Output
Section titled “Output”The bundle is written to
packages/wraithbox-swift/.build/Wraith Box.app. The build puts it
together in a work directory, and moves it to that path only when step
8 passes. So a bundle that fails its checks is never where
app:install reads.
CI runs app:bundle without WB_TEAM_ID. Every pull request builds
the ad-hoc bundle and runs its checks. CI has no Apple Development
identity. The team-signed build runs on a developer’s Mac only.
mise run app:install installs the built bundle as
~/Applications/Wraith Box.app (S17-05-upgrades-and-migrationsS17-05-upgrades-and-migrations: Upgrades and MigrationsHow an upgrade replaces the bundle, and how wb-hostd moves stored data to a new version., “Upgrades”).
Status: Draft