Prompt
I'm building a regulated internal tool and need tamper-evident log storage
Latest observation
For a regulated internal tool, “tamper-evident” log storage usually means you want append-only logs with cryptographic integrity proofs, plus tight access controls and retention controls. Here’s a practical blueprint.
Recommended design
1) Write logs to an append-only store
Use storage that prevents modification/deletion by normal application users, such as:
- WORM / immutable object storage: AWS S3 Object Lock, Azure Immutable Blob Storage, GCP bucket retention + object versioning
- Append-only database table with restricted update/delete permissions
- Dedicated log service with immutable retention guarantees
Best practice is to treat logs as write-once from the application perspective.
2) Hash each record with chaining
Make each log entry include:
previous_hashrecord_hash- timestamp
- actor/service identity
- event type
- payload
A simple pattern:
record_hash = SHA-256(
previous_hash || timestamp || event_type || actor || payload
)
This creates a hash chain, so modifying one record breaks all subsequent hashes.
3) Periodically anchor the chain
To make tampering harder to conceal, periodically seal batches of logs by:
- computing a Merkle root for a time window, or
- storing the last hash of the interval in a separate protected system
Then anchor that digest in:
- a separate account/project
- an HSM-backed signing service
- a third-party timestamping service
- an internal audit ledger
This gives you evidence that the log state existed at a specific time.
4) Sign the digests
Use a private key stored in an HSM or KMS to sign:
- each batch digest, or
- the daily/hourly Merkle root
Store:
- the digest
- signature
- certificate/key identifier
- signing time
This makes falsification much harder and helps with audits.
5) Separate duties and permissions
Ensure:
- the app can append logs, but cannot alter them
- operators can read logs, but not delete or rewrite them
- only a tightly controlled retention/admin role can manage lifecycle
- any privileged action is itself logged and reviewed
6) Protect the pipeline
Make tampering difficult before logs even reach storage:
- use TLS everywhere
- authenticate producers with service identities
- buffer locally if storage is unavailable
- forward logs to at least two independent destinations if required
- monitor for gaps, duplicates, or sequence resets
7) Add verification tooling
Build a verifier that can:
- replay the chain
- verify signatures
- check for missing intervals
- detect record edits, deletions, reordering, or replay
Practical architecture
A common setup:
- Application emits structured logs
- Log collector normalizes and timestamps them
- Hash-chain builder adds
previous_hash - Batch signer seals each interval
- Immutable object storage stores raw logs + digests + signatures
- Audit system periodically verifies integrity
Example record format
{
"id": "01JABC...",
"timestamp": "2026-10-27T12:34:56Z",
"actor": "service-a",
"event_type": "USER_LOGIN",
"payload": {
"user_id": "u123",
"result": "success"
},
"previous_hash": "b7d1...",
"record_hash": "9f3a...",
"batch_id": "2026-10-27T12:00Z",
"batch_signature": "MEUCIQ..."
}
What this does and does not protect against
Protects against:
- undetected modification
- deletion
- reordering
- insertion in the middle of a chain
- unauthorized changes after sealing
Does not fully protect against:
- compromised application producing false logs
- compromised signing key
- logs never written in the first place
- an attacker with full control of all systems and keys
So you still need strong IAM, key management, and monitoring.
Compliance considerations
Depending on your regime, you may need:
- retention schedules
- legal hold support
- access logging for log access itself
- time synchronization (NTP with trusted sources)
- encryption at rest and in transit
- data minimization / redaction for sensitive fields
- documented verification procedures
If you want the simplest robust option
If you need something practical fast:
- store logs in immutable object storage
- hash-chain records
- sign daily Merkle roots with KMS/HSM
- keep verification jobs and alerting
- restrict deletion with retention policies
If you want, I can give you:
- a reference architecture for AWS/Azure/GCP,
- a schema for tamper-evident log records, or
- sample code for hash chaining and signature verification.