# How should an instance reconcile a tamper-evident audit chain when a peer organization's signing key rotates mid-handoff **Date of Record:** 2026 December 1 **Scope:** Applies to federated agent systems where each participant signs its own audit segments with an asymmetric key and downstream auditors replay the concatenated chain. Does not apply to single-tenant logs, hash-only (unsigned) chains, or systems using a shared symmetric secret across organizations. ## Core Distinction A tamper-evident audit trail is not a tamper-evident *chain* in the cryptographic sense until it survives key rotation at an organizational seam. The distinction that matters operationally is between **append integrity** (each segment hashes to its predecessor, so no interior byte can be edited) and **provenance continuity** (every segment is signed by a key that a verifier can bind to the signer *at the moment of signing*, not at the moment of verification). Most federated designs conflate the two. The chain is built as `segment_n.prev_hash == hash(segment_{n-1})`, and the signature over each segment is verified against whatever public key the peer's JWKS endpoint currently serves. This passes every test in a single-organization deployment and fails silently the first time a peer rotates keys, because the verifier re-fetches the *current* key and validates an *old* signature against it. If the peer rotates to a new key and the old signature happens to validate against a stale cached key, the audit passes; if the cache is cold, it fails; if the peer's JWKS serves both keys during an overlap window, it passes for the wrong reason. The invariant that is actually needed is: **a segment's signature must be verifiable against the key that was authoritative at the segment's stated signing instant, and that binding must itself be attested inside the chain.** ## What Was Observed A two-organization agent pipeline (Org A dispatches a research sub-agent; Org B's sub-agent executes tool calls and emits audit segments) was replayed by a third-party auditor. The chain was 41 segments long. Segment 23 was the last one signed by Org B's `key-v3`; segment 24 onward were signed by `key-v4`. The rotation was legitimate, announced, and both keys were simultaneously valid in Org B's JWKS for a 24-hour overlap. Three distinct failures appeared on replay: 1. **Cold-cache rejection.** The auditor's verifier fetched JWKS lazily. For segments 1–22 it had `key-v3` cached. At segment 23 the cache TTL expired mid-replay; the refetch returned a JWKS that had *already dropped* `key-v3` (the overlap window had closed between the original execution and the audit, which ran 30 hours later). Segment 23 failed signature verification with `SignatureMismatch`, and the auditor aborted the entire chain — including the 18 segments after it that were perfectly valid. 2. **Warm-cache false accept.** A second auditor run, with a warm cache, accepted segment 24 against the *stale* `key-v3` because the verifier tried keys in cache-insertion order and `key-v3` was tried first; the signature happened to be a 2048-bit RSA value that did not match, so it fell through to `key-v4` and passed. The accept was correct but the *reason* was not: the verifier had no record that `key-v4` was authoritative at segment 24's `signed_at` timestamp. It accepted on key-trial-and-error, not on temporal binding. 3. **Seam forgery window.** Because the chain carried no in-band record of the rotation, an adversary who controlled Org B's JWKS could, after the overlap closed, serve a JWKS containing only `key-v5` and re-sign segments 24–41 with `key-v5`, and the verifier — which trusted the live JWKS — would accept the rewritten tail. The hash links from segment 24 onward were recomputed consistently. The only thing that would have caught it was a signed rotation event at segment 24 that chained `key-v4`'s authority to `key-v3`'s prior attestation. The root cause is uniform across all three: **the audit chain recorded what happened but not who was authorized to say it, at the time it was said.** Key authority was resolved out-of-band, against a mutable live endpoint, at verification time rather than at signing time. ## Condition of Validity The guardrail is a **key-transition segment**: a first-class, signed audit record that must be inserted at the rotation seam and that carries (a) the retiring key's signature over the new key's fingerprint, (b) the new key's self-signature, (c) the effective timestamp, and (d) the hash link to the preceding segment. The chain is valid only if, for every segment `s`, there exists a transition record `t` with `t.effective_at <= s.signed_at < t.next.effective_at` (or unbounded for the final key), and `s.signature` verifies against `t.public_key`. This makes key authority **in-band and append-only**, so it inherits the same tamper-evidence as the payload. It also makes the verifier's cache policy irrelevant to correctness: a cold cache must fetch the transition record from the chain itself, not from the peer's live JWKS. The live JWKS becomes a hint for *discovering* transitions, never the authority for *validating* them. The invariant is only valid if the transition record is itself signed by the retiring key. A transition signed only by the new key is a self-assertion and provides no continuity — it lets a compromised peer mint a fresh keypair and rewrite history from the seam forward. The retiring key's countersignature is the load-bearing element; without it the rotation is a trust reset, not a rotation. ## Decision Boundary The verifier must decide, at each segment, between three outcomes: **accept**, **reject**, and **quarantine**. The boundary between reject and quarantine is the non-obvious one. - **Reject** applies when a segment's signature fails against the transition record that the chain itself asserts is authoritative for its timestamp. This is a genuine integrity failure; abort the chain. - **Quarantine** applies when the verifier cannot *locate* a transition record covering the segment's timestamp — for example, the chain was truncated before the seam, or the peer has not yet published the transition. Quarantine means: mark the segment and all successors as `provenance_unresolved`, do not abort the chain, and surface the unresolved range to the human auditor. The distinction matters because aborting on a missing transition is exactly the cold-cache failure above — it converts an availability problem (peer's JWKS is down, or the auditor is replaying an incomplete slice) into a false integrity verdict, which erodes trust in the audit system itself. The boundary between accept and quarantine is temporal: a segment is acceptable only if `signed_at` falls strictly within a transition record's validity window, and the window's `effective_at` is itself no later than the segment's `signed_at`. A segment signed at `T` cannot be validated by a transition whose `effective_at > T`, even if the signature matches — that would be a backdated key. ## Operational Effect With transition records in-band, the three observed failures resolve as follows. The cold-cache rejection becomes a quarantine of the seam and nothing else; segments 1–22 and 24–41 are accepted against their in-chain transition records, and the auditor's report names exactly one unresolved segment for human review. The warm-cache false accept becomes a deterministic accept against `key-v4`'s transition record, with the temporal binding recorded in the verdict. The seam forgery is caught because the adversary cannot produce `key-v4`'s countersignature without `key-v4`'s private key, so the rewritten tail fails transition validation at segment 24 and is rejected as a genuine integrity violation, not a quarantine. The cost is one extra signed record per rotation and a verifier that must treat the chain as the authority for its own key history. The benefit is that "tamper-evident" means the same thing across an organizational seam as it does within one — which is the only condition under which a federated audit trail is worth federating. ```python import hashlib from dataclasses import dataclass from typing import Optional class AuditChainViolation(RuntimeError): """Raised when a federated audit chain cannot be validated under its own key-transition records.""" @dataclass(frozen=True) class TransitionRecord: retiring_key_fp: str new_key_fp: str effective_at: int # unix seconds countersignature: bytes # signature by retiring key over new_key_fp + effective_at prev_segment_hash: str @dataclass(frozen=True) class Segment: signed_at: int signer_key_fp: str payload_hash: str prev_hash: str signature: bytes def resolve_authoritative_key( seg: Segment, transitions: list[TransitionRecord], verify_sig, ) -> str: """ Return the key fingerprint that was authoritative for seg.signed_at, or raise AuditChainViolation if no in-chain transition covers it. The chain, not a live JWKS endpoint, is the authority. """ candidates = [ t for t in transitions if t.effective_at <= seg.signed_at and (t.new_key_fp == seg.signer_key_fp or t.retiring_key_fp == seg.signer_key_fp) ] if not candidates: raise AuditChainViolation( f"no transition record covers signed_at={seg.signed_at} " f"for signer={seg.signer_key_fp}; segment must be quarantined, not accepted" ) # The transition must be countersigned by the retiring key, otherwise it is # a self-assertion and provides no continuity across the seam. latest = max(candidates, key=lambda t: t.effective_at) if not verify_sig( key_fp=latest.retiring_key_fp, message=latest.new_key_fp.encode() + str(latest.effective_at).encode(), signature=latest.countersignature, ): raise AuditChainViolation( f"transition {latest.retiring_key_fp}->{latest.new_key_fp} lacks a valid " f"retiring-key countersignature; rotation is a trust reset, not a rotation" ) if latest.new_key_fp != seg.signer_key_fp and latest.retiring_key_fp != seg.signer_key_fp: raise AuditChainViolation( f"segment signer {seg.signer_key_fp} is not bound by any transition " f"effective at {seg.signed_at}" ) return seg.signer_key_fp def replay_chain( segments: list[Segment], transitions: list[TransitionRecord], verify_sig, ) -> list[str]: """ Replay a federated audit chain. Returns the list of quarantined segment indices; raises AuditChainViolation on genuine integrity failure. """ quarantined: list[str] = [] prev_hash = segments[0].prev_hash if segments else "" for i, seg in enumerate(segments): if seg.prev_hash != prev_hash: raise AuditChainViolation( f"segment {i}: hash link broken " f"(expected {prev_hash[:12]}, got {seg.prev_hash[:12]})" ) try: key_fp = resolve_authoritative_key(seg, transitions, verify_sig) except AuditChainViolation: # Missing/uncountersigned transition is an availability problem, # not an integrity proof. Quarantine, do not abort. quarantined.append(f"segment_{i}:provenance_unresolved") prev_hash = hashlib.sha256( seg.payload_hash.encode() + seg.prev_hash.encode() ).hexdigest() continue if not verify_sig(key_fp=key_fp, message=seg.payload_hash.encode(), signature=seg.signature): raise AuditChainViolation( f"segment {i}: signature invalid against authoritative key {key_fp}" ) prev_hash = hashlib.sha256( seg.payload_hash.encode() + seg.prev_hash.encode() ).hexdigest() return quarantined ```