S10-02 - Packaging and Signing
Purpose: How Wraith Box is packaged and signed on each host, and the one version every build stamps.
Design
Section titled “Design”An app bundle, Wraith Box.app, contains:
wb-hostd,wb-launcher,wb-vmd,wb-netd,wb-proxyd,wb-git,wb-prover,openshell-prover,wb-guestadmin,wb-credset,wb-build-ssh,wb-diskfmt,wb-release-check,wb-download;- the notification helper;
- the guest tools disk image;
wb, which the installer links ontoPATH.
A bundle is needed for notifications, Keychain access groups, and
launch-agent registration. It uses the hardened runtime. Only wb-vmd
has the virtualization entitlement. How it is built, installed and
upgraded is in S17-install-and-upgradeS17-install-and-upgrade: Install, Downloads and UpgradesBuild, install, upgrade and remove a Wraith Box bundle, move its stored data to a new version, and download what an image build needs from the internet.. Distribution is via a
Homebrew cask, once signed builds exist.
Helper bundles
Section titled “Helper bundles”Each program that holds a Keychain access group (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.,
and S15-03-access-rulesS15-03-access-rules: Access RulesHow each host process gets only the credentials it needs, for only as long as it needs them, and which process may access which item., “Declared access”) is the main
executable of its own bundle, Contents/Helpers/<name>.app. The
executable is at Contents/MacOS/<name> inside it. The app’s
provisioning profile is copied to its
Contents/embedded.provisionprofile.
These are wb-credset, which wb cred runs, wb-proxyd, and
wb-guestadmin, which wb-launcher’s three wb-guestadmin-* entries
start.
wb doesn’t hold a group, and is a plain executable.
macOS looks for the profile that allows the restricted
keychain-access-groups entitlement only in the bundle whose main
executable starts. So AMFI kills a plain executable in Contents/MacOS
that claims a group at launch (-413, “No matching profile found”).
Each helper bundle has the app’s bundle identifier and LSUIElement.
Its entitlements hold the groups of its items, from the table in
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., “Keychain”, and no others. The build fails unless:
- each helper’s signed entitlements equal its row’s groups exactly;
- every other program,
wbincluded, has no entitlement that names a group.
Apple takes a program’s access groups from keychain-access-groups,
the application identifier (com.apple.application-identifier) and the
application groups (com.apple.security.application-groups). The check
counts all three (S17-01-bundleS17-01-bundle: The BundleWhat a Wraith Box bundle holds, and how mise run build builds and signs it., “The entitlement check”).
The installer’s wb link on PATH points to Contents/MacOS/wb. A
program without a group doesn’t need a bundle of its own
(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…).
The layout is the same in every build, ad-hoc included. So
wb-launcher’s fixed program table and the installer’s link hold in
each. An ad-hoc build’s helper bundles have no profile and no group.
Signing
Section titled “Signing”Release builds get Developer ID signing and notarization later.
Development builds (mise run build) are signed with the developer’s
own Apple Development certificate.
The build takes the developer’s team ID as a setting, the environment
variable WB_TEAM_ID.
- The bundle identifier of a development build is
nl.wraithbox.dev.<teamid>, with the team ID in lowercase.WB_BUNDLE_ID, when set, replaces it. - A release build uses Wraith Box’s own identifier.
The build gets the profile from Xcode, 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… did:
- It builds the app’s Xcode project with
xcodebuild, automatic signing and that team. - It copies the profile Xcode embeds into each helper bundle.
- It signs from the inside out.
A build with WB_TEAM_ID set fails when Xcode gives it no profile. Its
message names the one-time setup in S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed., “Development builds on macOS”.
Without the setting, the build:
- is ad-hoc signed;
- has the bundle identifier
nl.wraithbox.dev.adhoc, orWB_BUNDLE_ID; - doesn’t give any program an access group;
- has no Keychain backend (S15-least-privilegeS15-least-privilege: Least Privilege on the HostThe security design for SEC12-least-privilege: which rights Wraith Box takes on the host, where credentials are held, and how each host process gets only the credentials it needs, for only as long as it needs them.).
Where a bundle has no profile, the profile checks of S12-03-host-prerequisitesS12-03-host-prerequisites: Host PrerequisitesWhat wb setup checks on each host, and how a development build on macOS gets signed., “Development builds on macOS”, don’t apply.
Each developer’s team gets its own explicit identifier, because Apple may refuse one team’s registered identifier to another (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… used one team). A Developer ID build has a profile in each helper bundle for its groups.
Other hosts
Section titled “Other hosts”- Windows (later): a per-user installer, with no administrator
rights, with the same set of binaries as
.exe. Code signing when available. - Linux (later): a tarball and an Ubuntu package with the same binaries, and a systemd user unit.
- WSL: the Linux
wbbinary. It requires the Windows installation (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.).
Each host daemon applies its own confinement at start (S04-architectureS04-architecture: ArchitectureName the processes, the boundaries between them, and which requirement each boundary serves.).
One build version
Section titled “One build version”Every build task stamps one version into every program of the bundle,
Go and Swift alike, and into the guest tools disk image. The files are
internal/version/version.go and WraithBoxVM/Version.swift. The
build tasks are the release build, the dev build (mise run build) and
CI.
- The version is the release number in
VERSION, with the VCS revision as its build part. - A build of a modified working tree adds a modified flag and a nonce. So builds of a modified tree from two runs never match.
- The nonce is made once per
mise run buildinvocation, and shared by every language task in it. So a partial rebuild of a modified tree needs a full build.
The task version:stamp makes the version and writes it to
build/version. Every build task reads it from that file. It refuses a
stamp that names another commit, and a clean stamp once the tree has
changes. A modified tree’s stamp can’t be checked against later
edits, so a modified tree needs a full build in one run, with no edits
while it runs. Go links it into a variable, and
Swift has the linker copy it into a section of each program. The guest
tools disk gets it as its VERSION file (S17-01-bundleS17-01-bundle: The BundleWhat a Wraith Box bundle holds, and how mise run build builds and signs it.).
Only a bare toolchain build (go build, go run, swift build) is
unstamped. It has no version, and every peer refuses it, an unstamped
peer included. A stamp outside the version form
(S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs., “The guest’s version is a label”) counts as
none. Tests that exercise the version exchange set the version
explicitly. Integration tests build through the stamping task (I174I174 (closed): Stamp the VCS revision into the build version, and treat an unstamped build as no versionFollow-up from the security review of #171 (#48, finding L5).).
Host processes refuse a peer of another version. wb-hostd refuses a
wb-guestd of another version (S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs., “Version skew”).
Versioned contracts
Section titled “Versioned contracts”Each .proto package name ends in its major version
(wraithbox.<area>.v1). A change an older peer can’t read goes into a
new major package (S04-08-records-and-boundsS04-08-records-and-bounds: Records, Versions and BoundsThe records daemons send wb-hostd, the build version rules between processes, the bounds on host work a guest can cause, and logs., “Version skew”).
Decisions
Section titled “Decisions”wb is a plain executable
Section titled “wb is a plain executable”wb doesn’t hold a Keychain access group. So it is a plain
executable in Contents/MacOS, without a bundle of its own.
Development signing through Xcode
Section titled “Development signing through Xcode”- Decided: I248I248 (closed): X29-dev-signing: Keychain access group for development builds signed by a personal teamCan a developer's free personal team (an Apple ID signed in to Xcode, no paid membership) sign the helper binaries inside Wraith Box.app (wb-proxyd, wb-hostd, wb-vmd) with a keychain-access-groups entitlement and a… (B248-dev-signingB248-dev-signing: Can development builds signed by the developer's own team share Keychain items across an update?Yes, with conditions.).
Status: Draft