Stackbook Logo
security-complianceestablished · medium operational burden

Tamper-Evident Audit Logging

Also known as: audit-trail, immutable-audit-log

Intent

Record who did what, when and from where in an append-only, tamper-evident store to support investigation and compliance.

Problem

Application logs are noisy, mutable and rotated away, so after an incident nobody can prove who accessed or changed sensitive data. Privileged insiders could also edit the evidence.

Forces

  • •Regulations require retention and integrity of access records
  • •Logging must not slow or break the main transaction
  • •Logs themselves can contain sensitive data
  • •Admins must not be able to erase their own tracks

Solution

Overview

An audit log is a security record, distinct from application logs. Its value rests on completeness, integrity and access control. Every entry must answer who, what, which resource, when, from where and with what result, including denied attempts.

Define a small common event schema early, with stable action names and resource identifiers, so events from different services can be queried together. Give security and compliance teams a read-only query interface, and test your retention and legal-hold procedures before an auditor asks for them.

How it works

service -> outbox table (same transaction as the change)
relay   -> durable queue -> audit writer
writer  -> append to WORM store (object lock, 7y)
         entry = { id, ts, actor, action, resource, outcome, ip,
                   prevHash, hash = SHA256(prevHash + body) }
verifier job: recompute chain daily, alert on mismatch or gap

Writing the event to an outbox in the same transaction as the business change avoids both lost and phantom events.

Pitfalls

  • Fire-and-forget logging that silently drops events under load.
  • Logging secrets, tokens or full personal records. Log identifiers and field names instead.
  • Letting application admins hold delete rights on the audit store.
  • Using local server clocks without synchronization.
  • No review process; unread logs deter nothing.
  • Forgetting read access: auditing who viewed sensitive records matters as much as writes.

Key takeaways

  • Treat audit events as a first-class, schema-controlled product.
  • Write atomically via an outbox and store immutably.
  • Make tampering and gaps detectable, and alert on them.
  • Minimize sensitive content and restrict who can read or delete.

✓ When to Use

  • •Regulated domains such as finance, health and payments
  • •Admin and break-glass actions
  • •Multi-tenant products offering customer audit exports

✗ When Not to Use

  • •Debug tracing, which belongs in observability tooling
  • •High-volume data with no accountability need
  • •Storing full payload bodies containing PII

Pros

  • +Supports forensics and compliance evidence
  • +Deters insider abuse
  • +Detects tampering

Cons

  • −Storage and retention cost
  • −Schema discipline across teams
  • −Delivery guarantees add pipeline complexity

Cost Profile

Infrastructure

Medium — queue and immutable storage

Operational

Medium — retention, access review

Cognitive

Low to medium

Failure Modes

  • Dropped events during pipeline outage leave gaps

  • Sensitive values logged in plaintext

  • Producer credentials can delete past entries

Real-World Examples

Alternatives

    Related Patterns

      Competency Domains

      security compliancereliability ops