C03 - Policy and Approvals
Purpose: The test cases for network policy: loading it, combining the policies of the projects in one VM, modes per host, profile parts, learn mode, and the approval flow.
Verifies: 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. (“Session end”), 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. (“Modes, per host”), 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”), 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., 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. (“Deny duration”), 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 OAuth token paths”), S09-04-boundary-checkS09-04-boundary-check: Boundary CheckThe check of a project's policy against the boundary policy with OpenShell's prover, and which policy it checks when. (“Built-in profiles in the check”), 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., S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection.
Unit tests
Section titled “Unit tests”Policy loader
Section titled “Policy loader”Spec: 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., “Modes, per host”.
- Put a host in pass mode from a repository’s
.wraithbox/policy.yamlwithconfig_truston, on a host with a credential binding, on a host a built-in profile covers, without a reason, and with a wildcard host. Then add a binding on a pass host. See each refused at load with an error that names the host and the rule. - Load a policy with a host that has
_or a non-ASCII byte in its name, and runwb allowon such a host, and see both refused with the ruledns-name-form(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., DNS). - The OAuth token paths: each form 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. lists refused at
load with
model-token-path, and the rules it says still load. - Add a global pass entry on a host that a joining project’s remote names, and see that project’s session start refused, with the project named.
Fuzzing
Section titled “Fuzzing”- Policy matching, and network policy YAML.
FuzzLoadPolicyininternal/policy/policyfileloads arbitrary bytes as a global, project and repository file. It never panics. An accepted file doesn’t hold a key outside the implemented keys or a string that isn’t printable ASCII, and one from a repository doesn’t hold thewraithboxkey oraudit(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.). - The guest flow labels of S13-guest-confinementS13-guest-confinement: Guest ConfinementControls inside the guest that narrow what a project user's processes can do, and tell the host which program opened each connection..
- The decoder and the script check that show internationalized names in approval requests (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.).
Conformance
Section titled “Conformance”The project set and learn mode
Section titled “The project set and learn mode”- Push to a repository outside the project set, with and without an attacker-supplied token. Create a gist or a repository. Publish a package. The project set is the VM’s: the repositories of every project with a session in the VM (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.).
- In a learn-mode session (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.):
- resolve a name that isn’t allowlisted, and see
NXDOMAINwith the same answer bytes as outside learn mode, no approval event, and the name inwb learn report; - push to a repository outside the project set, and see it refused;
- resolve more distinct names than the list cap, and see the rest
refused with
learn-list-full, not listed, and counted as dropped in the summary; - resolve a name with a control byte, an escape or a non-ASCII byte,
and see it refused with
dns-name-formand absent from the report, the summary andwb status; - put a name with a risk-check finding on the list, approve the batch, and see only the names without a finding allowed.
- resolve a name that isn’t allowlisted, and see
Per-VM enforcement
Section titled “Per-VM enforcement”- End a project’s last session, and see its binding no longer injected,
its open streams closed with the rule
policy-recomputed, and its project user’s processes stopped. - Give two projects different wildcard budgets or minimum ages, start both, and see the stricter one applied to both, including to a count reached before the second one joined.
- For every host and port of a union, see the mode
wb-proxydapplies equal the mode the boundary check projected (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”). With a boundary that allows onlyGETon a host:- put the host’s port 443 in
auditwith aGETrule in one project, and add anenforceendpoint with aGETrule on the same host and port in another file. See the start pass and aDELETEto that port refused; - then put port 8443 of the same host in
auditwith aGETrule while port 443 stays inenforce, and see the start refused with a counterexample that names the host, so aDELETEto port 8443 is never sent.
- put the host’s port 443 in
- Put port 443 of a host in
auditin the global policy, with one project’senforceendpoint with aGETrule keeping it inenforce, and a boundary that allows onlyGET. Remove that endpoint while sessions run, and separately end that project’s last session while another session stays. See each change checked as widening and refused by the boundary, the host and port held inenforcewith a 5019 event, and aDELETEto it still refused. - Put
github.com, a host a project’s remote names, or a host with a credential binding inaudit, in a policy file and as a global entry loaded before a project names the host. Add a binding on a host inauditwithwb cred set. See each refused with the host and the rule. Load repository configuration withenforcement: audit, and see a load error (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., “Modes, per host”, audit). - With the prover unavailable, remove a binding while sessions run, and
see it no longer injected and its streams closed. Then add a rule,
and separately remove a
deny_rulesentry, and see each change refused and shown as pending. - Start a second project whose policy puts a host in pass mode that the first project binds or inspects, whose binding overlaps the first one’s on the same host, port and path with another secret, or whose rules leave the boundary in union. See the start refused with both projects named and the first project’s policy unchanged.
- With the prover unavailable, end the last session of a project that
held the stricter minimum age, turned a part off, set inspection on a
host the other project passes, or had a
deny_rulesentry. See each kept as a held source, a 5019 event that names the project, and the widening shown as pending, while the project’s binding is no longer injected (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., “Session end”). - Deny a name, start and end another session, and see the name still refused with no new approval event until every session running at the deny has ended (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., “Deny duration”).
- Answer an approval after a session started or ended, and see the
answer refused with
approval-sessions-changedand the request shown again with a new id.
Sessions that exclude each other
Section titled “Sessions that exclude each other”- Start a learn-mode session while a session or a debug shell of another project runs, and start another project’s session while a learn-mode session runs, and see each refused with the other project named.
- Start another project, or an
--isolatedsession, in the isolated VM while a project withplacement = isolatedhas a session there, and the reverse, and see each refused. - Start
--learnin a project withplacement = isolated, and start with--isolatedin a project withplacement = workandconfig_truston, and see each refused.
Profile parts
Section titled “Profile parts”Spec: 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”.
- Turn off every GitHub part but
git, and see:- fetch and push to
github.compass; - any REST or GraphQL request refused with
profile-part-off; - no GitHub binding injected on
api.github.com; - a lookup of
api.github.comrefused at DNS with no approval event, also while another project’s rule allows that host.
- fetch and push to
- With the same parts off, load a repository configuration rule on that
host, or on
api.github.comwith the path/graphql,/graphql/,/graph*,/%67raphqlor/**and any method, and see a load error. - With a boundary that forbids
api.github.comand only the GitHubgraphqlpart on, see the prover refuse the session start (S09-04-boundary-checkS09-04-boundary-check: Boundary CheckThe check of a project's policy against the boundary policy with OpenShell's prover, and which policy it checks when., “Built-in profiles in the check”).
Approvals
Section titled “Approvals”- Look up a burst of unknown hostnames from the guest, and see the
approval limits deny the requests past the limit and log each with
the rule
approval-pending-caporapproval-rate,wb statusshow the counts, and no more prover runs than the cap. - Leave a request unanswered, end every session it records, and see it
expire with the rule
approval-expiredand grant nothing. - Look up an
xn--name whose Unicode form mixes Latin and Cyrillic, and one that fails to decode, and see each request show the ASCII form with a warning. Look upxn--bcher1-3ya.de(bücher1.de), and see no warning. - Answer a request with
wb approve <id>after it expired, and after it was replaced when the VM’s sessions changed. See each answer refused withapproval-stale, and the newer request for the same name still pending, its old notification withdrawn. - With one request pending, run
wb approvewithout an id, and see it refused with the pending id listed. - With 16 requests pending, restart
wb-netd, look up a 17th unknown name, and see it refused withapproval-pending-cap. - From a test
wb-netdthat skips its own check, send a 17th approval event, and seewb-hostddrop it without a notification, logged with the same rule.
Flow labels
Section titled “Flow labels”Once X14-flow-attributionX14-flow-attribution: Guest flow attributionA Network Extension transparent proxy in a macOS guest (S13-guest-confinement): can it be approved during the image build without MDM? has delivered labels:
- Forge or omit a flow label, and see only rules without program narrowing match.
- Replace a pinned binary, and see its connections denied.
Status: Draft