S17-04 - Restore Image and Release
Purpose: The steps by which wb-download and wb-hostd fetch and check
a macOS restore image and a Claude Code release.
Design
Section titled “Design”Each step runs under the rules of S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet..
The restore image
Section titled “The restore image”The entry
Section titled “The entry”wb-hostdsends the host’s macOS version.wb-downloadfetches the catalog fromhttps://mesu.apple.com/assets/macos/com_apple_macOSIPSW/com_apple_macOSIPSW.xml, at most 4 MiB, and parses it. The catalog parser has a fuzz target.- It picks the newest restore image for
VirtualMac2,1not newer than the host’s macOS. Versions compare as numbers, part by part, and between images of one version it picks the newer build. - It sends a
HEADfor the image’s size. - It reports the version, build, URL, SHA-1 and size.
A catalog that isn’t an XML property list, or lacks its dictionaries
of versions, product types and builds, fails with
download-catalog-invalid, and one with no image to pick fails
with download-no-restore-image.
The catalog lists the builds of VirtualMac2,1 without a SHA-1
(measured on 2026-11-29). The same image, with the same URL, build and
version, is also listed under other Mac models, with its SHA-1.
wb-download takes the SHA-1 from those listings. It leaves out a
build when none of them gives its SHA-1, and refuses a catalog that gives
one image two different SHA-1s with download-catalog-invalid.
The floor
Section titled “The floor”wb-hostd refuses an entry older than the minimum compiled into
Wraith Box, with restore-image-below-minimum. The minimum is 27.0.1,
which 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? built.
state.db records the macOS version of the last image a build sealed.
wb-hostd refuses an entry older than that version with
restore-image-rollback, unless the user passed wb image build --allow-older-macos.
Resume or start over
Section titled “Resume or start over”wb-hostd keeps the entry of the partial file
<data>/images/macos-restore.ipsw.partial in state.db.
- When the new entry is the same, it answers with the partial file’s size as the offset.
- Otherwise it truncates the file and answers 0.
It opens the file with O_NOFOLLOW, and creates it mode 600. It
requires a regular file from fstat. Then it passes the descriptor.
The fetch
Section titled “The fetch”- At offset 0,
wb-downloadsends a plainGET. It requires a200with aContent-Lengthequal to the size. - At a larger offset, it sends
Range: bytes=<offset>-. It requires a206with exactlyContent-Range: bytes <offset>-<size − 1>/<size>. - At an offset equal to the size, the partial file is whole. It sends
no
GET, and the run ends withdownload-done.
wb-download refuses an offset above the size, or one other than the
size fstat gives for the partial file’s descriptor, with
download-request-invalid.
Anything else fails with download-range-refused. The
Content-Range parser has a fuzz target.
wb-download writes from the offset, and stops reading at the size. A
shorter body fails with download-short.
The check
Section titled “The check”After wb-launcher reports the exit, wb-hostd:
- checks the size with
fstaton its own descriptor; - hashes the file with SHA-1 from that descriptor;
- renames it to
macos-restore.ipsw.
A mismatch deletes the file, and fails the build with
restore-image-hash-mismatch.
Before each start of wb-vmd-install, wb-hostd checks the SHA-1
again, unless it did in the same build. A build that seals its image
deletes the restore image.
The trust base
Section titled “The trust base”The SHA-1 comes from a catalog fetched over TLS, checked against the system trust store. It binds the file to that entry.
The catalog isn’t signed, so a compromised wb-download can report
any entry. Against that, the design relies on Virtualization’s
installer, which refuses a changed restore image
(X30-installer-trustX30-installer-trust: Installer refusal of a changed restore imageDoes the Virtualization framework's macOS installer, run by wb-vmd-install, refuse a restore image that Apple didn't sign, or one with a changed or replaced component, and does the install contact Apple while wb-vmd-i…):
- For the boot components (the kernel cache, the boot loaders, the ramdisk, the device tree and the trust caches), the installer hashes each file in the image and asks Apple’s signing server for a ticket. The spike changed the kernel cache. The server declined its digest, and the digest of Apple’s kernel cache for another device too, and the install failed. A matching change to the image’s build manifest didn’t change the digest the installer sent. The spike didn’t change the other boot components, which go in the same request.
- The restore OS in the VM checks the system volume image while it copies it. One changed byte in the middle of it failed the install.
The installation service asks the signing server on every install,
over the host’s network. It is Apple’s own process, and
wb-vmd-install’s profile doesn’t confine it. wb-vmd-install itself
still has no network (S04-04-vm-processesS04-04-vm-processes: Per-VM ProcessesOne wb-vmd for each VM, the wb-vmd-layer entry of the Claude Code layer build, the wb-vmd-recipe entry of a named image's recipe, and wb-diskfmt, which formats a VM's new data disk.). These requests are the one
part of an image build that reaches the internet without wb-download
(S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet., “Only wb-download fetches”). Wraith Box neither
bounds nor audits them (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.). Each request holds
the VM’s chip identity and the components’ digests. When the server
can’t be reached, the install is assumed to fail. The spike didn’t
test that.
An older build that the signing server still signs passes both
checks, and the SHA-1 doesn’t stop it either. The server signed every
VM build that X33-restore-downgradeX33-restore-downgrade: Restore image downgradeCan a compromised wb-download install an older macOS build that Apple's signing server still signs for a VM, by reporting a newer version in its catalog entry? tried, back to macOS 13.0 from
2022. The floor and the rollback check above compare the version that
the entry reports, which comes from wb-download too.
The version that VZMacOSRestoreImage reads from the image doesn’t
close that gap. It comes from the image’s build manifest, which no
signature covers. A 27.0 image whose manifest said 27.2.1 reported
27.2.1 and installed, and its guest said 27.0 (X33-restore-downgradeX33-restore-downgrade: Restore image downgradeCan a compromised wb-download install an older macOS build that Apple's signing server still signs for a VM, by reporting a newer version in its catalog entry?).
A compromised wb-download can therefore install any build the server
still signs, and nothing in this design stops it. The gap stays
open until I658I658 (open): wb-hostd: accept only restore images whose SHA-256 is on the release's pinned list (B618 option B)Package IMG.2 of docs/implementation-plan.md, part 5 of 5 (IMG.2e). is decided.
A Claude Code release
Section titled “A Claude Code release”The version
Section titled “The version”The version is a build input that wb-hostd holds. It is never a
value from a guest or a repository. It comes from one of two places
(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., “Which release”):
- the user’s
wb image build --claude-version <version>; - without that option, Anthropic’s stable channel.
A version has one form: three decimal numbers separated by dots, of
at most 4, 4 and 6 digits, each without a leading zero, such as
2.1.311. wb-hostd, wb-download and wb-release-check all
refuse a version outside it, with the one check in
internal/releasecheck/record. Without leading zeros, two equal
versions are equal as bytes too.
For the stable channel, a run of wb-download-claude fetches only the
channel file, before the release’s run:
wb-hostdcreatesstablein<data>/downloads/as “The files” below says, and passes its descriptor.wb-downloadfetches/claude-code-releases/stable, at most 64 bytes, and parses nothing. A larger body fails withdownload-too-large.- After
wb-launcherreports the exit,wb-hostdchecks the size withfstatthe same way, and reads the file from its own descriptor. It drops one trailing line feed, and checks the rest against the version’s form. Anything else fails the build withclaude-channel-invalid. The channel reader has a fuzz target. - It refuses a version older than the floor, with
claude-release-rollback. A version from--claude-versionskips this step.
The floor is the Claude Code version in the last Claude Code layer a
build sealed, of any image. state.db records it when the layer is
sealed. A parent doesn’t change it.
- No record means no floor, as on a new host.
- When
state.dbcan’t be read, the build is refused withclaude-release-floor-unknown. It never runs without a floor it can’t read.
Versions compare as three numbers, part by part.
The files
Section titled “The files”At the build’s start, wb-hostd deletes what an earlier build left in
<data>/downloads/, without following symbolic links.
It creates manifest.json, manifest.json.sig and claude there,
with O_CREAT|O_EXCL|O_NOFOLLOW and mode 600. It passes the three
descriptors.
The fetch
Section titled “The fetch”wb-download fetches:
| File | At most |
|---|---|
<version>/manifest.json |
1 MiB |
<version>/manifest.json.sig |
64 KiB |
<version>/darwin-arm64/claude |
1 GiB |
wb-download parses none of the files. A larger file fails with
download-too-large. After the exit, wb-hostd checks each size with
fstat, and refuses the same way.
Exit before check
Section titled “Exit before check”wb-hostd gives the files to wb-release-check only after
wb-launcher reports that wb-download exited. So nothing writes
them after the check. The build deletes them when it ends.
Status: Draft