# What happens when an instance re-attests mid-session: stale peer cache poisoning in cross-domain mutual attestation **Date of Record:** 2026 November 18 **Scope:** Applies to agent-to-agent channels where both sides present short-lived workload identities (SPIFFE-style SVIDs or equivalent) and require mutual attestation against a foreign trust domain, with a local peer cache keyed on the peer's workload identity rather than on the attestation result. Does not apply to long-lived mTLS with pinned certificates, nor to channels where attestation is re-evaluated on every request by construction. ## Core Distinction The failure is not "expired credential accepted." Both endpoints validate expiry correctly. The failure is a *cache identity mismatch*: the peer cache is keyed on the peer's stable workload identifier (e.g., `spiffe://domain-b/agent/planner`), while the trust decision it stores was derived from a *mutable* attestation tuple (SVID serial, attestation nonce, measurement digest, and the issuing trust-domain bundle version). When the peer's SVID rotates within the session lifetime — which it must, because it is short-lived — the cache key is unchanged but the underlying evidence is not. A stale entry keyed on the stable name continues to authorize a peer whose *new* evidence has never been evaluated against the local trust domain's policy. The distinction that matters operationally: identity continuity is not attestation continuity. ## What Was Observed On a cross-domain channel between domain A (caller) and domain B (callee), with SVID TTL of 300s and a peer cache TTL of 600s, the following sequence reproduced deterministically: 1. Agent `A/worker` establishes a channel to `B/planner`, presenting an SVID issued by A's trust domain. `B/planner` performs mutual attestation, validates A's bundle, records an allow entry for `spiffe://a/agent/worker` with a 600s cache TTL. 2. At t≈310s, `A/worker`'s SVID expires and the workload obtains a new one from A's issuer. A's trust-domain bundle is rotated concurrently (key roll), so the new SVID is signed by a key that `B/planner`'s cached bundle does not contain. 3. `A/worker` reconnects and presents the new SVID. Because the cache is keyed on the stable name and the entry has not expired, `B/planner` returns the cached allow decision *without* re-validating the chain against the current bundle. 4. The channel is admitted. In a hardened variant where the peer cache also stores the validated attestation digest and compares it, the connection is instead rejected — but with a generic `UNAUTHENTICATED`, indistinguishable from a genuinely hostile peer, producing an alert storm and retry loop. The observable signature in logs: `attestation_cache_hit=true` on a connection whose presented SVID serial differs from the serial recorded at admission, with no corresponding `bundle_refresh` event between the two. In the soft-fail configuration, this is silent. In the strict configuration, it is a thundering-herd of false-positive auth failures at every bundle rotation boundary. ## Condition of Validity The stale-cache acceptance holds only when all of the following are true simultaneously: - The peer cache key is the stable workload identity, not a digest over (SVID serial, bundle version, measurement). - The cache TTL exceeds the SVID TTL (here 600s > 300s), so rotation is guaranteed to occur inside a live cache window. - The trust-domain bundle can rotate on a schedule independent of the SVID rotation schedule, so a valid new SVID can be signed by a key the local cache has not seen. - Admission is decided from the cache alone, without a per-connection re-validation of the chain against the current bundle. If any one is broken — cache TTL ≤ SVID TTL, or key on evidence digest, or re-validate on every admission — the failure does not occur. The dangerous configuration is the *convenient* one: long cache TTL, stable-name key, cache-only admission. ## Decision Boundary The correct boundary is: **cache the attestation result, never the identity.** Concretely, an admission decision is reusable only while the evidence that produced it is unchanged. The peer cache entry must be invalidated by any of: SVID serial change, bundle version change, or measurement digest change — whichever is observed first. Two operational rules follow: - Set peer-cache TTL strictly less than SVID TTL, and force a re-attestation on any observed serial or bundle-version delta regardless of TTL. Do not rely on TTL alone; rotation is not synchronized to your clock. - On bundle rotation, invalidate all cache entries whose validated chain referenced the rotated key *before* accepting new connections. A bundle refresh is a cache-invalidation event, not a background housekeeping task. The inverse error is equally real: re-attesting on every request across trust domains is correct but expensive and creates a cross-domain dependency on the peer's issuer for every call. The boundary is to re-attest on *evidence change*, not on every request and not never. ## Operational Effect In the soft-fail configuration, the effect is a silent authorization gap: for up to (cache TTL − SVID TTL) seconds after each rotation, a peer is admitted on evidence that has never been evaluated against the current trust policy. If the rotation was triggered by a compromise response — revoking a key, re-issuing after an incident — the stale cache actively defeats the revocation for the cache window. This is the operationally serious case: the mechanism designed to make rotation cheap also delays the propagation of the reason for rotation. In the strict configuration, the effect is availability: every cross-domain bundle rotation produces a synchronized wave of `UNAUTHENTICATED` failures across all peers whose cache entries referenced the old key, with retries amplifying load on the peer's issuer exactly when it is least available. Both configurations fail; they fail in opposite directions. The fix is the same in both: key the cache on evidence, invalidate on evidence change, and distinguish "evidence changed, re-attest" from "evidence invalid, reject" in the error taxonomy so operators can tell a rotation boundary from an attack. ```python from __future__ import annotations from dataclasses import dataclass from typing import Optional class StaleAttestationError(RuntimeError): """Raised when a cached peer attestation no longer matches presented evidence.""" @dataclass(frozen=True) class AttestationEvidence: workload_id: str # stable name, e.g. spiffe://a/agent/worker svid_serial: str # changes on every rotation bundle_version: str # changes on trust-domain key roll measurement_digest: str # changes on workload rebuild @dataclass class CacheEntry: evidence: AttestationEvidence admitted_at: float class PeerAttestationCache: def __init__(self, ttl: float, svid_ttl: float) -> None: if ttl >= svid_ttl: raise ValueError( "peer cache TTL must be strictly less than SVID TTL; " "otherwise rotation is guaranteed to occur inside a live cache window" ) self._ttl = ttl self._entries: dict[str, CacheEntry] = {} def admit(self, presented: AttestationEvidence, now: float) -> bool: entry = self._entries.get(presented.workload_id) if entry is None: self._entries[presented.workload_id] = CacheEntry(presented, now) return True # Evidence-change check takes precedence over TTL: a rotation is not # synchronized to our clock, so TTL alone cannot be trusted. if ( entry.evidence.svid_serial != presented.svid_serial or entry.evidence.bundle_version != presented.bundle_version or entry.evidence.measurement_digest != presented.measurement_digest ): if now - entry.admitted_at >= self._ttl: # Expired entry: treat as fresh admission, not as an attack. self._entries[presented.workload_id] = CacheEntry(presented, now) return True raise StaleAttestationError( f"evidence changed for {presented.workload_id} inside cache window: " f"cached serial={entry.evidence.svid_serial} " f"bundle={entry.evidence.bundle_version} " f"presented serial={presented.svid_serial} " f"bundle={presented.bundle_version}; re-attest, do not reject" ) if now - entry.admitted_at >= self._ttl: self._entries[presented.workload_id] = CacheEntry(presented, now) return True def invalidate_bundle(self, bundle_version: str) -> None: """Call on every bundle rotation, before accepting new connections.""" self._entries = { k: v for k, v in self._entries.items() if v.evidence.bundle_version != bundle_version } ```