Skip to content

S07-17 - Approvals and Learning

Purpose: How an unknown destination reaches the user as an approval request, what an approval grants, and how learn mode collects names.

An unknown destination produces an approval event in wb-hostd, except for these names (S07-04-dns-refusalsS07-04-dns-refusals: DNS RefusalsHow wb-netd refuses a name: approval events, the hold before each refusal, quiet refusals, and the answer that is the same for every reason.):

  • a name on the guest OS’s background list;
  • a host refused with profile-part-off.

The event is shown as a native notification, and listed by wb status. The user picks one of:

  • allow for this session;
  • allow for this project;
  • deny.

Each request shows the result of the risk check on the rule it would add (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.). Examples are new reach for a credential, or a new write method.

Policy changes take effect without restarting anything. An approval that adds an inspected host doesn’t need a new CA, because the CA has no name constraints (S09-06-ca-keysS09-06-ca-keys: CA KeysHow the key of each TLS inspection certificate authority is made, stored and restored, and when a CA is valid.).

The host can’t tell which session looked up a name (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.).

  • A request names the VM and the sessions running in it.
  • A project or session the guest reported is shown, marked as reported by the guest and untrusted.

The answers:

Either way, any process in the VM can use an allowed rule (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.), and the request says so. The 5019 event of the answer records the guest’s label, if any, and the project the user picked.

An answer given after the VM’s sessions changed is refused. The request is shown again as a new request, with a new id (S07-04-dns-refusalsS07-04-dns-refusals: DNS RefusalsHow wb-netd refuses a name: approval events, the hold before each refusal, quiet refusals, and the answer that is the same for every reason., “Session set at the answer”).

On a host without a built-in profile, an approval grants the read methods GET, HEAD and OPTIONS.

A write method is refused until the user approves it in a separate request (fail closed, 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 risk check flags that request as a new write method. A write method is any other method, and a GET with Upgrade: websocket, which opens a channel both ways.

An approval is bound by the boundary (S09-09-approvalsS09-09-approvals: ApprovalsWhat an approval adds, the checks that each request goes through, and approvals for a joining project.). A rule outside it isn’t shown as a request.

Learn mode is only for projects with placement = work, not in an --isolated session (FR10-learn-modeFR10-learn-mode: Learn modeA learn mode, available only to projects whose placement is work (S05-cli), records the destinations a project needs and proposes an allowlist.). It changes how unknown names reach the user, not what the guest can reach. SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable. holds as written during a learn-mode session.

A name that isn’t allowlisted gets NXDOMAIN. The answer bytes, the hold and the wildcard budget are the same as outside learn mode (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., S07-04-dns-refusalsS07-04-dns-refusals: DNS RefusalsHow 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 rules of allowed hosts all hold:

Learn mode never adds a rule, a pass host or a raw TCP entry.

During a learn period in the VM (“The list”), an unknown name doesn’t raise an approval event or a notification. wb-hostd puts it on the learn list, with:

  • the time;
  • the count of lookups;
  • the guest’s program label, if any, shown as reported by the guest and untrusted.

The refusal is logged with the rule learn-collected (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.).

These are refused as outside learn mode, and don’t go on the list:

  • a name answered locally (.arpa and .local);
  • a name refused for its form;
  • a name on the guest OS’s background list;
  • a host refused with profile-part-off;
  • a denied name.

A learn list belongs to the learn project, and the set of sessions of its learn period. The period runs from the start of the project’s first learn-mode session in the VM, to the end of the last learn-mode session in the VM. Collection, the period and the refusal of other projects (“One project at a time”) all use this span.

  • After the period ends, the list stays for review.
  • A new learn period of the project starts a new list, which replaces the old one.
  • The user can clear a list from wb learn report.

A list holds at most as many distinct names as a cap fixed in code allows (SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.). Past it, a new name is refused as usual. It isn’t collected, and is logged with the rule learn-list-full.

Names are stored only after they pass the name form check and its length limit. Program labels are cut as guest strings in log records are (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”).

At session end, wb prints the list in the session summary: at most 100 names, then “and N more”. It does so as for the link list (S16-02-drops-and-linksS16-02-drops-and-links: Drops and LinksThe fixed rules that drops are counted by, and how wb records the links the filter drops., “Links”).

The user allows the names they accept with wb allow, or approves a selection from the report in one batch. A name with any finding, or whose rule would leave the boundary, is left out of the batch. The user allows it on its own with wb allow.

An accepted name is saved to the learn project’s network policy, as Allow for this project does. The project is fixed by the list, not picked by the user. It grants what an approval grants (“What an approval grants”).

The agent stops at the first refused host, and doesn’t reach the hosts behind it. So learning a project’s hosts can take more than one run, with the user allowing names between them.

The host can’t attribute the destinations it collects to a project (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.). So wb-hostd:

Another session of the same project may start, with or without --learn. The names it looks up during the learn period go on the same list.

When a project’s last session ends, wb-guestd (S13-01-process-hardeningS13-01-process-hardening: Layer 1: Process Hardening (v1)How wb-guestd hardens every process it starts for a project user, and how it stops and kills a project user's processes.):

  1. locks that project user;
  2. kills its processes until none remain;
  3. boots out its per-user launchd domain.

So no process of another project is meant to run during a learn-mode session. A process can still be left running, by guest root or by launchd.

When wb-guestd reports one, wb-hostd refuses learn mode in that VM until the VM is cold-booted (S06-10-leftover-processesS06-10-leftover-processes: Leftover ProcessesThe results of the kill of a project user, how wb-hostd accepts them, and what it does when processes are left.). Its names then reach the list, which the user reviews before any name is allowed.

An approval on a host without a built-in profile grants GET, HEAD and OPTIONS. A write method needs a separate approval.

Learn mode collects unknown names, and refuses them.

Status: Draft