Skip to content

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.

Each step runs under the rules of S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet..

  1. wb-hostd sends the host’s macOS version.
  2. wb-download fetches the catalog from https://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.
  3. It picks the newest restore image for VirtualMac2,1 not newer than the host’s macOS. Versions compare as numbers, part by part, and between images of one version it picks the newer build.
  4. It sends a HEAD for the image’s size.
  5. 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.

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.

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.

  • At offset 0, wb-download sends a plain GET. It requires a 200 with a Content-Length equal to the size.
  • At a larger offset, it sends Range: bytes=<offset>-. It requires a 206 with exactly Content-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 with download-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.

After wb-launcher reports the exit, wb-hostd:

  1. checks the size with fstat on its own descriptor;
  2. hashes the file with SHA-1 from that descriptor;
  3. 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 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.

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:

  1. wb-hostd creates stable in <data>/downloads/ as “The files” below says, and passes its descriptor.
  2. wb-download fetches /claude-code-releases/stable, at most 64 bytes, and parses nothing. A larger body fails with download-too-large.
  3. After wb-launcher reports the exit, wb-hostd checks the size with fstat the 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 with claude-channel-invalid. The channel reader has a fuzz target.
  4. It refuses a version older than the floor, with claude-release-rollback. A version from --claude-version skips 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.db can’t be read, the build is refused with claude-release-floor-unknown. It never runs without a floor it can’t read.

Versions compare as three numbers, part by part.

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.

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.

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