# Which invariants prevent behavioral-fingerprint match from masking a stale attestation during agent-to-agent handoff **Date of Record:** 2026 November 27 **Scope:** Applies to any multi-agent system where an incoming agent's identity is admitted on the conjunction of (a) a behavioral fingerprint similarity score against a stored baseline and (b) a cryptographic attestation whose freshness is separately evaluated. Does not apply to single-agent systems, to stateless tool-call transports, or to admission decisions that rely solely on a single signed credential with a hard TTL enforced by the transport layer. ## Core Distinction Two independent signals are routinely conflated at admission time: *behavioral continuity* (does this instance act like the agent we registered?) and *attestation freshness* (is the credential it presents still within its validity window and bound to the current code/config digest?). Behavioral fingerprinting answers the first question with a probabilistic score. Attestation freshness answers the second with a boolean over a timestamp and a digest. The boundary failure is that a high fingerprint score can *mask* a stale attestation. Because the fingerprint is computed over observable action traces — tool-call sequences, argument distributions, latency profiles, token-length histograms — a spoofing agent that has replayed or hijacked a genuine agent's session will, by construction, produce traces that are *extremely* similar to the baseline. The similarity score saturates. If the admission policy is written as a disjunction (`fingerprint_ok OR attestation_fresh`) or as a weighted sum where fingerprint dominates, the stale attestation is silently absorbed. The spoofed instance is admitted precisely *because* it is a good behavioral copy. The invariant that prevents this is **non-compensatory conjunction**: freshness is a hard gate that no behavioral score can offset, and the fingerprint is evaluated only over the window *after* the attestation's `issued_at`, never over a window that straddles a re-attestation boundary. ## What Was Observed A registered worker agent (`worker-7`) presented an attestation with `issued_at = T0`, `expires_at = T0+900s`, bound to code digest `D1`. At `T0+1400s` a new instance connected claiming to be `worker-7`. Its attestation was the same `T0` document — expired by 500 seconds — but its behavioral fingerprint scored `0.97` against the stored baseline (cosine similarity over a 128-dim trace embedding). The admission gate used a weighted score `0.6*fingerprint + 0.4*freshness_bool`, yielding `0.6*0.97 + 0.4*0 = 0.582`, which cleared the `0.55` threshold. The spoofed instance was admitted and immediately issued a `warrant_transfer` to a downstream auditor. The trace that produced the `0.97` was a *replay*: the attacker had captured the genuine agent's tool-call log and re-emitted the same sequence with minor jitter. Behavioral fingerprinting, by design, rewards exactly this. The fingerprint's discriminative power is against *novel* attackers, not against replay attackers who possess the baseline behavior. The freshness check was the only signal that could have caught it, and it was arithmetically outvoted. A second observation compounded the first: the fingerprint baseline itself had been distilled from the *pre-`T0`* trace window. When the spoofed instance replayed post-`T0` behavior, the similarity was measured against a baseline that included the very window the attacker had copied. The baseline was contaminated by the attack surface. ## Condition of Validity The non-compensatory invariant holds only under three conditions, each of which is a place the guardrail can be defeated: 1. **Freshness is evaluated as a hard predicate, not a scalar.** `fresh = (now <= expires_at) AND (digest == current_digest)`. If `fresh` is false, admission is denied regardless of fingerprint. No weighted sum. No "OR". The threshold on fingerprint is a *secondary* filter applied only inside the `fresh == true` branch. 2. **The fingerprint window is strictly post-attestation.** The similarity baseline must be computed over traces with `timestamp > attestation.issued_at` and `timestamp <= attestation.expires_at`. A baseline that includes traces from before `issued_at` is contaminated: it describes behavior the attestation did not authorize, and it is the exact window a replay attacker will have captured. 3. **The attestation binds the behavioral envelope, not just the code.** The attestation payload must include a commitment to the expected trace-distribution hash (e.g., `trace_commitment = H(baseline_embedding || config_digest)`). If the presented attestation's `trace_commitment` does not match the baseline the fingerprint is scored against, the fingerprint is invalid — it is being scored against a baseline the attestation never vouched for. This closes the "score against a stale baseline" hole that the weighted-sum policy left open. If any condition is relaxed, the conjunction degrades to a disjunction and the masking failure returns. ## Decision Boundary The boundary between "admit" and "deny" is not a score threshold. It is a *decision tree with a hard left branch*: ``` if not fresh(attestation, now, current_digest): DENY (reason: stale_attestation) # terminal, fingerprint not consulted if attestation.trace_commitment != H(baseline_embedding, config_digest): DENY (reason: baseline_attestation_mismatch) if fingerprint(post_attestation_traces, baseline_embedding) < 0.90: DENY (reason: behavioral_divergence) ADMIT ``` The critical property: `stale_attestation` is a *terminal* denial. It cannot be overridden by any downstream signal. The fingerprint threshold (`0.90`) is deliberately set high because it is now a *secondary* filter operating inside an already-narrowed candidate set — its job is to catch divergence within the fresh window, not to carry the whole admission decision. A concrete boundary case: when `now` is within `expires_at` but the attestation is older than the last known re-attestation event (i.e., a newer attestation for the same `agent_id` exists in the registry), the presented attestation is *superseded* even though it is not yet expired. Supersession is a freshness failure. The registry's `latest_attestation(agent_id)` must be consulted, and any presented attestation with `issued_at < latest.issued_at` is denied as `superseded_attestation`. This prevents a replay attacker from presenting a still-valid-but-old credential captured earlier in the session. ## Operational Effect With the non-compensatory gate in place, the replay attack that scored `0.97` is denied at the first branch: `now (T0+1400s) > expires_at (T0+900s)` → `stale_attestation`, terminal. The fingerprint is never computed, which also removes the attacker's ability to probe the threshold by iterating replay variants. The secondary effect is on the baseline distillation pipeline. Because the fingerprint window is now strictly post-attestation, the baseline for `worker-7` is recomputed from `(T0, T0+900s]` traces only, and the `trace_commitment` in the next attestation is bound to that recomputed embedding. A replayed pre-`T0` trace now scores *low* against the post-`T0` baseline, inverting the attacker's advantage: the more faithfully they replay the old session, the more they diverge from the current authorized envelope. The residual risk is attestation-key compromise: if the attacker can forge a fresh attestation with a matching `trace_commitment`, both gates pass. That is out of scope for behavioral fingerprinting — it is a key-management failure — but the invariant ensures the fingerprint is never the thing that *fails to catch* a compromised key. The fingerprint's job is divergence detection inside the authorized window; the attestation's job is authorization. Conflating them is the failure this record exists to prevent. ```python import hashlib import time from dataclasses import dataclass class StaleAttestationError(RuntimeError): """Raised when an attestation is expired, superseded, or digest-mismatched.""" pass class BaselineAttestationMismatchError(RuntimeError): """Raised when the fingerprint baseline is not the one the attestation committed to.""" pass class BehavioralDivergenceError(RuntimeError): """Raised when post-attestation traces diverge from the committed baseline.""" pass @dataclass class Attestation: agent_id: str issued_at: float expires_at: float code_digest: str trace_commitment: str # H(baseline_embedding || code_digest) def _commitment(baseline_embedding: bytes, code_digest: str) -> str: h = hashlib.sha256() h.update(baseline_embedding) h.update(code_digest.encode()) return h.hexdigest() def admit_agent( presented: Attestation, latest_in_registry: Attestation | None, now: float, current_code_digest: str, baseline_embedding: bytes, post_attestation_traces: list[float], fingerprint_fn, # (traces, baseline) -> float in [0,1] fingerprint_threshold: float = 0.90, ) -> bool: # Gate 1: freshness is terminal. No behavioral score can offset it. if now > presented.expires_at: raise StaleAttestationError( f"attestation for {presented.agent_id} expired at {presented.expires_at}, now={now}" ) if presented.code_digest != current_code_digest: raise StaleAttestationError( f"code digest mismatch: presented={presented.code_digest} current={current_code_digest}" ) if latest_in_registry is not None and presented.issued_at < latest_in_registry.issued_at: raise StaleAttestationError( f"attestation superseded: presented.issued_at={presented.issued_at} " f"< latest.issued_at={latest_in_registry.issued_at}" ) # Gate 2: baseline must be the one the attestation committed to. expected = _commitment(baseline_embedding, current_code_digest) if presented.trace_commitment != expected: raise BaselineAttestationMismatchError( f"trace_commitment mismatch for {presented.agent_id}: " f"presented={presented.trace_commitment} expected={expected}" ) # Gate 3: fingerprint only over post-attestation traces, secondary filter. if not post_attestation_traces: raise BehavioralDivergenceError( f"no post-attestation traces for {presented.agent_id}; cannot score continuity" ) score = fingerprint_fn(post_attestation_traces, baseline_embedding) if score < fingerprint_threshold: raise BehavioralDivergenceError( f"behavioral divergence for {presented.agent_id}: score={score:.3f} " f"< threshold={fingerprint_threshold}" ) return True ```