S09-11 - Audit
Purpose: What the audit log records, the budgets that bound it, and what happens when the log can’t be written.
Design
Section titled “Design”Where records go
Section titled “Where records go”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.).
Retention
Section titled “Retention”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.
Budgets
Section titled “Budgets”Never dropped
Section titled “Never dropped”No record of these classes is ever dropped:
- Device Config State Change (5019);
- Detection Finding (2004);
- approvals;
- returned work;
- recovery pushes;
- secret store accesses;
- the records of VM starts and stops, and of sessions;
- the records of
wb-download, which belong to no VM, and count against no VM’s budget (S17-03-downloadsS17-03-downloads: DownloadsHow wb-download fetches what an image build needs from the internet.).
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.).
Events per minute
Section titled “Events per minute”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-netdrefuses new lookups and connections; wb-proxydrefuses 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.
Runs with a count
Section titled “Runs with a count”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.
Bytes per day
Section titled “Bytes per day”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.
Per VM
Section titled “Per VM”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.).
Telling the senders
Section titled “Telling the senders”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.
Free space and failed writes
Section titled “Free space and failed writes”Free space
Section titled “Free space”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-hostdstops each VM whose data disk grew since the last check, before any write fails. It shows a native notification and awb vm statusline. It refuses VM and session starts with the ruleaudit-free-space. - Reserve: at start,
wb-hostdallocates 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.
Failed writes
Section titled “Failed writes”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.
Records
Section titled “Records”Classes
Section titled “Classes”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…):
- Network Activity (4001), for connections;
- HTTP Activity (4002), for inspected requests;
- Device Config State Change (5019), for policy, approvals and project settings;
- Detection Finding (2004), for refused placeholders, foreign credentials removed from a request (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.), pin mismatches, the terminal filter’s drops and dropped links, and other signs of an attack, and for a write of the log that failed;
- Application Lifecycle (6002), for VM starts and stops, and for sessions opened and ended;
- Entity Management (3004), for the secret store accesses of S15-03-access-rulesS15-03-access-rules: Access RulesHow each host process gets only the credentials it needs, for only as long as it needs them, and which process may access which item., rule 6: a fetch, use or list is a read, and a write or delete is an update or delete of the item.
A SIEM can read the log without a custom parser.
Project settings
Section titled “Project settings”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.).
Fields
Section titled “Fields”A record holds:
- timestamp;
- VM;
- project, session and guest user. For network events these are derived from the guest’s label (“Attribution of network events”);
- destination host and port;
- decision, and the rule that made it;
- HTTP method and path, for inspected requests;
- bytes in and out;
- approval actions;
- returned work and its flags;
- the terminal filter’s drop counts by rule, and its dropped links, escaped (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.).
Process attribution reported by the guest is stored as an untrusted label.
Attribution of network events
Section titled “Attribution of network events”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.).
Never recorded
Section titled “Never recorded”Credential values, and request or response bodies.
Decisions
Section titled “Decisions”Delete by age, never by size
Section titled “Delete by age, never by size”- Why: a size cap would let a guest push older records out by flooding events.
Refuse new work, never drop records
Section titled “Refuse new work, never drop records”- Why: 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.).
- Exceptions: the records a sender sends past the stop allowance
after its VM’s stop began are left unread and logged, and the late
wb-proxydrecords of an ended VM past the stop allowance are dropped and logged (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.).
Status: Draft