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.
Design
Section titled “Design”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
Section titled “Names not on the allowlist”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 DNS checks 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. and this page, in their order;
- the wildcard budget debit, with its accounting record;
- the one-open-event-per-name check;
- the request limits;
- building the answer’s bytes.
The end of the hold is a timer that only sends those bytes.
Widening during the hold
Section titled “Widening during the hold”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.
What the re-run changes
Section titled “What the re-run changes”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.
Result of the re-run
Section titled “Result of the re-run”- 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.
Deny or no answer
Section titled “Deny or no answer”A deny, or no answer within the 4 seconds, gets the refusal at the end of the hold.
Hold limits
Section titled “Hold limits”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.
Over the cap
Section titled “Over the cap”A refused query over the cap is dropped without an answer.
- Its wildcard budget debit and accounting record are made first, as for every refused query. Accounting records come before any drop decision (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”).
- It doesn’t raise or join an approval event, and doesn’t go on a learn list.
- It is counted with the rule
dns-hold-full, in runs per rule (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., “Events and rate limits”).
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.
Over the rate
Section titled “Over the rate”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.
- It is the first check that can refuse after the local answers (“Order at arrival”), so it doesn’t debit or write an accounting record.
- It doesn’t raise or join an approval event, and doesn’t go on a learn list.
- It is logged and counted with the rule
dns-query-rate, in runs per rule (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., “Events and rate limits”).
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.
Deny duration
Section titled “Deny duration”A deny holds for the VM until every session that was running when the user denied has ended. Until then:
- the name gets
NXDOMAINwithout a new approval event; - later queries are counted on the closed event.
After that, a lookup raises a new event.
Session set at the answer
Section titled “Session set at the answer”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.
Quiet refusals
Section titled “Quiet refusals”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-hostdpicks 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 statusshows 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.
Parts that are off
Section titled “Parts that are off”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.
Same answer for every refusal
Section titled “Same answer for every refusal”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:
- name form;
- not allowlisted;
- denied;
- quiet list;
- part off;
learn-collectedandlearn-list-full;approval-pending-capandapproval-rate;wildcard-budget, when the budget is used up;accounting-write-failed;handoff-send-failed(S07-05-stream-hand-offS07-05-stream-hand-off: Stream Hand-offHow wb-netd hands each stream to wb-proxyd, and the checks that keep a compromised wb-netd from widening what a stream may reach.);audit-budget,audit-bytesandevent-channel-blocked.
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.
Order at arrival
Section titled “Order at arrival”When the query arrives, wb-netd:
- checks the query rate (
dns-query-rate) before anything else that can debit, and drops a query over it (“Over the rate”); - debits the wildcard budget;
- writes the debit’s accounting record to
wb-hostd; - 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.
Work beside the answer
Section titled “Work beside the answer”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”).
Decisions
Section titled “Decisions”Approval events per VM
Section titled “Approval events per VM”One open approval event per name per VM, with queries from every session counted on it.
- Why: the host can’t tell which session looked a name up.
- Decided: I36I36 (closed): S07-egress-gateway: attribute network flows to projects in the shared work VMThe work VM hosts every trusted project, and its wb-netd sees one guest MAC and one leased IPv4 address (S07-egress-gateway "Addressing"). (B36-flow-attributionB36-flow-attribution: Can projects sharing the work VM keep their network grants apart?Not as the specs are written.).
Hold every refusal for 4 seconds
Section titled “Hold every refusal for 4 seconds”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.
- Why 4 seconds: the macOS resolver library (
libresolv,RES_TIMEOUT) waits 5 seconds before it sends a query again. The guest gets its answer before that retry. The guest’s system resolver ismDNSResponder, and B51-approval-flowB51-approval-flow: What happens between a blocked lookup and the user's answer?Hold the DNS answer for a few seconds while the notification is open, answer a refusal with a negative TTL of zero, and keep guest OS names out of notifications. assumes it waits at least as long. C01-network-and-dnsC01-network-and-dns: Network and DNSThe test cases for the guest's network path: the link endpoint, addressing, and the DNS gateway with its hold, quiet refusals, and negative answers. checks it. - Why every reason: a shorter wait for the other reasons would let the guest tell them apart by the timing of the refusal, which “Same answer for every refusal” rules out.
- Decided: 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. (B51-approval-flowB51-approval-flow: What happens between a blocked lookup and the user's answer?Hold the DNS answer for a few seconds while the notification is open, answer a refusal with a negative TTL of zero, and keep guest OS names out of notifications.).
Drop a query over the rate at once
Section titled “Drop a query over the rate at once”A query over the query rate is dropped without a hold, as an exception to “Hold every refusal for 4 seconds”.
- Why: a held rate refusal takes an entry in the held-query table.
A burst over the rate then filled the table, and
dns-hold-fulldropped what didn’t fit, the queries of names that raise an approval event included. The cap bounded memory, not the rate. - Cost: the guest can tell a rate refusal from the others, since it doesn’t get an answer. That reveals only its own query rate, nothing about a name or the policy.
- Decided: I566I566 (closed): S07-04-dns-refusals: decide whether rate refusals are heldRaised in round 1 of #563 (#486)..
A quiet list for the guest OS
Section titled “A quiet list for the guest OS”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)..
- Why: an idle guest looks up names with no user action (“Quiet refusals”).
- Decided: I17I17 (closed): X03-network-path: Network pathDoes a macOS guest boot on the file-handle network attachment with the gVisor stack: get a DHCP lease, resolve only allowlisted names, and reach only the proxy? (B17-network-pathB17-network-path: Does a macOS guest work on our userspace network stack, reaching only the proxy, and how fast?Yes, with conditions.).
Status: Draft