Skip to content

S09-01 - Policy Files

Purpose: Where policy is written, the network policy schema Wraith Box accepts, how the prover sees it, and narrowing by program and project.

Policy is in two kinds of files. Both are on the host, outside every repository and every guest. Both are the same on every host OS (FR17-same-everywhereFR17-same-everywhere: Same on every hostThe same wb commands, flags, policy files, and behavior on every host OS.).

  • Settings in TOML: <config>/config.toml and <config>/projects/<project-id>.toml.
  • Network policy in YAML: <config>/policy.yaml and <config>/projects/<project-id>.policy.yaml.

<config> is per OS in S12-platformsS12-platforms: PlatformsWhich host and guest operating systems Wraith Box targets, how platform-specific code is isolated, what each platform uses, and how wb works inside WSL. (~/.config/wraithbox on macOS).

Network policy uses the network_policies part of OpenShell’s policy schema (version 1). It holds named rules of endpoints and binaries. An endpoint has a host, port, path, protocol, an access preset or method and path rules, and enforce or audit.

Wraith Box parses and validates the schema in Go, with its own code.

Wraith Box’s extensions go under one top-level key, wraithbox: pass (host, reason), raw_tcp (host, port, reason), wildcard_budget (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 parts_off (profile, kind, part: 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”). credential_bindings, dependency_gate and git_hosts aren’t built yet, so they are refused with policy-key-unsupported. Repository configuration can’t hold wraithbox (policy-source, S09-03-project-settingsS09-03-project-settings: Project SettingsWhat a project's settings hold, and what a repository's own .wraithbox/ configuration may add., “Closed keys”).

OpenShell adds fields to the schema without changing version: 1. So the pin is an OpenShell release: v0.1.2 (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…, S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice.). Wraith Box accepts the keys of that release only.

OpenShell rejects a policy with an unknown key at any level. So a file with Wraith Box’s extension keys isn’t a valid OpenShell policy (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…).

Wraith Box keeps the extensions in the same file. When it hands policy to OpenShell’s tooling, it writes a new document with only version and network_policies. It never hands over the user’s file.

Per endpoint, Wraith Box implements host, port or ports, path, protocol, enforcement, access, rules and deny_rules.

The built-in profiles need deny_rules, for denies such as the git hosting profile’s archive deny. The prover’s handling of deny_rules wasn’t tested (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…). It is tested before the boundary check relies on it.

Any other OpenShell key is refused at load, with an error that names it (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.). It is never ignored, so no rule is weaker than written. Examples:

  • the other top-level keys, filesystem_policy and network_middlewares;
  • the endpoint fields credential_binding, mcp and allowed_ips.

allowed_ips would allow destinations by raw IP address (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.).

Every rule name, host, path and method must:

  • be ASCII;
  • have no control bytes;
  • be within a length cap fixed in code.

Otherwise the file is refused at load. The prover models ASCII values only, and its output repeats these strings (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…).

wb-hostd loads each file with its own Go code (internal/policy/policyfile). A repository’s file is repository data, so every byte is treated as hostile. The prover runs confined because it parses the same bytes (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.). The loader stays in wb-hostd because it is Go, bounded and fuzzed (FuzzLoadPolicy, C03-policy-and-approvalsC03-policy-and-approvals: Policy and ApprovalsThe 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.).

Only the global and project network policy files can put a host in pass mode, never repository configuration. Each pass entry names one exact host, and needs a reason. The reason follows the string rules (“Strings”).

These are refused at load:

  • a wildcard entry;
  • an entry for a host with a credential binding;
  • an entry for a host a built-in profile covers.

Adding a pass host is a Device Config State Change (5019) event. 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”, has the rules.

A raw TCP entry names one exact host and one port, for a stream that is neither TLS nor HTTP. The rules of a pass host apply to it, on its host and port. 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. has the rules.

Only the global and project network policy files can put a host and port in audit.

An audit endpoint on a host with a credential binding, or on a host a built-in profile covers, is refused (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.):

  • at load;
  • at every recompute;
  • when a binding is added later.

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”, has the rules.

The document Wraith Box writes for the prover allows at least what wb-proxyd enforces, never less.

The prover can’t see the extension keys. Wraith Box’s own Go check compares them with the boundary’s extension part:

  • each pass host must be a pass host in the boundary;
  • each raw TCP entry must be a raw TCP entry in the boundary;
  • dependency-gate thresholds can’t be looser;
  • the wildcard budget can’t be larger.

Any mismatch refuses the policy.

audit lets every request through, and only logs a violation (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”). So a host and port whose mode resolves to audit (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”) is written as the whole host on that port.

The projected endpoint is built from the host and the port only:

  • protocol: rest and enforcement: enforce;
  • one rule, allow: { method: "*", path: "/**" };
  • in an entry whose binaries is path: "/**".

These are dropped: the endpoint-level path, access and rules, the entry’s binaries, and the deny_rules of every endpoint on that host and port.

An endpoint with ports is written once for each port, each in the mode its host and port resolves to. A host and port that resolves to enforce is written with its rules.

The boundary must then allow every method and path on that host and port. A boundary that allows less refuses the policy, with a counterexample that names the host.

The prover’s reading of method: "*" wasn’t tested (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…). It is tested before the boundary check relies on it.

binaries entries match the program label from the guest (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.). Until spike 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, binaries does not narrow a rule.

OpenShell’s policy engine has the same mode, switched by its require_binary_identity setting. Its isolation backends must resolve binary identity, though (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…).

The prover checks each policy both with and without binary identity. With it, the prover reads /** as every program (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…).

A project’s rules and bindings apply to the whole VM while the project has a session in it (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.).

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? may deliver labels that name the project user (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.). Once it does, those labels may narrow a project’s rules to its own flows. The rules of program narrowing then apply: a missing or malformed label matches no narrowed rule.

Until then nothing is narrowed by project.

wb-hostd merges the files into one effective policy per VM (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.). It reaches wb-netd and wb-proxyd as a wraithbox.policy.v1.EffectivePolicy message (proto/wraithbox/policy/v1/policy.proto).

  • Why: OpenShell’s prover can then check Wraith Box policy, and users get one policy language for both tools.

Only global and project files set pass hosts

Section titled “Only global and project files set pass hosts”

Raw TCP entries follow the pass-host rules

Section titled “Raw TCP entries follow the pass-host rules”

audit only from global and project files, never on guarded hosts

Section titled “audit only from global and project files, never on guarded hosts”

Status: Draft