Skip to content

S09-11 - Audit

Purpose: What the audit log records, the budgets that bound it, and what happens when the log can’t be written.

Requirements: SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.

The audit log is JSONL in <logs> (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.), which is ~/Library/Logs/WraithBox/ on macOS.

wb-hostd writes it from events sent by wb, wb-netd, wb-proxyd, wb-guestadmin and wb-download (S17-install-and-upgradeS17-install-and-upgrade: Install, Downloads and UpgradesBuild, install, upgrade and remove a Wraith Box bundle, move its stored data to a new version, and download what an image build needs from the internet.). That includes each secret store access, without its value (S15-least-privilegeS15-least-privilege: Least Privilege on the HostThe security design for SEC12-least-privilege: which rights Wraith Box takes on the host, where credentials are held, and how each host process gets only the credentials it needs, for only as long as it needs them.).

Rotation deletes records by age only, never to make room.

A file is deleted once its newest record is older than audit_retention_days in config.toml. The default is 90, and the least is 30. A setting below 30 is refused at load, with the rule audit-retention-min.

A size cap would let a guest push older records out by flooding events.

No record of these classes is ever dropped:

Their sources bound them already: approval limits, push limits, session limits, and the terminal filter’s records per session (S09-12-terminal-filterS09-12-terminal-filter: Terminal Filter RecordsWhat wb reports to wb-hostd about the terminal filter, and the audit records wb-hostd writes from it.).

The high-volume classes, Network Activity (4001) and HTTP Activity (4002), have a budget per VM per minute. It is audit_events_per_minute in config.toml, default 6000. A minute is a calendar minute of UTC. The budget is used up when the minute’s count reaches it.

Over the budget, wb-hostd doesn’t drop records. It refuses new work instead, with the rule audit-budget, until the minute turns:

  • the VM’s wb-netd refuses new lookups and connections;
  • wb-proxyd refuses new streams and requests.

The refusals under that rule are written as one record per minute, with their count. So are the refusals under audit-bytes and event-channel-blocked.

Only the refusal classes that S07-egress-gatewayS07-egress-gateway: Egress GatewayThe only path from a guest to any network: a userspace network stack (wb-netd) and a policy-enforcing proxy (wb-proxyd) on the host. aggregates 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”) are written as runs with a count.

Each open run’s count is written when its window ends, and in the VM’s stop record. So no count is lost with the VM. wb-hostd holds up to 64 open runs per VM for the stop record, and writes a run past that as its own record.

Each VM has a byte budget per day, audit_vm_bytes_per_day, in MiB, default 64. It counts the bytes of all the VM’s records, the classes that are never dropped too. The day is a calendar day of UTC.

Over the budget, new work gets the same refusals until the day turns, with the rule audit-bytes, and wb status says so. The classes that are never dropped are still written.

So the high-volume classes of two VMs add at most 2 × 64 MiB to the log a day, at the defaults.

Both budgets count per slot, not per run of the VM. A VM started again on the same UTC day keeps the day’s count, and the refusal with it.

Both budgets are per VM, because the host can’t tell the projects in a VM apart (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 the work VM, one project’s traffic can use up the budget. The other projects’ new work is then refused with it (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.).

wb-hostd sends each sender of a VM over a budget a notice, and the senders refuse new work. A sender that ignores it has its VM stopped with event-budget-ignored (S09-13-event-sendersS09-13-event-senders: Event SendersHow wb-hostd tells the senders of event records about the audit budgets, what it holds back, and when it stops a VM for its records.).

wb vm status shows both budgets of a VM: their use, and the rule and its end while the VM is over one.

wb-hostd keeps free space for the log. At each VM start, each session start and every minute, it checks the volume that holds <logs> against the floor. The floor is audit_free_space_floor, in MiB, default 1024 (1 GiB).

  • At VM start: a VM starts only when the free space is at least the floor, plus the room the VM’s data disk can still grow on that volume, up to its cap (SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.). Otherwise the start is refused with the rule audit-free-space. The guest controls what the data disk holds. The system disk’s growth isn’t counted. The check every minute covers the data disk while the VM runs.
  • Every minute: below the floor, wb-hostd stops each VM whose data disk grew since the last check, before any write fails. It shows a native notification and a wb vm status line. It refuses VM and session starts with the rule audit-free-space.
  • Reserve: at start, wb-hostd allocates a 64 MiB reserve file in <logs>. It frees the reserve only when a write fails for lack of space. So the records that follow, a VM’s stop record among them, can still be written. It allocates the reserve again once the free space is back above the floor.
  • Volumes: the checks count a data disk only when it is on the volume that holds <logs>. On APFS, the volumes of one container share its free space. A data disk on a sibling volume still takes space from <logs>, but neither the start check nor the stop every minute counts it. The floor check every minute still sees the free space it took, and refuses starts. A write that then fails stops the VMs.

When a record can’t be written, wb-hostd first stops the VM of the record, and of every record queued behind it. A failed record that belongs to no VM stops every VM. It then writes a Detection Finding (2004) with the rule audit-write-failed, and refuses VM and session starts with that rule until a write succeeds.

The writer retries the failed record. The finding is queued behind it, and it belongs to no VM. So a failure that lasts past the first retry stops every VM.

wb-hostd refuses a session start until it can write that start’s record.

So no guest keeps its network while its decisions aren’t recorded (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.). wb vm status says why, with the rule.

Events use OCSF 1.8.0 classes, as OpenShell’s do (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 SIEM can read the log without a custom parser.

wb trust, wb untrust, and the wb project commands that change a project write a 5019 event. It has the values before and after: config_trust, placement, the location, the name, or the recorded remote URLs and root commits (S05-03-management-commandsS05-03-management-commands: Management CommandsThe commands of wb other than the agent commands.).

A record holds:

Process attribution reported by the guest is stored as an untrusted label.

wb-netd and wb-proxyd know the VM. wb-hostd adds the projects and sessions running in it.

The project, session, guest user and program of each connection come only from the guest’s label, stored as untrusted (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.).

The per-session audit log of FR15-inspectFR15-inspect: Inspect what happenedThe user can inspect what happened: per-session audit log, policy explanation, diff of returned work with risky changes flagged. holds:

  • returned work and approvals, by the host’s attribution;
  • network events, by the guest’s label, shown as reported by the guest.

Returned work keeps the project and session of its git transport (S08-workspace-and-gitS08-workspace-and-git: Workspace and Git Round TripHow code gets into the guest and how the agent's work gets back out, without sharing the host filesystem.).

Credential values, and request or response bodies.

  • Why: a size cap would let a guest push older records out by flooding events.

Status: Draft