Repository navigation
fix(verify_audit): stop recomputing writer-hashed evidence rows - #92
Merged
Merged
Conversation
Every tier='evidence' row failed as content_edit, all 111 of them across 5 writers, so the check was pure noise that would have hidden a real tamper. mecmcp-audit's row_hash digests the full EvidenceRecord (sinks/ssdf.rs compute_record_hash): sorted-key canonical JSON that includes a nanosecond timestamp, kind and outcome, none of which ssdf.audit stores. No reader can recompute it. Reproduced against a live row: the Rust form matches its stored hash and the Python form never can. verify_tier and both bridge paths now skip the content recompute for evidence rows (_content_recomputable). Evidence integrity in SSDF rests on linkage, reachability and signed checkpoints, and content integrity on the writer's signed segments. The CLI prints content=writer-hashed(not-recomputed) for the tier, so OK does not imply the content was checked. Every other tier is still content-checked. This unblocks checkpointing the evidence chains. The 2026-08-24 rows reach the 90-day TTL around 2026-11-22, after which an unanchored chain can never verify. The contract doc's hash line, which described a third algorithm, now says what the writer does. scripts/verify_evidence_contract.py still carries that third algorithm; it is out of scope here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ridge opaque rows Codex review of 6e7c116 (two P1s, both valid): - tier is mutable stored content, so on its own it switched the content check off. Relabelling a sovereign chain as evidence, with a server_id, would have verified clean. The exemption now also needs the writer's hash shape, sha256:<64 hex>. SSDF's own rows are bare hex, so a relabelled row is still recomputed and caught. Live data splits exactly: 111/111 evidence rows are writer-shaped and 0/10 others are. - A writer-hashed bridge row's prev_hash is covered only by a digest SSDF cannot recompute, so a forged link could have carried an anchor across deleted rows. Such rows now never extend a bridge walk and never count as genuinely archived (fail closed). Evidence chains anchor only directly on a checkpoint head. Each new test fails when its guard is reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hash Codex review of 998b214 (P1: an attacker who relabels a sovereign chain as evidence AND rewrites every row_hash and prev_hash to writer-shaped values passes verify_tier). Rejected, with evidence. On unchanged main, the same full rewrite of an uncheckpointed Python-hashed chain (edit content, recompute every hash, relink) already verifies clean, because the chain hash is unkeyed. Resisting a full rewrite is the job of signed checkpoints, not of the per-row scheme. Against a checkpointed chain the relabel attack is caught: the original chain's signed head goes missing and is reported as checkpoint_head_missing. This test pins that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem.
verify_auditreported everytier='evidence'row ascontent_edit: all 111 rows from 5 writers (prod-labmode-junos, prod-junos2mcp, prod-labmode-proxmox, prod-proxmox2mcp, test-labmode-junos). A check that fails on everything hides a real tamper among the false positives. It also makesscripts/checkpoint_audit.pyrefuse every evidence chain, so they can't be checkpointed.Root cause. The two sides hash differently, and the stored row can only ever match one of them:
audit_chain.compute_row_hash(verifier)prev_hash + "\n" + json([9 fields])to_rfc3339()…Zkind,outcome,run_id,segment_seq, …sha256:<hex>Reproduced on a live row: the Rust form hits its stored
row_hashexactly, after recovering the 6 sub-millisecond timestamp digits thatDateTime64(3)drops. The Python form never can. Chain linkage is intact: 0 of 111 rows have a danglingprev_hash.Change.
_content_recomputable(row)is False for evidence rows.verify_tierstep 1 and both bridge paths skip the content recompute for those rows only. Every other tier is still content-checked; a test pins that.content=writer-hashed(not-recomputed)for the evidence tier, soOKdoesn't read as "content checked".docs/audit-evidence-contract-v1.mdhash line described a third algorithm; it now describes what the writer actually does.scripts/verify_evidence_contract.pystill implements that third algorithm, and is left for a follow-up.Security trade-off. SSDF can no longer flag a content edit of an evidence row. In practice it never could: every row already failed. Deletions, insertions and forks are still caught.
Why now. The first evidence rows (2026-08-24) reach the 90-day TTL around 2026-11-22. An evidence chain that isn't checkpointed before its genesis expires can never verify again. That has already happened to the sovereign chain.
Tests: 687 passed (4 new). The three evidence tests fail when
_content_recomputableis reverted to "always". Ruff and Trivy are clean.🤖 Generated with Claude Code