Tamper-evident audit logs and hash chains, explained for compliance teams
A tamper-evident audit log is an append-only record set in which every entry stores a cryptographic hash of the entry before it, so any later edit, deletion or reordering breaks the arithmetic and becomes visible to anyone who recomputes the chain.
Auditrek is not open yet, so anything on this page about what it does is what it is being built to do.
What a tamper-evident audit log is
A tamper-evident audit log is an append-only record set in which each entry stores a cryptographic hash of the entry before it. Because the hash of record 400 is computed over the hash of record 399, which was computed over 398, any edit to an earlier record, any removal from the middle, and any reordering changes an input that a later hash already committed to. Recompute the chain from the first record and the point where the arithmetic stops matching is the point where something moved.
That is the entire mechanism. What makes it interesting to a compliance function is not the cryptography, it is the change in who has to be believed. A conventional audit table asks a supervisory authority to trust your operator, your access controls and your assurance that nothing was touched after the fact. A hash chain lets a reviewer take the records you hand over and reach a verdict independently, using a published algorithm and nothing else.
The three properties that do the work
- Sequence. Every record carries a monotonically increasing sequence number inside its own chain, so a missing record shows up as a gap rather than as an absence nobody can see.
- Linkage. Every record stores the hash of its predecessor, so one record cannot be quietly substituted for another and two histories cannot be spliced together without leaving a seam.
- Recomputability. The verdict comes from recomputing hashes over stored data, not from reading a column that says the data is fine. A stored integrity flag is just another field, and whoever can edit the record can edit the flag.
Tamper-evident is not tamper-proof, and neither is immutable
Three words get used interchangeably in procurement documents and they describe different guarantees. Being precise about which one you are buying matters, because each fails in a different way.
Prevention means an actor cannot make the change at all. That comes from access control, separation of duties, and storage that refuses to overwrite, such as the write-once retention modes offered by cloud object stores. Prevention is strong while it holds and silent about everything outside its scope, including a record that was wrong the moment it was written.
Evidence means an actor may be able to make the change, but the change cannot be hidden. That is what a hash chain gives you. It does not stop a database administrator from editing a row. It makes that edit detectable by anyone who recomputes, which is a different and often more useful property, because the people you most need to constrain are usually the people with legitimate write access.
Immutability in vendor copy usually means one of the two above, implemented in storage. Ask which.
In practice these compose rather than compete. Restricted write paths reduce the number of people who could tamper, append-only storage reduces the number of ways they could, and the hash chain means that if they did, you find out by running a computation instead of by arguing about log retention policy in an examination.
How a SHA-256 hash chain is constructed
The construction is small enough to hold in your head, which is part of why it stands up to scrutiny.
Each record holds a sequence number, a payload, the hash of the previous record, and its own hash. The own hash is computed over the previous hash concatenated with a canonical serialisation of the payload:
hash(1) = SHA-256(genesis_value + canonical_payload(1))hash(n) = SHA-256(hash(n-1) + canonical_payload(n))
The genesis value is a fixed, documented constant, commonly a string of zeros or an empty value, so that the first record is reproducible by a reviewer who has only your documentation.
Canonical serialisation is where implementations fail
SHA-256 is deterministic over bytes, not over meaning. If the bytes you hash at write time differ by a single character from the bytes a verifier reconstructs at read time, the chain reports damage that never happened, and a false positive on an integrity check is expensive in a room full of examiners. The usual culprits are object key ordering, floating point formatting of a confidence score, trailing zeros, timezone representation, unicode normalisation, and the difference between a null field and an absent one.
So the serialisation has to be written down: which fields are included, in which order, in which encoding, with which number format. Treat that definition as a versioned interface. If it changes, you either start a new chain or you stamp the version onto each record, because a silent change to the canonical form is indistinguishable from tampering across the boundary.
Version the format, and know which version a record carries
That versioning is not academic. The field list inside the hash is the only thing the chain protects, and it tends to change as a product matures, so a record set that spans years can span definitions. When you ask a vendor which fields are inside the hash, ask it per version, and ask which version your oldest records carry. A format version held on the record itself is what lets a verifier apply the right definition years later instead of guessing.
Why SHA-256 rather than something else
A chain is worth exactly as much as the difficulty of finding a second payload that produces the same digest. SHA-256 is chosen because it is a widely implemented standard that any reviewer can run without your code, in any language, on a laptop. That reproducibility by a third party is the point. A bespoke or obscure hash puts you back in the position of asking to be trusted.
How a record joins the chain, and how it is checked later
- Read the tail of the chain for that system
The write path first reads the highest sequence number for the chain it is appending to, and that record's hash. This read and the write that follows have to sit inside one transaction. Two concurrent inference events that both read the same tail will both claim the same sequence number, and a forked chain is a broken chain.
- Assign the next sequence number
Sequence numbers are per chain, not global, and they increment by one with no reuse. Gaplessness is what later lets a reviewer detect a deleted tail or a removed block of records, which linkage alone cannot do.
- Serialise the payload canonically
Build the exact byte string defined by your documented canonical form: the identifying and substantive fields of the event, in fixed order and fixed encoding, with the format version recorded. Anything you leave out of this string is outside the protection of the chain, permanently, for that record.
- Compute the record hash
Hash the previous record's hash concatenated with the canonical payload. Store the previous hash alongside the record rather than relying on a lookup at verification time, so that a verifier can reproduce the computation from the row in front of them.
- Write the record atomically
Sequence number, previous hash, payload, format version and hash are committed together or not at all. A partial write leaves an entry whose hash does not describe its own contents, which verification will correctly report as damage and which will cost you an afternoon of forensics to explain.
- Decide whether to anchor the hash outside the system
This step is optional and it is a separate decision from the chain itself. A hash is a small, content-free string, which is why it can be sent to a time-stamping authority under RFC 3161: the authority signs a token over the digest and, by the protocol's own rules, time-stamps only a hash representation of the data and does not examine it. Publishing the chain head to a counterparty achieves something similar. Both add a third party's memory of where the chain had reached, which no chain can assert about itself.
- Verify by recomputation, on demand
Verification walks the chain from sequence one up to the record in question, rehashing stored payloads and comparing against stored hashes, and a useful verifier returns both a status and the first sequence number at which recomputation diverged. The sibling page on hash-chain verification goes through what Auditrek's endpoint returns and why a stored flag is not a substitute.
What a hash chain does not prove
Evidence-first means naming the limits before somebody else does. Four of them matter in an examination.
It does not prove when, unless the time is bound in. A chain proves relative order, not wall-clock time. If the timestamp lives in a column outside the canonical payload, editing it changes nothing that a later hash committed to, and verification will still return a valid status. There are two independent ways to close that gap, and they do different jobs. Putting the creation timestamp inside the hashed payload makes an edit to the time break recomputation exactly as an edit to the output would. Anchoring the record's hash to an external source, such as a trusted timestamp token under RFC 3161, adds a third party's attestation that the digest existed by a given moment. To be plain about where this product currently stands: Auditrek's hashed payload covers the record's sequence number, input hash, output, confidence value, human override flag and pseudonymised subject reference, the creation timestamp sits outside it, and no external time anchor is signed over records today. So the chain commits to the content and order of a decision record, and the recorded time is documentation rather than cryptographic evidence. Ask any vendor the same question, per record version, before you lean on a timestamp in front of a reviewer.
It does not prove the contents are true. A chain proves that a record is byte-identical to what was written. If your inference wrapper reported the wrong model version, the chain faithfully preserves the wrong model version. Integrity and accuracy are separate problems with separate controls.
It does not prevent a full rewrite. An actor with write access to every row and a copy of the hashing code can regenerate an entire chain that verifies perfectly. The only defence is an anchor outside the actor's control: timestamp tokens held elsewhere, chain head digests published to a counterparty, or storage under a retention lock the actor cannot lift. Without that, the chain constrains careless tampering and not determined tampering.
A truncated chain still verifies. Delete the last two hundred records and what remains is internally consistent, gapless and hash-consistent, so a recomputing verifier will report it valid. Auditrek's verifier is no exception: it walks from sequence one over the records that exist. Detecting truncation needs an expected head, which again means somebody outside the writing system remembers where the chain had reached.
Approaches to log integrity, compared
| Approach | What it detects or prevents | What it leaves open | What it costs you |
|---|---|---|---|
| Audit table with restricted permissions | Little on its own, depends on trust in the operator | Anyone with write access to the table and to the database logs | Almost nothing to build, and nothing a reviewer can verify independently |
| Write-once retention lock in object storage | Prevents overwrite and deletion for the retention window | Records written incorrectly stay wrong, ordering across objects is unproven | Retention configuration, storage growth, no per-record proof |
| SHA-256 hash chain per system | Detects edits, reordering and mid-chain deletion by recomputation | Wall-clock time unless the timestamp is inside the hashed payload, full rewrite by an insider, truncation, content accuracy | Canonical serialisation discipline and a verification path that recomputes |
| Hash chain with the timestamp inside the hashed payload | Adds detection of edits to the recorded time of a decision | Whether the recorded time was right when it was written, and rewrites of the whole chain | A format version per record and a documented field list per version |
| Hash chain plus an RFC 3161 trusted timestamp over each hash | Adds third-party evidence that a record's digest existed by a given moment | Anything about records written after the last token, and content accuracy | A dependency on an authority, token custody, and verification of the token chain |
| Hash chain plus externally published chain head | Adds detection of full rewrite and truncation before the last published head | Anything written after the most recent published digest | A publishing cadence and a counterparty willing to retain digests |
| Distributed ledger | Integrity plus a distributed witness to order | Cost, latency, and serious data protection exposure if payloads go on chain | Operational weight well beyond what a record-keeping obligation requires |
One chain per system, or one chain for the organisation
The scoping decision looks administrative and turns out to be structural.
A single organisation-wide chain gives you one head to anchor and one number to remember. It also serialises every write behind one tail read, so a busy inference endpoint and a quarterly batch scorer contend for the same lock. Worse, a break anywhere becomes a break in the evidence for everything, and an examination of one hiring model now touches records from unrelated systems you would rather not disclose.
A chain per AI system inverts both, which is why Auditrek scopes a chain to each connected system rather than to the organisation. Write contention is bounded by the throughput of one system. A break is contained in the system where it happened, and everything else still verifies. And the evidence you produce for a single system and date range is naturally scoped to that system, which matters when the scope of disclosure is itself negotiated.
The cost is bookkeeping. You now have as many heads to keep track of as you have systems, and verification cost grows linearly with chain length, so a chain with millions of records takes real time to walk from sequence one. The standard mitigation is periodic checkpoints, timestamped or externally anchored heads at fixed intervals, so routine verification runs from the last trusted checkpoint and full recomputation from genesis is reserved for the occasions that warrant it.
Choosing the fields that go inside the hash
For AI inference events, the payload has to satisfy two pressures at once. It needs to carry enough to reconstruct what the system decided, and it needs to avoid dragging special category personal data into a store that will be retained for years and shown to third parties.
The resolution is to hash the input rather than keep it. Store a digest of the input, and you can still prove later that a specific input you hold produced a specific recorded output, by hashing your copy and comparing. You have preserved the evidentiary link without becoming the custodian of a clinical note or a credit file. Alongside the input hash, the fields that usually earn their place are the model identifier and version, the output, the confidence value, the event timestamp, and a flag recording whether a human overrode the model. That last field is the one reviewers ask about most, because human oversight of high-risk AI systems is its own obligation under Article 14 of the EU AI Act, and a record that cannot distinguish a model output from an overridden one cannot evidence oversight at all.
The timestamp is worth a separate decision rather than an assumption. A creation time held in a column beside the record, outside the canonical payload, is documentation; the same value inside the hashed payload is evidence, because changing it then breaks recomputation. Whichever side of that line your records sit on, write it down, and say so when you hand the records over.
Two further details are easy to get wrong. First, if you carry any reference to the individual a decision concerned, remember that a pseudonymised identifier is still personal data wherever re-identification remains possible, so the mapping needs to live somewhere with its own controls, and that is a design question to settle with your own data protection function. Second, whatever you decide, the boundary of the hashed payload is the boundary of your proof. The sibling pages on decision record capture and on data minimisation at ingestion cover the payload contract and the rejection of raw sensitive fields in detail.
Checks to run before you rely on a chain as evidence
Ask which fields are inside the hash, per version
Get the canonical payload definition field by field, in writing, for every format version your records span. Anything outside it can be changed without breaking verification, and the creation timestamp is the field most often left outside.
Confirm verification recomputes, and says where it broke
A green status read from a column is a claim about integrity rather than a test of it, and a bare verdict without the first divergent sequence number gives an investigation nowhere to start. The sibling page on hash-chain verification covers both in detail.
Test gaplessness separately from linkage
Linkage catches substitution and reordering. Only sequence continuity plus a known expected head catches a deleted tail, because a truncated chain is internally consistent and will verify.
Pin the serialisation and version it
An undocumented change to field order or number formatting will look exactly like tampering to a future verifier. Version the format, stamp the version on each record, and record where each version applies.
Look at who can write to the store
A chain constrains what tampering can hide, not who can attempt it. Write paths, credential custody and rotation still carry weight in any examination.
Ask whether time and heads are anchored outside the system
Binding the timestamp into the payload stops a quiet edit; it does not stop a wholesale rewrite. For that you want a trusted timestamp token under RFC 3161, a published chain head, or both, held where the writing system cannot reach them. Ask whether either is actually in place for your records, not merely on a roadmap.
Prove a third party can verify without your software
Hand a reviewer the records and the algorithm and see whether an independent script reaches the same verdict. If verification only runs inside the vendor's product, the trust problem has moved rather than gone.
Where a hash chain sits in an AI record-keeping programme
A chain answers one question well and stays silent on the rest. The question it answers is whether the record in front of a reviewer is the record that was written, and in what order it was written. It says nothing about whether you logged the right events, retained them long enough, described the system accurately to the people deploying it, or met any specific obligation.
Those obligations sit elsewhere. The EU AI Act sets record-keeping and logging requirements for high-risk AI systems in Article 12, which requires that such systems technically allow the automatic recording of events over their lifetime, sets transparency and information duties toward deployers in Article 13, and addresses human oversight in Article 14. Whether a given evidence set satisfies a given obligation in the eyes of a national supervisory authority is a legal judgement, and it is one for your own counsel rather than for any vendor or any guide. Auditrek's report generator is designed to support documentation of Article 12 and 13 fields for a chosen system and date range, in PDF and HTML, and every page of that output carries a fixed statement that the report does not constitute legal advice and has not been reviewed by qualified regulatory counsel. We document what the system did. We do not tell you what it means.
What a hash-chained log changes is the character of the conversation. Instead of describing controls and asking for confidence in them, you hand over a record set, a sequence range and an algorithm, and the reviewer checks it. That is a narrower claim than most of this category makes, and it is one you can actually demonstrate on a Tuesday afternoon with an examiner watching. The sibling pages in this pillar go deeper on each piece: the capture call itself, the verification endpoint, minimisation at ingestion, mapping SageMaker inference events onto a decision record, and doing all of it without an engineer having to touch the production inference path.
Questions
What is the difference between a tamper-evident log and an immutable log?
Tamper-evident means a change can be detected after the fact, which is what a hash chain provides. Immutable, as the word is usually used in product copy, means storage refuses to accept a change in the first place, for example a write-once retention lock on object storage. The first gives you a verifiable verdict, the second gives you prevention within its configured scope. They address different failure modes and are usually deployed together.
Do I need a blockchain for a tamper-evident audit log?
No. A hash chain is the primitive that a blockchain also uses, and on its own it gives you edit, reorder and mid-chain deletion detection without consensus, tokens, latency or distributed infrastructure. What a distributed ledger adds is an external witness to the chain's state, and you can get most of that benefit more cheaply with an RFC 3161 trusted timestamp over each record's hash or periodic chain head digests held by a counterparty. Putting inference payloads onto a public ledger would also create data protection exposure that is hard to unwind.
Does the hash chain prove when a decision happened?
A bare chain establishes order, not wall-clock time. It proves when only if the creation time is inside the hashed payload, and only against a third party if the hash is anchored externally, for example with a trusted timestamp token under RFC 3161, where the authority signs over the digest and by the protocol's own rules never examines the data. In Auditrek today the hashed payload covers the sequence number, input hash, output, confidence, human override flag and pseudonymised subject reference, so the recorded timestamp sits outside the chain and is documentation rather than cryptographic evidence, and no external time anchor is signed over records. Ask every vendor this question the same way, field by field and version by version.
Can someone with database access rewrite the entire chain so it still verifies?
Yes, if they hold write access to every record and the hashing logic, and nothing outside their control records where the chain had reached. This is the honest limit of a bare hash chain. It is addressed by anchoring, meaning trusted timestamp tokens or chain head digests retained outside the writing system, plus append-only storage and separation of duties so that the same identity cannot both write records and remove the anchors.
How long does verification take on a chain with millions of records?
Recomputation cost grows linearly with chain length, because every hash has to be recomputed in order. Two things keep this workable in practice: scoping chains per AI system so no single chain absorbs all traffic, and establishing periodic anchored checkpoints so routine verification runs from the last trusted point while full recomputation from the first record is reserved for the occasions that justify it.
What happens if SHA-256 is weakened in future?
Treat the hash function and the canonical payload as a versioned part of the record format from the beginning, stamped onto each record, which is what a hash version field is for. If a migration becomes necessary you start a new chain under the new definition, record the transition point, and preserve the old chain and its verification code so historical records remain checkable under the rules they were written with. The practical risk today is far more often a sloppy serialisation format than the hash itself.
Does a hash-chained log satisfy EU AI Act Article 12?
That is a legal judgement about your systems and your evidence, not something a tool can assert. Article 12 requires that high-risk AI systems technically allow the automatic recording of events over their lifetime, and whether a particular record set is sufficient in an examination is a question for qualified regulatory counsel. Auditrek's report generator is designed to support documentation of Article 12 and 13 fields for a chosen system and date range, and every report carries an embedded statement that it does not constitute legal advice and has not been reviewed by counsel.
Where are the records stored?
Auditrek runs on Amazon Web Services, in a single region, with no multi-region replication and no choice of data residency. Decision records are stored as append-only, SHA-256 hash-chained rows scoped per AI system, so each system has its own sequence and its own head to verify, and raw model inputs never arrive because only an input hash is accepted.
Sources
- Regulation (EU) 2024/1689 (Artificial Intelligence Act), official text
- EU AI Act Article 12, record-keeping
- EU AI Act Article 13, transparency and provision of information to deployers
- EU AI Act Article 14, human oversight
- RFC 3161, Internet X.509 PKI Time-Stamp Protocol
- Amazon S3 Object Lock, write-once retention for object storage