Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Audit Chain

Open Sesame keeps a tamper-evident audit log: every auditable operation appends a JSONL entry whose prev_hash is the hash of the previous entry’s serialized line. Changing, deleting, reordering, or injecting an entry breaks every later link.

core-profile/src/audit.rs is the only reader and writer of the log: open_audit_log resumes the chain for appending, read_audit_log reads it, and verify_audit_log replays it.

Hash Algorithm

The chain hash is the configured [crypto] audit_hash: BLAKE3 (default) or SHA-256 for governance-compatible deployments. A chain is verifiable only under the algorithm it was written with: verifying a SHA-256 chain as BLAKE3 fails at the second entry.

Appending

AuditLogger holds the chain head (last_hash, the hex hash of the last written line, and sequence), the hash algorithm, and the default agent identity. append(action):

  1. Reads the wall clock (milliseconds since the Unix epoch); a clock before the epoch is an error.
  2. Builds an AuditEntry with sequence sequence + 1 and prev_hash the current head.
  3. Serializes it to one JSON line, writes it, and flushes.
  4. Only after the write succeeds, advances the head to the new line’s hash and sequence: a failed write leaves the logger consistent with the log.

The first entry of a fresh log has an empty prev_hash.

Entry Structure

{
  "sequence": 1,
  "timestamp_ms": 1700000000000,
  "action": { "ProfileActivated": { "target": "...", "duration_ms": 42 } },
  "prev_hash": "",
  "agent_id": "..."
}
FieldTypeDescription
sequenceu64Monotonically increasing, starting at 1.
timestamp_msu64Wall clock time in milliseconds since the Unix epoch.
actionAuditActionThe auditable operation (below).
prev_hashStringHex hash of the previous entry’s line. Empty for the first entry.
agent_idOption<AgentId>The agent that triggered the action; omitted when unknown.

AuditAction Variants

AuditAction (core-profile/src/lib.rs, #[non_exhaustive]):

VariantFieldsDescription
ProfileActivatedtarget, duration_msA trust profile was activated.
ProfileDeactivatedtarget, duration_msA trust profile was deactivated.
ProfileActivationFailedtarget, reasonAn activation failed.
ProfileDeactivationFailedtarget, reasonA deactivation failed or was not confirmed.
DefaultProfileChangedprevious, currentThe default profile for new launches changed.
IsolationViolationAttemptfrom_profile, resourceA cross-profile resource access was blocked.
SecretAccessedprofile_id, secret_refA secret was read from a vault.
KeyRotationStarteddaemon_name, generationIPC key rotation began.
KeyRotationCompleteddaemon_name, generationKey rotation completed.
KeyRevokeddaemon_name, reason, generationA daemon’s key was revoked.
SecretOperationAuditedaction, profile, key, requester, requester_name, outcomeA secret operation was performed or denied.
AgentConnectedagent_id, agent_typeAn agent connected.
AgentDisconnectedagent_id, reasonAn agent disconnected.
InstallationCreatedid, org, machine_binding_presentAn installation was created.
AuthorizationRequiredrequest_id, operationAn operation requires authorization.
AuthorizationGrantedrequest_id, delegator, scopeAuthorization was granted.
AuthorizationDeniedrequest_id, reasonAuthorization was denied.
AuthorizationTimeoutrequest_idAn authorization request timed out.
DelegationRevokeddelegation_id, revoker, reasonA delegation was revoked.
HeartbeatReneweddelegation_id, renewal_sourceA delegation heartbeat was renewed.
FederationSessionEstablishedsession_id, remote_installationA federation session was established.
FederationSessionTerminatedsession_id, reasonA federation session ended.
PostureEvaluatedcomposite_scoreA device posture evaluation produced a score.

Verification: sesame audit verify

sesame audit verify replays the chain of the log under the configured algorithm:

$ sesame audit verify
OK: 1247 entries verified.

verify_chain iterates the non-empty lines in order, parses each as an AuditEntry, and checks that its prev_hash is the hash of the previous line. The first mismatch is an error naming the sequence number and the expected and actual prev_hash; an unparseable line is an error naming its line number. The core-profile tests cover modified, deleted, and reordered entries, and a chain resumed across a restart.

sesame audit tail

sesame audit tail -n 10
sesame audit tail --follow

Without --follow, the last N entries are pretty-printed. With --follow, new appends are printed as the file grows, until Ctrl-C.

Startup and Recovery

daemon-profile opens the log once installation.toml exists (open_audit):

  1. open_audit_log reads the chain head from the log’s last non-empty line: its hash under the configured algorithm and its sequence. A missing or empty log starts a fresh chain.
  2. A last line that does not parse is an error naming the file and sesame audit verify: starting a fresh chain after it would fork the log, so daemon-profile does not start until the log is inspected.
  3. verify_audit_log then replays the whole chain. A broken chain is logged at error and the daemon keeps running: the log stays tamper-evident (sesame audit verify reports the break), and refusing to start would also stop recording new events.

The chain survives restarts: the first entry after a restart links to the last entry before it.

File Format and Location

  • Path: Layout::audit_log, <config dir>/audit.jsonl (~/.config/pds/audit.jsonl).
  • Format: JSON Lines, one entry per line.
  • Mode: opened for appending and restricted to its owner (0600), including a log that already existed with wider permissions.
  • Agent identity: daemon-profile’s default agent is uuid::Uuid::new_v5(&install_ns, "agent:human:uid{uid}"), from the installation namespace and the process’s Unix UID.

Retention and Rotation

The log is not rotated or pruned by Open Sesame and grows without bound. External rotation (for example logrotate) severs the chain at the rotation point: sesame audit verify validates one contiguous file, so rotated segments must be archived and verified on their own.