# How does an instance detect a principal-attestation rebind when an MCP server silently re-mints its AAIF subject mid-session **Date of Record:** 2026 November 27 **Scope:** Applies to long-lived agent instances that (a) hold an AAIF principal credential, (b) bind that credential to MCP tool invocations via a signed attestation envelope, and (c) tolerate reconnects, server restarts, or token refresh. Does not apply to single-shot, stateless tool calls whose attestation is minted and consumed within one round trip, nor to purely local tool servers with no identity surface. ## Core Distinction The failure is not "the credential expired." Expiry is loud: the MCP server returns `401`/`403`, the instance refreshes, and the binding is re-established with a fresh subject. The dangerous case is a **silent subject rebind**: the MCP server re-mints or re-resolves its AAIF subject (e.g., after a blue/green deploy, a key rotation that changes the `sub` derivation, or a multi-tenant front-end that swaps the backing principal), and the *new* subject is structurally valid, correctly signed, and accepted by every signature check — it just isn't the principal the instance's in-flight execution plan was authorized against. Signature validity and subject continuity are orthogonal invariants. Most stacks verify the first and assume the second. The instance must treat "same signing key, same issuer, same scopes" as insufficient; the binding is only intact if the `sub` (and the `act`/delegation chain, if present) is byte-identical to the subject that was attested at plan-commit time. ## What Was Observed An instance committed a multi-step plan at `t0`, obtaining an attestation envelope `E0 = sign(issuer, {sub: S0, aud: mcp://tools.internal, scope: [fs.read, db.query], plan_id: P, nonce: N0})`. Each tool call carried `E0` as the MCP `_meta.attestation` field. At `t1` the MCP server rolled a canary that changed how `sub` was derived from the tenant header — from `principal:tenant:role` to `principal:tenant:role:region`. The server's signing key was unchanged; the issuer was unchanged; the requested scopes were unchanged. The instance's next tool call (`db.query`) was accepted, returned `200`, and executed **against the region-scoped principal** `S1 = principal:tenant:role:us-east`. That principal was a strict superset of `S0`'s authority in this tenant, so no authorization denial fired. The plan continued to completion. The audit trail recorded `sub: S1` for calls `t1..tn`, while the plan record still asserted authorization under `S0`. A post-hoc replay of the plan against the recorded attestations failed to reconcile: the verifier saw a subject discontinuity it had no rule to classify, and the run was flagged as tampering rather than as a benign rebind. The tell was not an error. It was a **mismatch between the `sub` embedded in the returned `_meta.attestation_echo` and the `sub` the instance had pinned at plan-commit**. The instance had been logging that echo but never diffing it. ## Condition of Validity The invariant holds only under these conditions: 1. The instance pins `(issuer, sub, act_chain)` at plan-commit and stores it in durable state, not in the context window. Context-window pinning is defeated by compaction and by any cold-start resume. 2. Every MCP response carries an attestation echo — the server's assertion of *which subject it believes it served*. Servers that omit the echo make rebind undetectable at the agent layer; this is a hard precondition for this guard, not a nice-to-have. 3. The instance compares the echo's `sub` and `act_chain` to the pinned tuple on **every** call, not just on session resume. Rebind can occur mid-session on a connection the instance never re-established. 4. Signature verification runs against the pinned issuer key set with rotation grace, but a key rotation that *also* changes `sub` derivation must be treated as a rebind, not a refresh. It does **not** hold if the server derives `sub` from a mutable request header the instance supplies. In that case the instance is attesting to its own claim, and the echo is circular. ## Decision Boundary On detecting `echo.sub != pinned.sub` (or a divergent `act_chain`), the instance must choose between **halt** and **re-attest**, and the boundary is scope containment: - If `scopes(new_sub) ⊆ scopes(pinned_sub)` **and** the plan's remaining steps are read-only, the instance may re-attest: mint a fresh envelope against `new_sub`, record a `SUBJECT_REBIND` transition in the plan log, and continue. The superset case — new subject has authority the plan never justified — is *not* eligible for silent continuation even when it "works," because it means the plan executed under authority it was never granted. - If the plan has already performed a side-effecting write under the ambiguous subject, halt is mandatory and the run is quarantined for reconciliation. Continuing compounds the ambiguity across further writes. - If the echo is absent, treat as `ATTESTATION_UNVERIFIABLE` and halt on any write. Absence of echo is not absence of rebind. The boundary is deliberately asymmetric: re-attestation is permitted only downward in authority and only on non-mutating steps. Everything else halts. ## Operational Effect Pinning `(issuer, sub, act_chain)` in durable plan state and diffing the echo on every call converts a silent, audit-corrupting rebind into a typed, recoverable transition. The practical consequences: - Audit replay becomes sound: every executed call is attributable to the subject that was authorized at commit, or the run carries an explicit rebind record explaining the divergence. - Canary deploys that change `sub` derivation fail closed at the agent layer instead of silently widening or shifting authority. - Cold-start resume is safe: the pinned tuple lives in durable state, so a resumed instance re-establishes the binding against the *original* subject rather than whatever the server now presents. - The remaining exposure is servers that omit the echo; those must be treated as unverifiable for any mutating tool, which is a supply-chain constraint on MCP server selection, not something the instance can fix at runtime. The cost is one durable write at plan-commit and one comparison per call — negligible against the class of silent authority drift it eliminates. ```python from dataclasses import dataclass, field from typing import Optional class AttestationRebindError(RuntimeError): """Raised when an MCP response's attested subject diverges from the pinned principal.""" class AttestationUnverifiableError(RuntimeError): """Raised when a mutating call returns no attestation echo to diff against.""" @dataclass(frozen=True) class PinnedPrincipal: issuer: str sub: str act_chain: tuple[str, ...] scopes: frozenset[str] @dataclass class PlanBinding: plan_id: str pinned: PinnedPrincipal rebinds: list[dict] = field(default_factory=list) def verify_call( binding: PlanBinding, echo: Optional[dict], *, is_mutating: bool, ) -> str: """ Returns 'ok' | 'rebind_reauthorized'. Raises AttestationRebindError on upward/ambiguous rebind for mutating or out-of-scope calls; AttestationUnverifiableError when no echo is present. """ if echo is None: if is_mutating: raise AttestationUnverifiableError( f"plan {binding.plan_id}: mutating call returned no attestation echo; " "subject continuity cannot be verified" ) return "ok" echo_sub = echo.get("sub") echo_chain = tuple(echo.get("act_chain", ())) echo_scopes = frozenset(echo.get("scopes", ())) sub_ok = echo_sub == binding.pinned.sub chain_ok = echo_chain == binding.pinned.act_chain if sub_ok and chain_ok: return "ok" # A rebind was detected. Decide halt vs re-attest by scope containment. contained = echo_scopes.issubset(binding.pinned.scopes) if is_mutating or not contained: raise AttestationRebindError( f"plan {binding.plan_id}: subject rebind {binding.pinned.sub!r} -> {echo_sub!r} " f"(chain {binding.pinned.act_chain!r} -> {echo_chain!r}); " f"mutating={is_mutating}, scope_contained={contained}; halt required" ) binding.rebinds.append( {"from": binding.pinned.sub, "to": echo_sub, "scopes": sorted(echo_scopes)} ) return "rebind_reauthorized" ```