Skip to content

S10-02 - Packaging and Signing

Purpose: How Wraith Box is packaged and signed on each host, and the one version every build stamps.

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 onto PATH.

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.

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, wb included, 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.

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:

  1. It builds the app’s Xcode project with xcodebuild, automatic signing and that team.
  2. It copies the profile Xcode embeds into each helper bundle.
  3. 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:

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.

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.).

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 build invocation, 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”).

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”).

wb doesn’t hold a Keychain access group. So it is a plain executable in Contents/MacOS, without a bundle of its own.

Status: Draft