<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://docs.santati.io/blog/</id>
    <title>Santati Blog</title>
    <updated>2026-11-17T00:00:00.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://docs.santati.io/blog/"/>
    <subtitle>Engineering notes and product news from the team building Santati audit logging.</subtitle>
    <icon>https://docs.santati.io/img/favicon.ico</icon>
    <rights>Copyright © 2026 Santati</rights>
    <entry>
        <title type="html"><![CDATA[How a hash chain makes an audit log tamper-evident]]></title>
        <id>https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/</id>
        <link href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/"/>
        <updated>2026-11-17T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[What a hash chain proves about an audit log, what it cannot prove on its own, and how to check Santati's chain without trusting Santati.]]></summary>
        <content type="html"><![CDATA[<p>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.</p>
<p>"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.</p>
<!-- -->
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="append-only-is-a-promise-not-a-proof">Append-only is a promise, not a proof<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#append-only-is-a-promise-not-a-proof" class="hash-link" aria-label="Direct link to Append-only is a promise, not a proof" title="Direct link to Append-only is a promise, not a proof" translate="no">​</a></h2>
<p>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.</p>
<p>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.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="one-hash-per-event-each-covering-the-last">One hash per event, each covering the last<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#one-hash-per-event-each-covering-the-last" class="hash-link" aria-label="Direct link to One hash per event, each covering the last" title="Direct link to One hash per event, each covering the last" translate="no">​</a></h2>
<p>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.</p>
<div class="language-python codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:oklch(0.955 0.010 240);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-python codeBlock_bY9V thin-scrollbar" style="background-color:oklch(0.955 0.010 240);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token keyword" style="color:hsl(301, 63%, 40%)">import</span><span class="token plain"> hashlib</span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">import</span><span class="token plain"> json</span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">def</span><span class="token plain"> </span><span class="token function" style="color:hsl(221, 87%, 60%)">seal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">record</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"> </span><span class="token builtin" style="color:hsl(119, 34%, 47%)">dict</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> prev_hash</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"> </span><span class="token builtin" style="color:hsl(119, 34%, 47%)">str</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"> </span><span class="token operator" style="color:hsl(221, 87%, 60%)">-</span><span class="token operator" style="color:hsl(221, 87%, 60%)">&gt;</span><span class="token plain"> </span><span class="token builtin" style="color:hsl(119, 34%, 47%)">str</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    body </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> json</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">dumps</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">{</span><span class="token operator" style="color:hsl(221, 87%, 60%)">**</span><span class="token plain">record</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">"prev_hash"</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"> prev_hash</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">}</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> sort_keys</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token boolean" style="color:hsl(35, 99%, 36%)">True</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> separators</span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token string" style="color:hsl(119, 34%, 47%)">","</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">":"</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">return</span><span class="token plain"> hashlib</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">sha256</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">body</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">encode</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">hexdigest</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain" style="display:inline-block"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">chain</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> prev_hash </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">[</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">]</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">""</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain"></span><span class="token keyword" style="color:hsl(301, 63%, 40%)">for</span><span class="token plain"> record </span><span class="token keyword" style="color:hsl(301, 63%, 40%)">in</span><span class="token plain"> records</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">:</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    prev_hash </span><span class="token operator" style="color:hsl(221, 87%, 60%)">=</span><span class="token plain"> seal</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">record</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">,</span><span class="token plain"> prev_hash</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">    chain</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">.</span><span class="token plain">append</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">(</span><span class="token plain">prev_hash</span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">)</span><br></div></code></pre></div></div>
<p>This code shows the idea; it is not Santati's canonical form, which hashes a defined record
layout.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="what-tampering-looks-like">What tampering looks like<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#what-tampering-looks-like" class="hash-link" aria-label="Direct link to What tampering looks like" title="Direct link to What tampering looks like" translate="no">​</a></h2>
<p>Verification recomputes every digest in order and compares links. Each kind of edit produces
its own failure:</p>
<table><thead><tr><th>What someone does</th><th>What verification reports</th></tr></thead><tbody><tr><td>Edits a stored event</td><td><code>hash_mismatch</code>: the stored digest no longer recomputes</td></tr><tr><td>Deletes an event</td><td><code>seq_gap</code>: a position is missing</td></tr><tr><td>Re-points an event at a different predecessor</td><td><code>prev_hash_mismatch</code>: the link to the previous position is wrong</td></tr></tbody></table>
<p>Verification stops at the first failing position, so a report names the earliest break, not
the newest edit.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="how-santati-chains-a-trail">How Santati chains a trail<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#how-santati-chains-a-trail" class="hash-link" aria-label="Direct link to How Santati chains a trail" title="Direct link to How Santati chains a trail" translate="no">​</a></h2>
<p>Each trail has its own chain, so one trail's verification never depends on another's. A
sealed event has a position <code>seq</code> and a <code>hash</code>: a SHA-256 digest over a canonical JSON record
that includes the previous event's digest. <code>hash</code> is on every event the read API returns and
is empty until the event is sealed.</p>
<p>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 <code>unsealed</code> (it is waiting for
its seal task), and an imported (backfilled) row is outside the chain by construction and
counted as <code>backfilled</code>.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="check-it-without-trusting-us">Check it without trusting us<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#check-it-without-trusting-us" class="hash-link" aria-label="Direct link to Check it without trusting us" title="Direct link to Check it without trusting us" translate="no">​</a></h2>
<p>Verification is a read, so any team API key works:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-background-color:oklch(0.955 0.010 240);--prism-color:hsl(230, 8%, 24%)"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="background-color:oklch(0.955 0.010 240);color:hsl(230, 8%, 24%)"><code class="codeBlockLines_e6Vv"><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token function" style="color:hsl(221, 87%, 60%)">curl</span><span class="token plain"> </span><span class="token parameter variable" style="color:hsl(221, 87%, 60%)">-sS</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">"https://api.santati.io/api/v0/events/chain/verify/?trail=billing&amp;from=2026-09-29T00:00:00Z"</span><span class="token plain"> </span><span class="token punctuation" style="color:hsl(119, 34%, 47%)">\</span><span class="token plain"></span><br></div><div class="token-line" style="color:hsl(230, 8%, 24%)"><span class="token plain">  </span><span class="token parameter variable" style="color:hsl(221, 87%, 60%)">-H</span><span class="token plain"> </span><span class="token string" style="color:hsl(119, 34%, 47%)">"Authorization: Api-Key </span><span class="token string variable" style="color:hsl(221, 87%, 60%)">$SANTATI_API_KEY</span><span class="token string" style="color:hsl(119, 34%, 47%)">"</span><br></div></code></pre></div></div>
<p>Leave <code>to</code> unset to verify from <code>from</code> to the chain head.</p>
<p>The call answers <code>200</code> for a broken chain too, so branch on <code>status</code>, not on the HTTP code.
The response's <code>report_url</code> is a gzip JSON artifact, downloadable for 24 hours without an API
key, with one entry per event carrying <code>digest_input</code>: 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 <a class="" href="https://docs.santati.io/integrity/chain-verification/#verify-the-artifact-yourself">no reimplementation of the canonicalisation</a>.
The response also carries <code>artifact_sha256</code> and <code>artifact_bytes</code>, 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.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="what-a-chain-cannot-prove-alone">What a chain cannot prove alone<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#what-a-chain-cannot-prove-alone" class="hash-link" aria-label="Direct link to What a chain cannot prove alone" title="Direct link to What a chain cannot prove alone" translate="no">​</a></h2>
<p>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 <code>head.seq</code> and <code>head.hash</code> 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 <code>seq</code> and that <code>hash</code>.</p>
<p><code>head.tail_verified</code> 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.</p>
<p>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.</p>
<h2 class="anchor anchorTargetStickyNavbar_Vzrq" id="try-it">Try it<a href="https://docs.santati.io/blog/hash-chain-tamper-evident-audit-log/#try-it" class="hash-link" aria-label="Direct link to Try it" title="Direct link to Try it" translate="no">​</a></h2>
<p>Send a few events to a trail and verify the chain yourself: <a class="" href="https://docs.santati.io/quickstart/">Quickstart</a>, then
<a class="" href="https://docs.santati.io/integrity/chain-verification/">Chain verification</a>.</p>]]></content>
        <author>
            <name>Santati</name>
            <uri>https://santati.io/</uri>
        </author>
    </entry>
</feed>