Audit log
A durable, tamper-evident record of every security-relevant action — kept separate from operational telemetry, and in the path of every secret read.
What is recorded
- Authentication success and failure, sessions, bootstrap and recovery activation, use and deactivation.
- Secret creation, metadata changes, value reads, version creation, rollback and deletion.
- Organization, membership, policy, identity and API token changes.
- Key creation, rotation and rewrapping, and dynamic credential issue, renewal and revocation.
- Workload token exchanges and other administrative actions.
- Authorization denials, with safe reason codes.
Each event carries a schema version, event ID, organization, actor and actor type, action, stable resource identifier, outcome, UTC timestamp, request or correlation ID and a small allowlist of source fields. Never secret values, passwords, private keys, raw tokens or request and response bodies.
Fail-closed reads
Rivergate does not return a secret value until the matching success event is durably committed in PostgreSQL.
- The caller is authorized and the value is decrypted into memory.
- The audit gate appends the read event and commits it.
- Only then is the value released to the response.
If the commit fails, the value is cleared on a best-effort basis and the request fails with 503 service_unavailable. There is no degraded mode, bypass flag, environment override or administrator exception. A database outage therefore makes secret reads unavailable rather than unaudited.
Business mutations and their audit event are committed in the same PostgreSQL transaction, so a change cannot exist without its record.
Hash chain
Each organization has one ordered chain.
- The append transaction locks the organization’s chain head, assigns the next sequence number, and computes
SHA-256(previous_hash || canonical_event). The first previous hash is 32 zero bytes. - The canonical encoding is versioned and independent of JSON serialization: strings are length-prefixed and integers and timestamps use fixed-width network byte order.
- The event, the new head and the commit are one atomic step. A failed insert rolls the whole append back.
- Mutation-rejecting triggers guard event and checkpoint rows against routine mistakes.
Verification checks contiguous sequence numbers, hash links, canonical fields, event hashes and the stored head in one repeatable-read snapshot.
Signed checkpoints
A hash chain alone is not immutability: a privileged database owner could rewrite it consistently. Checkpoints add independent evidence.
- At a configurable interval (
AUDIT_CHECKPOINT_INTERVAL, default5m) the worker signs each organization’s chain head with an Ed25519 key: format version, organization, covered sequence, head hash, time, hash algorithm and signer key ID. - The signing key is loaded from
AUDIT_SIGNING_KEY_FILE, is distinct from every data-encryption key, and is mounted only into the worker. - Rotating the signer retains old public keys, and each checkpoint records its signer key ID.
To detect rewriting or truncation of history, retain the signer’s public keys and copies of signed checkpoints somewhere independent of Rivergate’s PostgreSQL. Rivergate does not export checkpoints or provide WORM retention itself; use your own immutable storage.
Reading the audit log
- Open Audit in the dashboard, or call
GET /api/v1/organizations/{organization}/audit. - Reading audit events requires the
audit.readaction: organizationowner,adminorauditor. - Metadata reads and denied decisions are recorded too, not only successes.
Operating the audit log
- Appends set
synchronous_commit=onand fail closed if PostgreSQL reportsfsync=off. Durability across failover still depends on your replication policy. - Alert on append failures, checkpoint worker health, and the age of the oldest un-checkpointed chain head.
- Use separate database roles for migrations and runtime, and restrict who can alter audit tables. The bundled Compose stack uses a single database identity and does not demonstrate this separation.
- Preserve signer public keys for the life of the checkpoints they verify.
Audit versus telemetry
The audit log and observability are separate data paths. Telemetry exporters never carry audit data and cannot influence audit durability. A telemetry outage never blocks a read; an audit outage always does.