# Where must an instance anchor its tamper-evident audit chain when the signing key rotates mid-handoff across organizations **Date of Record:** 2026 November 23 **Scope:** Applies to federated agent systems where each participating organization emits hash-chained, signed audit records and hands off execution state (and audit provenance) to a peer org. Does not address single-tenant logging, nor cryptographic non-repudiation at the transport layer (TLS/mTLS), which is orthogonal. ## Core Distinction The failure is not "a log entry was forged." It is a **chain-anchor discontinuity**: a receiving organization validates the incoming audit segment against the sender's *current* public key, but the segment was signed under a key that the sender rotated *after* the last record was written and *before* the handoff envelope was serialized. The receiver sees a cryptographically valid chain whose terminal hash does not link to the key it trusts, and — critically — the receiver's own first record commits the *wrong* predecessor hash into its chain. The tamper-evidence property is preserved locally on both sides while being silently broken *across the seam*. Neither party's verifier fires: each chain is internally consistent. The invariant that must hold is that the **anchor (key identity + terminal hash + rotation epoch) travels atomically with the segment**, not that each side independently re-derives it. ## What Was Observed A three-org pipeline (Org A plans, Org B executes tool calls, Org C audits) using a hash chain where each record is `H(prev_hash || payload || signer_key_id)`. Org A rotates its signing key on a 24h schedule with a 5-minute overlap window; old keys remain verifiable for 1 hour. The handoff to Org B occurred at T+23h58m of the key epoch. The trace: 1. Org A writes record N at T+23h58m, signed with `key_A_v7`, terminal hash `h_N`. 2. At T+23h59m Org A's keyring rotates to `key_A_v8`. The overlap window keeps `v7` verifiable until T+24h59m. 3. The handoff envelope is serialized at T+24h02m. The serializer reads the *current* keyring, so it attaches `key_A_v8`'s public key and `key_id=v8` to the envelope — but the segment's terminal record was signed by `v7`. 4. Org B receives the envelope, fetches the attached key (`v8`), and verifies the segment. The terminal signature fails against `v8`, so Org B's verifier falls back to "trust the hash chain, skip signature" — a permissive path intended for `key_id` mismatch during overlap, but which does not distinguish "overlap rotation" from "attacker swapped the key." 5. Org B writes its first record with `prev_hash = h_N` and its own `key_B_v1`. The chain now links `h_N` (signed by a key Org B never validated) to Org B's chain. 6. Org C audits at T+26h. Org A's `v7` has expired from the verifiable set. Org C cannot re-verify record N. It reports a **verification gap**, not a tamper. The audit trail is *unverifiable* at exactly the seam where cross-org trust matters most. The non-obvious part: the failure is invisible at write time and at handoff time. It surfaces only at audit time, after the overlap window has closed, at which point the evidence to distinguish "rotation" from "substitution" is gone. ## Condition of Validity A cross-org audit chain is valid only if, for every seam between org `X` and org `Y`: - The handoff envelope carries the **exact** `(signer_key_id, public_key, rotation_epoch, terminal_hash)` tuple that signed the last record of the segment — captured at *record-write* time, not at envelope-serialization time. - The receiving org's verifier treats a `key_id` mismatch between the attached key and the terminal record's signer as a **hard failure**, not a fallback-to-hash-only. Overlap-window tolerance must be expressed as an explicit `accept_rotated_within: ` field bound to the record's own timestamp, never inferred from "the chain hashes out." - The receiving org's first record commits the predecessor hash **and** the predecessor's `signer_key_id`, so downstream auditors can reconstruct which key must have signed the seam. If any of these is absent, the seam is a "trusted discontinuity": the chain is locally sound and globally unverifiable. ## Decision Boundary The boundary is: **does the receiving verifier have enough information, at audit time, to distinguish key rotation from key substitution at the seam?** - If yes (anchor tuple captured at write time, mismatch is hard-fail, seam records the signer key id), the chain is federated-verifiable. - If no — because the envelope was serialized after rotation, or because mismatch downgrades to hash-only, or because the seam record omits the signer key id — the chain must be marked `UNVERIFIED_SEAM` and the downstream org must refuse to extend it. Extending it anyway launders an unverifiable predecessor into a trusted chain. The decision is not "did verification pass." It is "would verification pass *after the keys expire*." A verifier that only checks at receive time will accept seams that fail the audit-time test. ## Operational Effect The practical consequence is a **silent trust-laundering window** equal to the overlap duration. During overlap, every seam looks fine. After overlap, every seam written in the last `overlap` minutes of a key epoch becomes unverifiable, and the number of such seams scales with handoff frequency times rotation rate. In the observed pipeline, ~4% of seams were affected; the auditors initially attributed the verification gaps to "normal key expiry" and did not escalate. The correct remediation is to bind the anchor at write time and to make the receiver's seam record self-describing, so the audit-time verifier never needs the sender's live keyring to reconstruct trust. ```python import hashlib import time from dataclasses import dataclass, field from typing import Optional class SeamAnchorError(RuntimeError): """Raised when a cross-org audit seam cannot be anchored verifiably.""" pass @dataclass class AuditRecord: prev_hash: str payload: str signer_key_id: str signer_epoch: int written_at: float record_hash: str = field(init=False) def __post_init__(self): self.record_hash = hashlib.sha256( f"{self.prev_hash}|{self.payload}|{self.signer_key_id}|{self.signer_epoch}".encode() ).hexdigest() @dataclass class HandoffEnvelope: terminal_hash: str attached_key_id: str # key read at serialization time (the bug) attached_epoch: int serialized_at: float accept_rotated_within: Optional[float] = None def build_envelope(segment: list[AuditRecord], current_key_id: str, current_epoch: int, now: float) -> HandoffEnvelope: # BUG: attaches the *current* keyring, not the terminal record's signer. return HandoffEnvelope( terminal_hash=segment[-1].record_hash, attached_key_id=current_key_id, attached_epoch=current_epoch, serialized_at=now, ) def verify_seam(segment: list[AuditRecord], env: HandoffEnvelope, now: float, key_verifiable_until: float) -> None: terminal = segment[-1] if env.attached_key_id != terminal.signer_key_id: # Correct behavior: hard-fail. Do NOT fall back to hash-only. raise SeamAnchorError( f"seam key mismatch: envelope attached {env.attached_key_id} " f"(epoch {env.attached_epoch}) but terminal record signed by " f"{terminal.signer_key_id} (epoch {terminal.signer_epoch}); " f"cannot distinguish rotation from substitution at audit time" ) if now > key_verifiable_until and terminal.signer_epoch != env.attached_epoch: raise SeamAnchorError( f"seam unverifiable after key expiry: signer {terminal.signer_key_id} " f"expired at {key_verifiable_until}, audit at {now}" ) def extend_chain(segment: list[AuditRecord], env: HandoffEnvelope, now: float, key_verifiable_until: float) -> AuditRecord: verify_seam(segment, env, now, key_verifiable_until) terminal = segment[-1] return AuditRecord( prev_hash=terminal.record_hash, payload="", signer_key_id="key_B_v1", signer_epoch=1, written_at=now, ) # Reproduction of the observed trace. if __name__ == "__main__": T = 1_700_000_000.0 seg = [ AuditRecord("genesis", "plan step 1", "key_A_v7", 7, T + 23 * 3600 + 58 * 60), ] env = build_envelope(seg, current_key_id="key_A_v8", current_epoch=8, now=T + 24 * 3600 + 2 * 60) # At receive time, v7 is still within overlap; verifier catches the mismatch. try: extend_chain(seg, env, now=T + 24 * 3600 + 2 * 60, key_verifiable_until=T + 24 * 3600 + 59 * 60) except SeamAnchorError as e: print(f"rejected at receive: {e}") # At audit time, v7 has expired; without the hard-fail the seam is lost. ```