S07-07 - Hosts and Modes
Purpose: How wb-proxyd binds a stream to its name, which upstream
addresses it refuses, and the inspect, pass and audit modes.
Design
Section titled “Design”Name binding
Section titled “Name binding”The hostname of a stream is the name wb-proxyd’s copy holds for the
synthetic address (S07-06-name-mappingS07-06-name-mapping: Name MappingHow wb-proxyd keeps its own checked copy of the names wb-netd gave synthetic addresses: name reports, releases, replay, lifetime, the second count of the wildcard budget, and the copy wb-hostd keeps.).
- For TLS, the ClientHello SNI must equal that hostname, or the stream
is reset with the rule
tls-sni-mismatch. The SNI is folded to lower case and must be in the name form of S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget.. A ClientHello without an SNI, or with an SNI that ends in a dot or is an IP address, is reset with the same rule. Aserver_nameextension that doesn’t hold exactly one host name fails the ClientHello parser, and the first-byte check resets the stream (S07-15-non-http-streamsS07-15-non-http-streams: Non-HTTP StreamsHow wb-proxyd checks the protocol of each stream, and what it does with SSH, other protocols and raw TCP., “First bytes”). - For inspected plain HTTP, the
Hostheader must equal that hostname (S07-03-dnsS07-03-dns: DNSHow wb-netd answers the guest's DNS queries: synthetic addresses, the name form, negative answers and the wildcard budget., “Synthetic pool”).
wb-proxyd resolves the real upstream address itself.
Upstream address
Section titled “Upstream address”This rule serves SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.. It applies to each connection
wb-proxyd opens:
- upstream streams in every mode: inspect, pass and raw TCP;
- its own fetches, such as following a Go module proxy redirect, the
ghcr.iotoken fallback and OSV lookups.
wb-proxyd refuses the connection when any address the name resolves
to is in one of these ranges:
-
IPv4:
- unspecified and “this network” (0.0.0.0/8);
- loopback (127.0.0.0/8);
- RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16);
- CGNAT (100.64.0.0/10);
- link-local (169.254.0.0/16);
- IETF protocol assignments (192.0.0.0/24);
- multicast (224.0.0.0/4);
- reserved (240.0.0.0/4, broadcast included);
- the synthetic range (198.18.0.0/15).
-
IPv6: unspecified (
::), loopback (::1), link-local (fe80::/10), the deprecated site-local range (fec0::/10, RFC 3879), unique local (fc00::/7) and multicast (ff00::/8). -
An IPv4 address embedded in IPv6:
- IPv4-mapped (
::ffff:0:0/96) and IPv4-compatible (::/96) addresses; - the well-known NAT64 prefix (
64:ff9b::/96); - the local-use NAT64 prefix (
64:ff9b:1::/48), refused whole. Where it carries the IPv4 address depends on how the network splits it, whichwb-proxydcan’t know; - 6to4 (
2002::/16) and Teredo (2001::/32). The whole 6to4 and Teredo prefixes are refused, whatever address they embed.
- IPv4-mapped (
-
The host’s own networks, at connect time:
- any address assigned to a network interface of the host;
- any address in the on-link prefix of one of the host’s interfaces.
This covers the host’s own public addresses, and a LAN that uses global IPv6 addresses.
wb-proxyd connects only to an address it checked. It never resolves
the name again between the check and the connect.
A refused connection is logged with the host, the address, and the
rule upstream-address-refused (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.). A lookup that fails,
or returns an empty answer, is refused with upstream-resolve-failed. When none
of the checked addresses connects, the rule is
upstream-connect-failed. Both are logged with the host, and the
second with the last address tried.
- On an inspected stream the guest gets a
502that names the rule. - A pass or raw TCP stream is reset (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).
So a name whose zone someone else controls can’t point a relay at the host itself, at a private or link-local network, or at a network on the host’s own links.
A network on public addresses that the host reaches through another route, such as a VPN, isn’t in these ranges. It is still reachable by name (T01-allowed-channelsT01-allowed-channels: Data through allowed channelsData sent through allowed operations to allowed destinations, for example a push to an allowed repository that is public, or prompt content sent to the model provider.). Wraith Box has no LAN opt-in in V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there..
Modes, per host
Section titled “Modes, per host”- Plain HTTP is allowed only when policy names
host:80. It is always inspected. - A stream that isn’t TLS or HTTP is reset, unless policy names its host and port for raw TCP (S07-15-non-http-streamsS07-15-non-http-streams: Non-HTTP StreamsHow wb-proxyd checks the protocol of each stream, and what it does with SSH, other protocols and raw TCP.).
A TLS host has one of three modes.
inspect
Section titled “inspect”inspect is the default.
wb-proxydterminates TLS with a leaf certificate from the Wraith Box CA (S09-policy-credentials-auditS09-policy-credentials-audit: Policy, Credentials, Certificates and AuditWhere policy comes from, how secrets are held, how TLS inspection is trusted, and what is recorded.). It doesn’t issue session tickets, so no stream resumes a session whose leaf came from a CA that a rotation has since replaced.- It applies HTTP policy and credential replacement.
- It opens a new TLS connection upstream, validated against the host’s system trust store, at the stream’s first request that passes its checks. It doesn’t present a client certificate.
It speaks HTTP/1.1, and HTTP/2 once I499I499 (open): wb-proxyd: HTTP/2 on inspected TLS streams, with the same request form, caps and steps as HTTP/1.1Package M3.6 of docs/implementation-plan.md, part 3 of 4 (M3.6c). adds it to both sides.
An upstream certificate that fails validation refuses the request
with the rule upstream-tls-verify. Any other upstream handshake
failure, such as no common TLS version, refuses it with
upstream-tls-failed. A server that asks for a client certificate
and then fails the handshake, or sends a certificate alert before its
first byte, gives tls-client-cert-unsupported
(S07-16-tls-and-tunnelsS07-16-tls-and-tunnels: TLS and TunnelsWhat wb-proxyd does with client certificates, encrypted ClientHello and tunnels, and which refusals no mode or approval relaxes.). After such a request, a timeout, or an end
with no alert before the first byte, is upstream-tls-failed. Each
one answers the guest’s request with a 502 that names the rule.
pass relays TLS bytes unchanged to the named host. It is only for
hosts where inspection breaks the client.
The proxy can’t see what is sent. So every pass host is a residual channel (T01-allowed-channelsT01-allowed-channels: Data through allowed channelsData sent through allowed operations to allowed destinations, for example a push to an allowed repository that is public, or prompt content sent to the model provider.).
The rules for pass:
- Still one named host. Pass isn’t an exception to SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.. The name must be allowed, and the SNI must equal it (“Name binding”). A pass entry names one exact host. A wildcard pass entry is refused at load.
- Only the user sets it. A host is put in pass mode only in the global policy, or in a project’s network policy on the host (S09-policy-credentials-auditS09-policy-credentials-audit: Policy, Credentials, Certificates and AuditWhere policy comes from, how secrets are held, how TLS inspection is trusted, and what is recorded.). Repository-supplied configuration can never switch a host to pass (SEC09-host-policySEC09-host-policy: Policy is held on the hostThe guest cannot read or change policy.). An approval or learn mode never does either (S07-17-approvals-and-learningS07-17-approvals-and-learning: Approvals and LearningHow an unknown destination reaches the user as an approval request, what an approval grants, and how learn mode collects names.).
- A reason for each. Each pass entry holds a reason the user writes.
An entry without one is refused at load.
wb policy explainlists every pass host with its file and its reason. - Never on a guarded host. A guarded host can’t be a pass host (“Guarded hosts”).
- Audited. Each policy change that adds a pass host is a Device Config State Change (5019) event, with the host, the file and the reason (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.).
Known to break under inspection
Section titled “Known to break under inspection”None of the clients X04-tls-inspectionX04-tls-inspection: Inspection compatibilityGo-based, Swift-based, and Xcode clients accept a CA that only the guest trusts. could test pins a certificate.
The guest’s trustd pinning rules pin Apple hosts a development guest may use. So these are expected to refuse an inspected leaf (inferred from the rules, not seen):
- software update and the command line tools:
swscan.apple.com,swcdn.apple.com,swdist.apple.com,swdownload.apple.com; xcode-cdn.apple.com,mesu.apple.com,updates.cdn-apple.com;gdmf.apple.com,gs.apple.com,gsa.apple.comandidmsa.apple.com.
Wraith Box never puts these hosts in pass mode itself, and the rules
above apply to them. A user who does makes each one a
T01-allowed-channelsT01-allowed-channels: Data through allowed channelsData sent through allowed operations to allowed destinations, for example a push to an allowed repository that is public, or prompt content sent to the model provider. channel. The Apple Account hosts
(idmsa.apple.com, gsa.apple.com) then carry whatever Apple
credentials the guest holds. Wraith Box neither gave nor removes them
(T10-unnamed-credentialsT10-unnamed-credentials: Guest credentials in unnamed placeswb-proxyd removes Authorization, Proxy-Authorization and Cookie on every inspected host.).
On a macOS guest, clients that read only the system trust store, such as URLSession, also reject inspection. That is a known gap of FR08-no-proxy-configFR08-no-proxy-config: No per-tool proxy settingsAllowlisted network destinations work for every tool without per-tool proxy configuration., which S09-08-guest-trustS09-08-guest-trust: Guest TrustHow wb-guestd makes the guest's clients trust the VM's CAs. lists.
audit inspects, with the HTTP policy of the host and port logging a
violation and letting the request through (S07-11-http-policyS07-11-http-policy: HTTP PolicyThe HTTP rules of inspected hosts, the built-in profiles, and the parts a user can turn off.).
- The mode is per host and port, resolved over the whole union.
enforcewins when any source has anenforceendpoint on that host and port (S09-02-precedenceS09-02-precedence: PrecedenceHow the policy sources merge, how the mode of each host and port resolves, and how the merge works for a VM with more than one project., “Mode per host and port”).- The boundary check sees an
audithost and port as every method and path on it (S09-01-policy-filesS09-01-policy-files: Policy FilesWhere policy is written, the network policy schema Wraith Box accepts, how the prover sees it, and narrowing by program and project., “Audit as the whole host”).
The rules for audit:
- Only the user sets it. Only the global policy and a project’s
network policy can put a host and port in
audit. Repository configuration and approvals can’t (S09-03-project-settingsS09-03-project-settings: Project SettingsWhat a project's settings hold, and what a repository's own .wraithbox/ configuration may add., “Repository-supplied configuration”, and S09-09-approvalsS09-09-approvals: ApprovalsWhat an approval adds, the checks that each request goes through, and approvals for a joining project., “Approved rule”). - Never on a guarded host. A guarded host can’t be in
audit(“Guarded hosts”).
Guarded hosts
Section titled “Guarded hosts”A host is guarded when it has a credential binding, or a built-in profile covers it. A profile covers a host when:
- any host of a built-in profile (git hosting, model API, package registries) matches it;
- or the remotes of a project’s host repository name it, which gives it the git hosting profile (S07-08-requests-and-credentialsS07-08-requests-and-credentials: Requests and CredentialsThe form of each request wb-proxyd sends upstream, and how it removes the guest's credentials and injects bound ones., “Named places”).
Neither pass nor audit is allowed on a guarded host:
- Pass would switch off credential replacement, HTTP policy and the dependency gate on it, and with them SEC06-repo-writesSEC06-repo-writes: Repository-scoped writesGit pushes and repository-mutating API calls are allowed only for the repositories of the projects that have a session in the VM. and SEC07-dep-gateSEC07-dep-gate: Dependency gatePackage downloads (npm, PyPI, Go modules, crates) are refused when the version is younger than a minimum age or has a known vulnerability at or above a severity threshold..
- With policy not enforced in
audit, a write the git hosting profile refuses would pass with a credential injected, against SEC06-repo-writesSEC06-repo-writes: Repository-scoped writesGit pushes and repository-mutating API calls are allowed only for the repositories of the projects that have a session in the VM..
The rule is checked at three points. Each error names what it says below (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).
- At load. A pass entry or an
auditendpoint on a guarded host, in the global policy or a project’s policy, is refused at load. The error names the host and the reason. - At every recompute.
wb-hostdchecks the same rule over the union, whatever source set the mode, global entries included. So a global entry that loaded while no project named its host refuses the session start of a project whose remote names it. The error names that project, the host, and the file of the pass entry orauditendpoint. - A binding added later. A change that adds a credential binding on
a pass host, or on a host with an
auditendpoint, is refused. That holds in a policy file and withwb cred set. The pass entry orauditendpoint stays. The error names it and its file, and says to remove it first.
Decisions
Section titled “Decisions”Rules for pass
Section titled “Rules for pass”Pass names one exact host, only the user sets it, each entry has a reason, it is never on a guarded host, and each new pass host is audited.
- Why: the proxy can’t see what a pass host is sent, so each one is a residual channel (T01-allowed-channelsT01-allowed-channels: Data through allowed channelsData sent through allowed operations to allowed destinations, for example a push to an allowed repository that is public, or prompt content sent to the model provider.).
- Decided: I40I40 (closed): S03-requirements, S07-egress-gateway: record learn mode and pass mode as SEC05-default-deny exceptionsSEC05-default-deny is "default-deny egress", and AGENTS.md says an S control is never weakened. (B40-learn-pass-modesB40-learn-pass-modes: May learn mode and pass mode open holes in default-deny egress?Learn mode should collect unknown names and refuse them, so SEC05-default-deny is unchanged.).
Rules for audit
Section titled “Rules for audit”Only the user sets audit, and never on a guarded host.
- Why: with policy not enforced, a write the git hosting profile refuses would pass with a credential injected.
- Decided: I109I109 (closed): S09-policy-credentials-audit: audit mode can never pass the boundary checkS09-policy-credentials-audit says the prover answers unsupported for an endpoint in audit mode, and the boundary check refuses on unsupported..
Status: Draft