Menu ▾ ▴

#119 [Feature]: Audit log export, retention and tamper evidence

closed
nobody
None
2026-10-24
2026-10-16
Anonymous
No

Originally created by: bosd

We are evaluating Dopbase as a lightweight self-hosted secrets manager for a small consultancy and want to work towards the access-control and audit-logging expectations of NIS2 (and similar frameworks such as ISO 27001). The current audit log (docs/reference/audit-events.md) already covers the right events. What is missing, and listed as roadmap there, is what makes it usable as evidence.

Proposal

  • Export / forwarding: stream audit records as JSON lines to stdout or a file, and optionally to syslog or a webhook, so an operator can ship them to external, write-once storage.
  • Retention: a configurable retention period, with a clear rule for what happens at expiry (archive then delete).
  • Tamper evidence: each record carries a hash of the previous record (hash chain), plus a dopbase audit verify command that checks the chain. An optional periodic signed checkpoint would let an operator anchor it externally.
  • Read access: a read-only auditor role that can view and export the log but cannot read secrets.

Out of scope: SIEM-specific integrations.

Happy to contribute a PR for the export part if the direction fits. Which of these would you accept, and in which order?

See also [#24] (browse audit events from the CLI).

Related

Tickets: #123
Tickets: #124
Tickets: #125
Tickets: #126
Tickets: #131
Tickets: #135
Tickets: #24

Discussion

  • Anonymous

    Anonymous - 2026-10-17

    Originally posted by: bosd

    Implemented and proposed in this order, as four stacked PRs. Each branch builds on the previous one and each PR targets main; until a predecessor merges its diff shows the whole stack, so the per-PR commit noted below is the one to review.

    1. #123 — Tamper evidence (hash chain + verify) — 0015_audit_chain adds seq, prev_hash, record_hash with a unique sequence index. Appends stay atomic under SQLite's existing write lock, so no new locking. GET /api/v1/audit-events/verify and dopbase audit verify recompute the chain in sequence order and stop at the first break (exit 0 intact, 2 broken; --json includes the head sequence/hash for external anchoring). Records written before the chain are sealed during the next startup migration pass and during backup restore.

    2. #124 — Export — dopbase audit export streams one JSON object per line to stdout or --output <FILE> (written atomically, mode 0600, never replaced without --force), with --action / --project / --environment / --actor filters and --limit; pagination is followed to the end, so a full export never stops at one API page. The audit list API now carries seq / prevHash / recordHash additively, so every exported line remains externally verifiable. Syslog/webhook forwarding is deferred: reliable forwarding (backpressure, retries, durability) is a separate problem from exporting, and file/stdout already covers shipping to write-once storage.

    3. #125 — Retention — audit_retention_days in server.toml or DOPBASE_AUDIT_RETENTION_DAYS; unset (the default) keeps the whole log, 0 is rejected as a misconfiguration. The expiry rule is exactly archive, then delete: expired records are written to audit-archive/ as JSON lines (every stored column, chain fields included) and only then deleted in the same transaction, together with an anchor (0016_audit_chain_anchor) recording where the chain continues. dopbase audit verify picks up at the anchor and reports Pruned through: sequence N, so retention never reads as tampering, and appends after a full prune continue the sequence instead of restarting. Only the oldest contiguous run is pruned — a record timestamped behind a retained one (clock step) would leave a hole no anchor can describe, so it waits. Retention runs at startup and on each audit write, the same opportunistic pattern as the existing 30-day session pruning, since the codebase has no scheduler. Archives live outside dopbase backup snapshot (database only) and the docs say to back them up separately.

    4. #126 — Read-only auditor role — a new AdminRole::Auditor that require_audit_reader admits to the audit list and verify endpoints only; require_metadata_access and require_read_access explicitly refuse it, so secret metadata, project/environment data, instance status, mutations, and account administration all return 403. Members keep their existing access and still cannot read the log. Migration 0017 rebuilds admins (SQLite cannot alter a check constraint) and rebuilds sessions after the swap so foreign keys follow the new table — no session is revoked. The Admin UI role picker is not included (API-created accounts, same API-first scope as [#120]).

    Signed checkpoint: not included as a periodic signer — the verify response already exposes headSeq/headHash for anchoring in external write-once storage, so a periodic signed checkpoint can be a focused follow-up on top of [#123]. SIEM integrations remain out of scope per the issue.

    All four are implemented and green on fmt, clippy -D warnings, the full test suite, test:docs, and test:github (the 3 pre-existing commands::export::* failures in this environment need the util-linux script binary and are unrelated).

     

    Related

    Tickets: #120
    Tickets: #123

  • Anonymous

    Anonymous - 2026-10-23

    Ticket changed by: dopbase

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2026-10-24

    Originally posted by: dopbase

    @bosd Thanks for the contribution!

    I’ll cherry-pick the changes that are required and leave out anything unnecessary, such as the dual secret keys. We can work around that for now. I’ll focus on adding tamper evidence, as I think it’s a valuable improvement.

     

Log in to post a comment.