Skip to content

S07-04 - DNS Refusals

Purpose: How wb-netd refuses a name: approval events, the hold before each refusal, quiet refusals, and the answer that is the same for every reason.

The answers of wb-netd to allowed names, and the name form, are on 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..

Names not on the allowlist get NXDOMAIN and raise an approval event (FR09-approve-unknownFR09-approve-unknown: Approve unknown destinationsA request to an unknown destination is blocked and offered to the user for approval out-of-band (allow once, allow for project, deny).). During a learn period in the VM they go on the learn list instead (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.).

The answer is held first (“Hold”). So a user who approves in time sees the lookup succeed.

A VM has at most one open approval event per name. Later queries for that name, from any session in the VM, are counted on it. The host can’t tell which session looked a name up (S07-01-per-vm-policyS07-01-per-vm-policy: Enforced per VMWhy the VM is the unit the gateway enforces, how the policies of its projects combine, and what happens when they conflict or change.).

Over the VM’s limits on pending requests and on new requests, a name is refused the same way, with the rule approval-pending-cap or approval-rate. It doesn’t raise an approval event (S09-10-approval-flowS09-10-approval-flow: Approval FlowHow an approval request for a name behaves, from the lookup that raises it to its answer or its expiry.).

wb-netd sends the answer to a refused query 4 seconds after the query arrived, not before. That holds whatever the reason in the list under “Same answer for every refusal”. A query over the query rate isn’t refused this way: it is dropped at once (“Over the rate”).

Every step that depends on the reason runs when the query arrives:

The end of the hold is a timer that only sends those bytes.

A change that widens the VM’s effective policy, such as an approval, runs each held query through every DNS check again (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. and this page). It runs them as if they had just arrived, the audit budgets and the event channel included.

The re-run reads policy and host state: the allowlist, denies, the budgets, and the event channel.

  • Each re-run query counts against the query rate limit. A burst of re-runs over the limit is refused with dns-query-rate, and those queries keep their refusal bytes and their timers. They are held already, so this adds nothing to the held-query table, unlike a new query over the rate (“Over the rate”).
  • A debit already made for the query isn’t made again.
  • The re-run doesn’t add to an open event’s lookup count, doesn’t raise a request, and doesn’t add a learn list entry.
  • An allowed result is sent at once. Its accounting record and name report go first, as for every allowed answer.
  • A refusal keeps its refusal bytes and its timer. So a refusal always arrives 4 seconds after its query.
  • A name approved while the VM is over its audit budget is still refused.

A deny, or no answer within the 4 seconds, gets the refusal at the end of the hold.

Each VM’s wb-netd holds at most 1,024 queries at once by default. That is a per-VM cap that is configuration like the others (S07-02-packet-pathS07-02-packet-path: Packet PathHow wb-netd carries the guest's frames: the packet transport, the stack, the link filter, its caps, addressing, the MTU and connections., “Per-VM caps”), with a minimum of one more than the queries the rate lets through in one hold (“Over the rate”). Every query of a name counts on its own. A held query costs a few hundred bytes, so the default table takes well under a megabyte per VM.

A refused query over the cap is dropped without an answer.

Over UDP the guest’s resolver sends it again after its own timeout. Over TCP wb-netd closes the DNS-over-TCP connection that sent it, so the client doesn’t wait on an open connection.

A query over the VM’s query rate (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., “Wildcard budget”) is dropped at once without an answer, and isn’t held.

So a flood over the rate holds at most the burst and the rate for one hold, under the cap’s minimum, and leaves room for names that raise an approval event (T11-shared-vm-grantsT11-shared-vm-grants: Projects in one VM share network grantsThe host sees one guest address per VM, and can't tell which project user, session or program opened a connection.). Over UDP the guest’s resolver sends it again after its own timeout. For TCP, see “TCP”.

wb-netd keeps a DNS-over-TCP connection open while it has a held query. It counts the connection in the per-VM cap on DNS-over-TCP connections until its last held answer is sent.

An over-cap query closes the connection anyway. The connection’s held queries leave the table at the close, and their timers don’t fire. A query over the rate is dropped, and closes the connection only when it has no held query, so a rate drop never evicts a held query.

A deny holds for the VM until every session that was running when the user denied has ended. Until then:

  • the name gets NXDOMAIN without a new approval event;
  • later queries are counted on the closed event.

After that, a lookup raises a new event.

An approval event records the sessions running in the VM when it was raised. It has a request id (S09-10-approval-flowS09-10-approval-flow: Approval FlowHow an approval request for a name behaves, from the lookup that raises it to its answer or its expiry.).

If that set has changed when the user answers, the answer is refused with the rule approval-sessions-changed. The request closes. A new request, with a new id and the current sessions, replaces it.

The guest OS resolves names of its own, with no user action. An idle guest at the login window looked up 14 host names, 109 queries in all, in its first hour (X03-network-pathX03-network-path: Network pathA macOS guest boots on the file-handle attachment with the gVisor stack: gets a DHCP lease, resolves only allowlisted names, reaches only the proxy.).

Names on the guest OS’s background list get NXDOMAIN, and an audit entry with the rule guest-os-background. They don’t raise an approval event.

The list is host-held:

  • It ships with Wraith Box for each guest OS release.
  • wb-hostd picks the list from the image it booted, never from anything the guest reports.
  • Nothing the guest sends adds a name to it.

The list holds exact names, such as init.push.apple.com, never suffixes or wildcards. So a lookup of developer.apple.com still raises an approval event.

  • A query matches when its name equals a listed name, compared case-insensitively, after one trailing dot is removed.
  • A name on the list that is also allowed by policy is answered as allowed.
  • wb status shows the list, and the count of refusals per name.

The image turns off the services that send these lookups where it can (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?). So the list holds what remains.

A host can have all its built-in rules in profile parts that are off (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., “Profile parts”). It gets NXDOMAIN and an audit entry with the rule profile-part-off, whatever other rule allows it. It doesn’t raise an approval event. So an approval can’t undo the user’s switch.

The answer’s bytes are the same whatever the reason a name is refused, and so is the time of sending (“Hold”). The reasons are:

Each of them can be held. A held query costs only an entry in the held-query table, whose cap drops what doesn’t fit (“Hold limits”). A new query over the query rate is dropped, not refused with this answer (“Over the rate”).

The last three come from the host’s own state, not from the name (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., “Accounting and event channels”, 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.). They don’t raise an approval event or debit the wildcard budget.

When the query arrives, wb-netd:

  1. checks the query rate (dns-query-rate) before anything else that can debit, and drops a query over it (“Over the rate”);
  2. debits the wildcard budget;
  3. writes the debit’s accounting record to wb-hostd;
  4. takes the one-open-event-per-name check and the checks of the request limits (S09-10-approval-flowS09-10-approval-flow: Approval FlowHow an approval request for a name behaves, from the lookup that raises it to its answer or its expiry.) under one lock.

It does no other work that depends on the reason.

The whole order, with the local answers, the name form and the host state, is in 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., “Order of checks”. Which lookups debit is in 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., “Wildcard budget”.

When the write fails, the name is refused with the rule accounting-write-failed (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., “Accounting and event channels”). An answered name’s accounting record, with its address, is written before its answer too. A failed write refuses the name the same way.

The emission of the approval event and the notification start with the hold, so the user can answer while the query waits. They, the entry on a learn list and the audit entry run apart from the answer. Nothing they do changes when the answer is sent (“Hold”).

One open approval event per name per VM, with queries from every session counted on it.

I51I51 (closed): S09-policy-credentials-audit: approval flow, what the blocked client sees, and approval noiseS07-egress-gateway and S09-policy-credentials-audit describe approval choices and their security (SEC14-no-fake-approvals), not how the flow behaves. decided to hold the answer for up to 4 seconds while a request is open. The hold applies to every reason, not only to names with an open request.

A query over the query rate is dropped without a hold, as an exception to “Hold every refusal for 4 seconds”.

Names the guest OS looks up by itself are refused without an approval event, as an exception to FR09-approve-unknownFR09-approve-unknown: Approve unknown destinationsA request to an unknown destination is blocked and offered to the user for approval out-of-band (allow once, allow for project, deny)..

Status: Draft