How a hash chain makes an audit log tamper-evident
An audit log is evidence only if a reader can tell whether it was changed afterwards. A stored row is just a row: an engineer with database access can edit it, an attacker who reaches the server can edit it, and the vendor that hosts the log can edit it too.
"Append-only" is a promise the operator makes about its own systems, and a promise is not something a reader can test. A hash chain is different: it is a property of the stored data that any reader checks, independently of whoever stores it. This post shows what that check proves, what it cannot prove, and how to run it on a Santati trail without trusting Santati.
Append-only is a promise, not a proof
Every log keeps rows somewhere, and someone can change those rows. In a database you run yourself, that is your engineers and anyone who compromises them. In a hosted service, it is the operator too. Access controls, audit trails of admin access and reviews narrow the circle of people who can change a row, but a reader cannot verify any of them: they hold because the operator says they held.
A hash chain does not narrow that circle either. It changes what a later edit costs. With a chain in place, changing one row requires recomputing a digest that is stored in the next row, then the next, and so on to the end of the trail, in a form the reader recomputes for themselves.
One hash per event, each covering the last
The idea is small. Each record stores a digest of its own content plus the digest of the previous record, and the digest is public. Change or remove one record and every digest after it no longer recomputes, so the break is found at a known position and cannot be hidden by editing only the changed row.
import hashlib
import json
def seal(record: dict, prev_hash: str) -> str:
body = json.dumps({**record, "prev_hash": prev_hash}, sort_keys=True, separators=(",", ":"))
return hashlib.sha256(body.encode()).hexdigest()
chain, prev_hash = [], ""
for record in records:
prev_hash = seal(record, prev_hash)
chain.append(prev_hash)
This code shows the idea; it is not Santati's canonical form, which hashes a defined record layout.
What tampering looks like
Verification recomputes every digest in order and compares links. Each kind of edit produces its own failure:
| What someone does | What verification reports |
|---|---|
| Edits a stored event | hash_mismatch: the stored digest no longer recomputes |
| Deletes an event | seq_gap: a position is missing |
| Re-points an event at a different predecessor | prev_hash_mismatch: the link to the previous position is wrong |
Verification stops at the first failing position, so a report names the earliest break, not the newest edit.
How Santati chains a trail
Each trail has its own chain, so one trail's verification never depends on another's. A
sealed event has a position seq and a hash: a SHA-256 digest over a canonical JSON record
that includes the previous event's digest. hash is on every event the read API returns and
is empty until the event is sealed.
Not everything on a trail is in the chain, and the two kinds of rows outside it are counted
rather than reported as breaks: an unsealed row is counted as unsealed (it is waiting for
its seal task), and an imported (backfilled) row is outside the chain by construction and
counted as backfilled.
Check it without trusting us
Verification is a read, so any team API key works:
curl -sS "https://api.santati.io/api/v0/events/chain/verify/?trail=billing&from=2026-09-29T00:00:00Z" \
-H "Authorization: Api-Key $SANTATI_API_KEY"
Leave to unset to verify from from to the chain head.
The call answers 200 for a broken chain too, so branch on status, not on the HTTP code.
The response's report_url is a gzip JSON artifact, downloadable for 24 hours without an API
key, with one entry per event carrying digest_input: the exact string the digest was taken
over. A reader needs only a SHA-256 implementation to recompute every digest — no trust in
the API, and no reimplementation of the canonicalisation.
The response also carries artifact_sha256 and artifact_bytes, so the download can be
checked against the digest the API reported. One window covers at most 100,000 sealed events;
verify a longer range in several windows.
What a chain cannot prove alone
Whoever can rewrite every row from some point on can recompute every digest after it.
The defence is to keep your own copy of the head: record head.seq and head.hash from a
verification response somewhere Santati cannot write — your own database, a ticket, a signed
commit — on a schedule. A later report must contain an entry with that seq and that hash.
head.tail_verified is true only when the pass reached the trail's head and ended on
its digest. A pass over an earlier window says nothing about newer events.
A chain proves a record was not changed after it was written. It cannot prove the record was true, or that the producer sent every event.
Try it
Send a few events to a trail and verify the chain yourself: Quickstart, then Chain verification.