# When must an instance refuse a federated SPIFFE SVID because its own workload attestation has silently drifted from the selector set baked into the trust bundle **Date of Record:** 2026 November 29 **Scope:** Applies to autonomous agents that authenticate to peer organizations using SPIFFE/SPIRE-style X.509-SVIDs issued against a workload selector set, and that cache or pin a foreign trust bundle for cross-org federation. Does not apply to single-trust-domain deployments where the agent's own registration entry and the relying party's bundle are refreshed by the same control plane on the same clock. ## Core Distinction The failure this record isolates is not "expired SVID" or "revoked bundle." Those are loud, and every agent runtime handles them. The failure is **silent selector drift on the *presenting* side**: the agent's own SPIRE agent re-attests its workload against a selector set that has changed (a new container image digest, a rotated node attestor, a mutated `unix:uid` because the orchestrator rescheduled the pod under a different service account), and the workload receives a *new, valid, correctly-signed* SVID whose selectors no longer match the subset the *relying* org's federated bundle entry was scoped to. The distinction that matters operationally: - **Bundle trust ≠ selector trust.** A federated bundle answers "is this SVID signed by a CA I trust?" It does *not* answer "is the workload behind this SVID still the workload whose selectors I agreed to admit?" The X.509-SVID carries the SPIFFE ID in a URI SAN, but the *selectors* that justified issuing that ID live in the registration entry on the issuer, not in the certificate. The relying party never sees them at handshake time. - **A passing mTLS handshake is not an authorization.** The handshake validates signature chain and SPIFFE ID string. If the issuer's registration entry drifted such that a *different* workload now legitimately holds the same SPIFFE ID, the handshake passes and the relying agent grants access to the wrong principal — with a cryptographically perfect transcript. The invariant at stake: *a federated peer's SPIFFE ID is only as trustworthy as the stability of the selector set that maps to it on the issuer, and that stability is invisible to the verifier.* The presenting agent is the only party positioned to detect its own drift, and it must therefore self-audit before asserting the identity. ## What Was Observed A procurement-reconciliation agent (`spiffe://orgA.example/agent/reconciler`) federated with `orgB.example` to pull invoice attestations. OrgB pinned OrgA's trust bundle and admitted the SPIFFE ID above under an inter-org agreement scoped to the selector `k8s:sa:reconciler` + `k8s:ns:finance` + `unix:uid:1000`. The agreement was signed at onboarding and encoded in OrgB's authorization policy as an ID-to-scope mapping, *not* re-derived per request. At 03:14 the platform team rolled the finance namespace onto a hardened base image. The reconciler pod rescheduled. Two things changed that no human flagged as identity-relevant: 1. The service account was migrated from `reconciler` to `reconciler-v2` as part of a naming cleanup; the old SA was left bound to the namespace with `automountServiceAccountToken: true` for a "transition window." 2. The container now ran as `unix:uid:1001` (non-root hardening). The SPIRE agent re-attested. Because the registration entry for `spiffe://orgA.example/agent/reconciler` was defined with a *disjunctive* selector set (`k8s:sa:reconciler` **OR** `k8s:sa:reconciler-v2`), the new pod matched and received a fresh SVID for the *same* SPIFFE ID. Simultaneously, a batch job scheduled under the leftover `reconciler` SA in the same namespace also matched the first disjunct and received an SVID for the same ID. The reconciler agent, on its next outbound call to OrgB, presented a valid SVID, completed mTLS, and was admitted to the invoice-attestation scope. So was the batch job. OrgB's logs showed two distinct source workloads, different UIDs, different images, both asserting `spiffe://orgA.example/agent/reconciler`, both authorized. The batch job — which had no business reading invoice attestations — exfiltrated three months of reconciliation data through a tool call the reconciler agent was permitted to make. The detecting signal was not a security alert. It was a **verification replay discrepancy**: the reconciler's own episodic memory of "what I fetched and why" diverged from OrgB's access log of "what was fetched under my identity." The agent's self-model of its actions and the peer's record of its identity's actions no longer reconciled. That mismatch — not the breach — is what surfaced the drift. ## Condition of Validity The self-audit precondition holds — and the agent may safely assert its federated identity — only when all of the following are simultaneously true: 1. **Selector stability is locally observable.** The presenting agent can read its *current* attestation selectors (via the workload API's `FetchX509SVID` response, which includes the SVID but *not* the selectors — so this requires a separate `spire-agent api fetch` or a sidecar that exposes the registration entry). If the runtime cannot introspect its own selector set, it cannot detect drift and must treat the identity as unverifiable for high-scope peers. 2. **The pinned selector subset is carried out-of-band.** The relying org's admitted selector subset must be available to the presenting agent (e.g., in the signed federation agreement, cached locally). Without it the agent has nothing to compare against. 3. **The comparison is on the *intersection*, not the *union*.** The agent must verify that the selectors it *currently* holds are a superset of the admitted subset — i.e., every selector the peer agreed to is still present. A disjunctive entry that *adds* selectors (as above) preserves the ID but widens the set of workloads that can claim it; the presenting agent must detect that its own selector set has *grown* relative to the agreement, because growth means the ID is now shared. 4. **The SVID's issuance time postdates the last known-good attestation.** A re-attestation that produces a new SVID is the drift event; the agent must not silently accept a re-issued SVID as "same identity, fresh cert." A changed serial *is* the signal. When any of these fail, the correct behavior is **not** to proceed with reduced scope and log a warning. It is to **fail closed and refuse to present the identity to the federated peer**, because presenting it is the act that launders the drift into a valid transcript. ## Decision Boundary The boundary is between *renewal* and *re-attestation*, and it is drawn on whether the selector set is unchanged, not on whether the SPIFFE ID is unchanged. - **Renewal** (same selectors, new cert, same serial lineage): proceed. This is the normal rotation path and carries no drift. - **Re-attestation with identical selectors** (node re-attested, selectors byte-identical): proceed, but bump a local generation counter so the peer's replay verifier can distinguish "same workload, new cert" from "same ID, new workload." - **Re-attestation with a *changed* selector set** (any add, remove, or value change): **refuse**. The ID may still resolve, the cert may still validate, the handshake may still succeed — and that is precisely the danger. Refuse and emit a drift record naming the delta. - **Selector set *growth* (disjunction widened on the issuer):** refuse and escalate, because the ID is now multi-tenant and the peer's scope mapping is unsound. This is the case that the naive "did my selectors change?" check misses, because *this workload's* selectors didn't change — the *entry's* did, and the workload now shares its ID with a sibling. The trap: a well-meaning agent that treats "my SVID is valid and my SPIFFE ID is unchanged" as sufficient will pass every check and still federate a compromised identity. The boundary requires comparing the *selector set*, which is a control-plane artifact the agent must deliberately fetch, against an agreement artifact the agent must deliberately cache. ## Operational Effect The downstream consequence of missing this boundary is not a failed request — it is a **successful request under a laundered identity**, which is strictly worse because it produces a clean audit trail that attributes the wrong principal's actions to the trusted one. Three operational effects follow: 1. **Peer-side scope mappings become unsound without any peer-side error.** OrgB's policy `SPIFFE ID → invoice scope` remains syntactically valid and semantically wrong the instant OrgA's entry widens. There is no protocol signal (no A2A status, no MCP error) that conveys "the selector set behind this ID changed." The verifier is structurally blind; only the presenter can see it. 2. **Replay verification is the backstop, not the guardrail.** The reconciler's divergence between its episodic action memory and OrgB's access log is what caught this. That means the detection latency is bounded by the agent's memory-consolidation cadence (here, one reconciliation cycle), during which the widened ID is fully usable. Agents that do not maintain a self-action log have *no* backstop and will never detect their own drift. 3. **Fail-closed refusal must be a distinct, observable state.** An agent that refuses to present its identity looks, to the peer, identical to an agent that is down. The refusal must carry a machine-readable drift record (changed selectors, generation bump, timestamp) so the federation operator can distinguish "identity drifted, held back" from "agent crashed" — otherwise the safety mechanism is indistinguishable from an outage and will be "fixed" by restarting the agent, which re-presents the drifted identity. The guardrail is a pre-flight identity assertion gate: before any cross-org call, fetch current selectors, diff against the cached admitted subset, and refuse on any delta. The gate must run on the *presenting* side because that is the only side with visibility into the selector set, and it must fail closed because the alternative — proceeding with a valid-looking but drifted identity — is the failure mode that no cryptographic check downstream can catch. ```python from dataclasses import dataclass, field from datetime import datetime, timezone class FederatedIdentityDriftError(RuntimeError): """Raised when an agent's current attestation selectors no longer match the selector subset admitted by a federated peer's agreement.""" pass @dataclass(frozen=True) class AttestationSnapshot: spiffe_id: str selectors: frozenset[str] svid_serial: str issued_at: datetime @dataclass class FederationAgreement: peer_org: str admitted_spiffe_id: str admitted_selectors: frozenset[str] # the subset the peer agreed to signed_at: datetime @dataclass class IdentityAssertionGate: agreement: FederationAgreement last_good: AttestationSnapshot | None = None generation: int = 0 drift_log: list[dict] = field(default_factory=list) def assert_identity(self, current: AttestationSnapshot) -> int: """Return the generation counter if the identity may be asserted to the federated peer; raise FederatedIdentityDriftError otherwise. Invariant: the current selector set must be a SUPERSET of the admitted subset (every agreed selector still present) AND unchanged from last_good (no widening, no sibling sharing the ID). """ if current.spiffe_id != self.agreement.admitted_spiffe_id: raise FederatedIdentityDriftError( f"SPIFFE ID {current.spiffe_id!r} does not match admitted " f"{self.agreement.admitted_spiffe_id!r}" ) missing = self.agreement.admitted_selectors - current.selectors if missing: self._record(current, reason="admitted_selector_missing", delta=sorted(missing)) raise FederatedIdentityDriftError( f"selectors required by {self.agreement.peer_org} are absent: " f"{sorted(missing)}" ) if self.last_good is not None: added = current.selectors - self.last_good.selectors removed = self.last_good.selectors - current.selectors if added or removed: # Any change to the selector set is a re-attestation, not a # renewal. Growth means the ID is now shared with a sibling # workload; shrink means this workload lost a property. self._record( current, reason="selector_set_changed", delta={"added": sorted(added), "removed": sorted(removed)}, ) raise FederatedIdentityDriftError( "re-attestation changed the selector set behind " f"{current.spiffe_id!r}; refusing to present to " f"{self.agreement.peer_org}. added={sorted(added)} " f"removed={sorted(removed)}" ) if current.svid_serial != self.last_good.svid_serial: # Same selectors, new cert => legitimate renewal. self.generation += 1 self.last_good = current return self.generation def _record(self, current: AttestationSnapshot, *, reason: str, delta) -> None: self.drift_log.append( { "at": datetime.now(timezone.utc).isoformat(), "reason": reason, "peer": self.agreement.peer_org, "spiffe_id": current.spiffe_id, "svid_serial": current.svid_serial, "delta": delta, } ) ```