S17-03 - Downloads
Purpose: How wb-download fetches what an image build needs from
the internet. Apple’s installation service, which asks Apple’s signing
server, is the one exception (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…).
Design
Section titled “Design”Only wb-download fetches what an image build needs. wb-hostd has
no network, and wb-proxyd serves guests. On macOS, Apple’s
installation service also asks Apple’s signing server for a ticket
during each install, over the host’s network. Wraith Box neither bounds
nor audits those requests (S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release., “The trust
base”).
Entries
Section titled “Entries”wb-download is Go. Each download is one run, started through
wb-launcher from one of three fixed entries. Each entry has:
- an instance cap of one;
- its hosts, compiled into the program;
- a file size limit (
RLIMIT_FSIZE), soft and hard, thatwb-downloadsets on itself first thing, before it reads anything. A process without privileges can’t raise its hard limit again, so nothing later in the run undoes it.
| Entry | Hosts | Fetches | File size limit |
|---|---|---|---|
wb-download-restore |
mesu.apple.com, updates.cdn-apple.com |
Apple’s restore image catalog and one restore image | 40 GiB |
wb-download-claude |
downloads.claude.ai |
the stable channel file, or one Claude Code release (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.) | 1 GiB |
wb-download-clt |
swscan.apple.com, swdist.apple.com, swcdn.apple.com |
Apple’s software update catalog and the distribution files of its Command Line Tools, or the packages of one product | 2 GiB |
S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release. has the steps of the first two entries, and
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). those of wb-download-clt.
Start interface
Section titled “Start interface”wb-download takes no argument. Its entry’s fixed environment names
the entry in WB_DOWNLOAD_ENTRY, restore, claude or clt. It never comes
from wb-hostd. Its descriptors are:
| Descriptor | Use |
|---|---|
| 2 | the log pipe |
| 3 | the request pipe, open for reading |
| 4 | the result pipe, open for writing |
| 5 on | the output files, regular files open for writing: one for restore, one for a channel run of claude, or three for a release, in the order manifest.json, manifest.json.sig, claude; none for a catalog run of clt, or one for each package of a package run, in the product’s order |
No descriptor above the outputs is open. wb-download starts in this
order, and refuses with the rule named:
- an argument, with
download-arguments, or an entry other than the three, withdownload-entry-unknown; - it sets the file size limit, or fails with
download-file-limit; - it works out
BUNDLEfrom the real path of its program, which must be<bundle>.app/Contents/MacOS/wb-download, or fails withdownload-bundle-unknown; - it confines itself;
- a descriptor missing, of the wrong kind or access mode, or open
beyond the outputs, with
download-descriptor-invalid. So does a count of outputs that doesn’t fit the entry, or aclauderun whose kind doesn’t fit the count. The log must be a pipe open for writing. Aclaudeorcltoutput must be empty, sincewb-downloadwrites it from the start. One that holds bytes ends the run, when its request arrives, with the same rule.
A refusal of the start is logged with its rule, and wb-download
exits 1 without writing a record.
The records
Section titled “The records”Each record on either pipe is a 4-byte big-endian length and then a
message of wraithbox.download.v1 (proto/wraithbox/download/v1), of 1
to 4096 bytes. The first record each way is the version record of
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., “Between host processes”. After a version
refused, wb-download writes nothing more and exits 1.
wb-hostd sends the requests of S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release.: the host’s
macOS version and then the offset for restore, or for claude one
request naming a channel run or a release and its version. For clt
it sends the guest’s macOS version, or the product to fetch
(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).).
wb-download sends the results: the restore image’s entry, a report
for each request, and last an end record with the run’s rule,
download-done after a run that succeeded. A request outside its form
ends the run with download-record-form. A request the step doesn’t
expect, such as a second one, ends it with download-request-invalid.
On Windows and Linux, wb-download confines itself with that
platform’s mechanism (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.), with the same rules in its code.
Confinement
Section titled “Confinement”wb-download confines itself first thing, from a compiled-in profile.
The profile is the network part of the wb-proxyd profile that
X23-sandboxed-daemonsX23-sandboxed-daemons: Self-sandboxed Go daemons on macOSCan wb-netd, wb-proxyd and wb-hostd confine themselves at start with a sandbox profile, as S04-architecture says, while the Go runtime, inherited descriptors, and Keychain and Secure Enclave access in wb-proxyd keep w… measured for I61I61 (closed): X23-sandboxed-daemons: wb-proxyd profile with Keychain and Secure EnclaveSplit from #34 (X23-sandboxed-daemons) during triage on 2026-10-04.. It is limited to port 443, and
leaves out the secret store services:
(version 1)(deny default)(allow network-outbound (remote tcp "*:443"))(allow network-outbound (remote udp "*:53"))(allow network-outbound (literal "/private/var/run/mDNSResponder"))(allow file-read-metadata (literal "/etc") (literal "/var"))(allow file-read* (literal "/private/etc/resolv.conf") (literal "/private/var/run/resolv.conf") (literal "/private/etc/hosts"))(allow mach-lookup (global-name "com.apple.trustd.agent"))(allow file-read-metadata (literal (param "BUNDLE")))(allow sysctl-read (sysctl-name-prefix "net.routetable"))BUNDLEis the real path ofWraith Box.app, the bundle whose program it is.wb-downloadworks it out before it confines itself.- The last line is for
getifaddrs, which reads the interface list from the routing table throughsysctl. The self-check test of 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. measured it on macOS 27.2: without the line,getifaddrsfails withEPERM, and the name it reads isnet.routetable.0.0.3.0. - The profile is enough for the TLS check through
trustdonly when the program is inside its bundle. Run from a bare path, the Security framework reads the metadata of the directory that holds the program, which the profile denies, and the handshake fails. The tests run a copy of the test binary from a bundle for that reason.
Files, the secret store and starting programs are denied.
wb-download can still use its inherited descriptors.
Seatbelt can’t name hosts. The code checks them instead, and refuses:
- a host outside its entry, or a URL that isn’t HTTPS on port 443,
with
download-host-refused; - every redirect, with
download-redirect-refused; - an address under the rule of S07-07-hosts-and-modesS07-07-hosts-and-modes: Hosts and ModesHow wb-proxyd binds a stream to its name, which upstream addresses it refuses, and the inspect, pass and audit modes., “Upstream address”, with
upstream-address-refused.
That rule lists the host’s interfaces with getifaddrs. A failure to
list them refuses the connection with upstream-address-refused as
well. Every connection goes through the upstream dialer of
wb-proxyd, which resolves the host and checks each address, so a
failed lookup or connect ends the run with its rule,
upstream-resolve-failed or upstream-connect-failed.
TLS is checked against the system roots, and a failed handshake ends
the run with download-tls-failed. The HTTP client’s
Transport.Proxy is nil, so HTTPS_PROXY and the system’s proxy
settings don’t apply.
Deadlines
Section titled “Deadlines”| Limit | Time | Rule |
|---|---|---|
| A connection that isn’t up | 30 s | download-connect-timeout |
| A response with no byte | 60 s | download-idle-timeout |
A whole request for a catalog, a distribution file, a HEAD, the channel file, the manifest or the signature |
2 minutes | download-deadline |
| A whole request for the Claude Code binary or a Command Line Tools package | 30 minutes | download-deadline |
| A whole request for the restore image | 12 hours | download-deadline |
wb-hostd cancels a run by closing its request pipe. wb-download
stops at that end of file with download-cancelled.
The result record
Section titled “The result record”wb-download writes fixed-format records to its pipe. wb-hostd
checks the form of each field:
| Field | Form |
|---|---|
| macOS version | ^[0-9]{1,3}(\.[0-9]{1,3}){1,2}$ |
| macOS build | ^[0-9]{2}[A-Z][0-9]{1,5}[a-z]?$ |
| product, package | ^[0-9]{3}-[0-9]{5}$, and a package name of 1 to 64 characters of A-Z a-z 0-9 _ ending in .pkg |
| URL | https://updates.cdn-apple.com/ and a path of 1 to 512 characters of A-Z a-z 0-9 . _ / - ending in .ipsw, or https://swcdn.apple.com/ and a path like it ending in .pkg, with no empty segment, no . or .. segment, and no port, user, query or fragment |
| SHA-1, digest | 40 lowercase hexadecimal digits |
| size | a decimal number from 1 to 42,949,672,960 (40 GiB), and for clt from 1 to 2,147,483,648 (2 GiB) |
| host, rule, status, bytes | one of the entry’s hosts, a rule name of this page or S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release., a three-digit status, a decimal count |
| path | a catalog’s path, a distribution file’s path of swdist.apple.com with the product ID in it, the path of a URL above, /claude-code-releases/stable, or /claude-code-releases/<version>/ followed by manifest.json, manifest.json.sig or darwin-arm64/claude, with the version’s form of S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release. |
| address | an IPv4 address in dotted decimal, or an IPv6 address in the form Go’s netip.Addr.String writes, without a zone |
A field outside its form ends the run with download-record-form. So
does a run that reports more than 16 requests. The record parser has a
fuzz target.
For each request, and each refusal of one, wb-download reports:
- the method, the host and the path;
- the address it connected to;
- the status, or the rule;
- the bytes it wrote.
A request refused before a connection, because its URL was outside the entry, is reported with its rule and no host, path, address or status: none of them would fit the forms above. A refusal of an address reports the address. A report that would still fall outside its form is sent as the method, host, path and rule alone, so remote input never drops one.
wb-hostd writes each as an HTTP Activity (4002) record, and a
refusal as a refused one with its rule (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.). These records
belong to no VM. They don’t count against any VM’s audit budget
(S09-11-auditS09-11-audit: AuditWhat the audit log records, the budgets that bound it, and what happens when the log can't be written.), and they’re never dropped.
When one can’t be written, wb-hostd cancels the run with
download-audit-failed. The rule of S09-11-auditS09-11-audit: AuditWhat the audit log records, the budgets that bound it, and what happens when the log can't be written. for a record that
can’t be written applies.
Before it starts any entry, wb-hostd checks the free space on
the volume of <data>. It refuses with download-no-space when that
is less than:
- the entry’s file size limit, less what the partial restore image already holds;
- plus
audit_free_space_floor(S09-11-auditS09-11-audit: AuditWhat the audit log records, the budgets that bound it, and what happens when the log can't be written.).
For a Claude Code release, the limit counts once for each of its three
files, and once for the channel file of its own run. For a package
run of clt, the sizes of its packages count instead of the limit.
The check uses only numbers the host knows before the run. The file
size limit holds what a run writes to them.
Failures
Section titled “Failures”Any exit other than success fails the build with its rule.
wb-download isn’t restarted. The next wb image build resumes the restore
image.
Besides the rules above and those of S17-04-restore-and-releaseS17-04-restore-and-release: Restore Image and ReleaseThe steps by which wb-download and wb-hostd fetch and check a macOS restore image and a Claude Code release., a run ends with:
| Rule | When |
|---|---|
download-result-write-failed |
a record couldn’t be written to the result pipe |
download-response-invalid |
the connection ended before a whole response header, the header couldn’t be parsed, or its status is outside 100 to 599 |
download-status-refused |
a status other than the one the request wants |
download-size-invalid |
the HEAD’s Content-Length is missing or outside the size’s form |
download-write-failed |
a write to an output failed, such as past the file size limit |
Decisions
Section titled “Decisions”Only wb-download fetches
Section titled “Only wb-download fetches”What an image build needs from the internet is fetched by one
confined program, wb-download, not by wb-hostd or wb-proxyd.
- Decided: I49I49 (closed): S10-tech-stack: installation, restore image download, upgrades and migrationsS10-tech-stack "Packaging and signing" gives the shape of the macOS app bundle..
- Amended: 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…. Apple’s installation service, which
wb-vmd-install’s profile doesn’t confine, sends the TSS requests for an install’s ticket to Apple’s signing server itself, over the host’s network. The installer refuses a changed restore image only through those requests, so they stay, outsidewb-download, and Wraith Box neither bounds nor audits them. Everything else an image build fetches still goes throughwb-download.
Status: Draft