/app/auditctl. For what the chains are and
what they prove, see Audit trail.
Synopsis
Environment
The application role sees one organization at a time under row-level security,
so with it every chain would read as empty and intact.
auditctl checks the
role before doing any work and refuses to run as one that cannot read tenant
tables.
What it checks
- SEALED is the number of rows whose digest and link were recomputed and matched.
- REMOVED counts rows that were deleted lawfully (the retention sweep, or a cascade from a deleted finding, scan or agent) and left a removal record. A gap in a chain with no removal record is reported as a break.
- UNSEALED counts rows written before the table was chained. They are not covered by the chain. A checkpoint records the count, so the set cannot grow unnoticed.
BROKEN at row N: <reason> and names the first row that
does not verify.
Exit codes
1 and 2 are distinct so that a scheduled job can page on 1 and retry on
2.
Checkpoints
The chains use an unkeyed SHA-256 computed inside the database. Somebody who can disable a trigger can rewrite a chain from any row forward, andverify
on its own will pass it. A checkpoint is the control against that.
checkpoint refuses to sign when any chain is broken: a checkpoint of a
tampered chain would anchor the tampering.
What a checkpoint does and does not prove
It proves that history up to the moment it was signed is unchanged, to anybody holding the file and the key. It says nothing about rows written afterwards, so take checkpoints on a schedule (below): the interval is the window in which a rewrite by a database administrator would go undetected. It proves nothing if it is stored where the database administrator can replace it and the key. Store checkpoints off the host.Scheduled checkpoints
The worker takes checkpoints itself whenAUDIT_CHECKPOINT_DIR is set:
Each run does what
auditctl verify --checkpoint <newest file> followed by
auditctl checkpoint would: it verifies every chain, proves history up to the
newest checkpoint already in the directory, and only then writes a new one. It
writes nothing, and logs periodic task failed with the reason, when a chain
is broken, when history below the previous checkpoint changed, or when the
previous file does not authenticate with the key (it was edited, or the key
changed: move the old files aside to start a new series). It runs as the
worker’s own database role, one organization at a time, so it needs no
migration-owner credentials.
The production Compose file mounts a volume, audit_checkpoints, at
/audit-checkpoints in the worker, so AUDIT_CHECKPOINT_DIR=/audit-checkpoints
is all it needs there; on Kubernetes, mount a volume yourself and name its path.
The trade is that the worker holds the key. A checkpoint still proves nothing
until it has left the host, so point the directory at storage the database’s
administrators cannot write, or at a directory your off-host backup copies, and
verify against those copies. If the key cannot live on the worker’s host, run
auditctl checkpoint from another host instead.
A lawful removal and a removal by somebody who also forged its removal record
look the same to verify. The checkpoint comparison reports how many rows
were removed since it was signed, so the number can be compared with what your
retention settings would remove.