S06-16 - The Base Layer
Purpose: What the base layer holds, how the image build installs Apple’s Command Line Tools from a package the host fetched, and the toolchain user that named images and project layers install as.
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). (the guest’s own tools), SEC04-no-guest-secretsSEC04-no-guest-secrets: No secrets in the guestThis includes the model credential., SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable., SEC08-proj-isolationSEC08-proj-isolation: Per-project isolationEach project has its own guest user, state and history, and one project cannot persist into another., 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.
Tests: C09-guest-and-sessionsC09-guest-and-sessions: Guest and SessionsThe test cases for what a project user can reach inside the guest, wb-guestd's update and the guest clock, the shared toolchain prefix, the guest admin password, and the session lifecycle., C12-install-and-downloadsC12-install-and-downloads: Install and DownloadsThe test cases for installing and upgrading Wraith Box: wb-download, wb-release-check, the checks wb-hostd makes on what it fetches, wb setup, and the migrations of state.db and configuration.
Design
Section titled “Design”What the base holds
Section titled “What the base holds”The base layer is minimal (I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image.):
- macOS, installed from an Apple restore image (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage.);
wb-guestdandwb-guestroot;- the Xcode Command Line Tools:
clang,make,gitand the SDK headers; - the toolchain user, and its empty tool prefix (“The toolchain user”).
It doesn’t hold third-party code. Homebrew comes from the built-in
homebrew recipe (S06-17-named-imagesS06-17-named-images: Named Images and RecipesThe build of a named image from a recipe on a clone of the sealed base.), and full Xcode from a named
image’s Xcode step (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 base build has no guest egress at all. Its wb-netd is the build
VM’s, which serves only DHCP, ARP and the one connection to the
guest’s port 22 (S07-18-build-networkS07-18-build-network: Build NetworkThe build VM's network: what its wb-netd serves, the one connection to the guest's port 22, and its refusal for session VMs.). Everything the base needs from
the internet, the host fetches with wb-download.
The Command Line Tools
Section titled “The Command Line Tools”The host fetches the package files of one Command Line Tools product from Apple’s software update catalog (S17-06-command-line-toolsS17-06-command-line-tools: Command Line ToolsThe steps by which wb-download and wb-hostd fetch and check Apple's Command Line Tools for the base layer (S06-16-base-layer).). They reach the guest over the host-guest socket, never over a network.
Step 4 of the second stage (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Provisioning stages”)
installs them through the named operation install-command-line-tools:
wb-hostdsends the product’s version, then streams each package file in the product’s order from the descriptor it checked (S17-06-command-line-toolsS17-06-command-line-tools: Command Line ToolsThe steps by which wb-download and wb-hostd fetch and check Apple's Command Line Tools for the base layer (S06-16-base-layer)., “The check”). It reads withpread, hashes what it sends, and after the last byte sends the SHA-256 it computed in that check.wb-guestdwrites each one to a temporary file that only root can read or write. It keeps a file only when the SHA-256 of what it received equals the onewb-hostdsent, andwb-hostdreports that its own hash of the sent bytes matched too.- It checks every file’s signature with
pkgutil --check-signature(“Apple’s signature” below), before it installs any of them. - It installs each file with
installer -pkg <file> -target /, in the product’s order. - It checks that
xcode-select -pprints/Library/Developer/CommandLineTools, and that the installed receipt ofcom.apple.pkg.CLTools_Executableshas a version that starts with the product’s version and a dot. - It deletes the temporary files, on every path.
A file changed between the check and the send fails the build with
clt-bytes-changed, as S14-01-installS14-01-install: InstallHow the image build downloads Claude Code on the host, checks it, and installs it in the guest image, and which version a guest runs., “The checked bytes”, does for
Claude Code.
Each tool runs by its absolute path, with a fixed environment and a
deadline in code. A failure fails the build with its rule:
clt-hash-mismatch, clt-signature-invalid, clt-install-failed or
clt-not-selected. The host cuts the failure text to 1024 bytes and
escapes it, as for terminfo (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Terminfo”).
Apple’s signature
Section titled “Apple’s signature”The catalog isn’t signed, so a compromised wb-download can report
any package. Apple’s signature is what the build trusts. wb-guestd
accepts a package only when pkgutil --check-signature reports:
- the status
signed Apple Software; - a chain of exactly three certificates:
Software Update, thenApple Software Update Certification Authority, thenApple Root CA; - a root whose SHA-256 fingerprint equals the one compiled into
wb-guestd.
B150-named-imagesB150-named-images: Which VM runs a recipe, and how does a recipe build get through the proxy?A new recipe VM, `wb-vmd-recipe`, with a network of its own and the build CA installed at runtime and removed before sealing., “Evidence”, has the package this chain was read
from. The parser of pkgutil’s
output has a fuzz target. Anything else it reads is refused.
An older product that Apple signed passes this check. The floor and
the rollback check of S17-06-command-line-toolsS17-06-command-line-tools: Command Line ToolsThe steps by which wb-download and wb-hostd fetch and check Apple's Command Line Tools for the base layer (S06-16-base-layer)., “The floor”, run on
the version the catalog reported, before the download. Step 5 ties
that version to the signed package’s receipt, and state.db records
the receipt’s version.
The toolchain user
Section titled “The toolchain user”The named operation create-toolchain-user creates the toolchain user
that writes the tool prefix (I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3., 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., “Toolchain
prefix”). It runs once in each base build, and takes no input.
- The user is
_wbtool, with UID 440, and its own group_wbtool, with GID 440 and no other members. - It isn’t in
admin,wheelor any other group. - Its shell is
/usr/bin/false, its password*, and it is hidden (IsHidden). - Its home belongs to it, with mode 700.
- The prefix,
/opt/homebrew, belongs to it and its group, with mode 755, and is empty.
The operation refuses with toolchain-user-exists, and doesn’t
create anything, when the user, the group, either ID or the prefix already
exists.
UID 440 is below 500, so macOS treats the user as a system account
and doesn’t list a login for it. _wbtool is the name and UID that
X20-shared-homebrewX20-shared-homebrew: Homebrew with more than one project userCan each project user in one guest get its declared Brewfile without a Homebrew prefix that another project user can write to (SEC08-proj-isolation)? measured. The operation’s refusal covers a later
macOS that takes either.
At sealing
Section titled “At sealing”The sealing scan (S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”) accepts _wbtool
only with every property above. It refuses an image where:
_wbtoolhas a shell, a password, a secure token, or a group other than its own;- a file outside the prefix,
_wbtool’s home and its temporary folders belongs to_wbtoolor its group. The temporary folders are its own folder in/private/var/folders, and files it owns in/private/tmp, as forwbadmin(S06-02-image-buildS06-02-image-build: Image BuildHow wb image build makes a guest image: the build VM, its two provisioning stages, terminfo, sealing, and storage., “Sealing”); - a file in the prefix belongs to another user, can be written by others, or has the set-user-ID or set-group-ID bit.
So the base, and every image built on it, has one user that may write the prefix. That 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 for the toolchain: project users only read it (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., “Toolchain prefix”).
Decisions
Section titled “Decisions”No guest network in the base build
Section titled “No guest network in the base build”- Why: the base then doesn’t run third-party code or reach a host.
The host fetches what it needs through
wb-download, which is confined and audited (S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet.). - Rejected: network to Apple’s software update servers from the guest, as I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. first said. It would need a policy and a proxy for the build VM.
- Decided: I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image., maintainer’s addition of 2026-10-07.
_wbtool, UID 440
Section titled “_wbtool, UID 440”- Why: X20-shared-homebrewX20-shared-homebrew: Homebrew with more than one project userCan each project user in one guest get its declared Brewfile without a Homebrew prefix that another project user can write to (SEC08-proj-isolation)? measured Homebrew under that name and UID. A UID below 500 keeps it out of the accounts macOS lists.
- Rejected:
_wbtools, the name in I144I144 (closed): S06-vm-lifecycle: which user installs the base layer before sealingFrom the security review of PR #141 (X17-image-build, #28), finding 3.’s decision and I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image.’s triage, which no measurement used. - Decided: I150I150 (closed): S06-vm-lifecycle: minimal base image and named derived images built from recipesS06-vm-lifecycle "Images" puts Homebrew, the Xcode command line tools and wb-guestd in the base image. (B150-named-imagesB150-named-images: Which VM runs a recipe, and how does a recipe build get through the proxy?A new recipe VM, `wb-vmd-recipe`, with a network of its own and the build CA installed at runtime and removed before sealing.).
Status: Draft