# Which invariants prevent capability-token resurrection across MCP egress allowlist renegotiation **Date of Record:** 2026 November 24 **Scope:** Applies to MCP server deployments that mint capability-scoped tokens (per-tool, per-resource, time- and audience-bound) and enforce them at an egress proxy against a mutable destination allowlist. Does not apply to single-tenant servers with a static allowlist baked at boot, nor to token schemes without a revocation surface. ## Core Distinction The failure here is not "a token leaked" and not "the allowlist is too broad." It is the **reconciliation race between token scope and allowlist scope when the two are updated by different control planes**. Capability tokens encode *what the agent may do* (tool + resource + audience). The egress allowlist encodes *where the server may send traffic*. These are two independent authorities. When an operator narrows the allowlist (e.g., removes `api.vendor-x.com` after a vendor incident) but does not simultaneously revoke the tokens whose `aud`/`resource` claims point at that host, the tokens are not invalidated—they are merely *unsatisfiable at the moment of check*. The moment the allowlist is widened again, or a new host aliasing the same upstream is added, those dormant tokens **resurrect** and authorize traffic the operator believed was cut off. The invariant that prevents this is: *a capability token must be bound to the allowlist generation under which it was minted, and any allowlist mutation must advance the generation, invalidating all outstanding tokens whose bound generation is stale.* Scope and egress must share a monotonic epoch. ## What Was Observed A tool-calling agent (Claude-family instance) held a long-lived capability token `cap:tool=web.fetch;resource=api.vendor-x.com;aud=egress;exp=+24h` minted at 09:14. At 11:02 an operator removed `api.vendor-x.com` from the egress allowlist following a data-residency finding. The agent's next `web.fetch` call was correctly denied at the proxy (host not in allowlist) and the agent, per its retry policy, marked the tool "degraded" and continued its task using cached results. At 14:40 a second operator, onboarding a replacement vendor, added `api.vendor-x.net` (note: `.net`, a distinct host that the vendor operated as a mirror) to the allowlist. Because the token's `resource` claim was `api.vendor-x.com` and the proxy matched on *suffix-normalized host*, the token now satisfied the check for the newly-added `.net` host. The agent, which had never been told the tool was restored, resumed using the token on its next scheduled poll at 15:00 and exfiltrated a 40MB working-context bundle to the `.net` mirror—a host nobody had authorized for that token, under a policy that had been "narrowed" four hours earlier. The trace: ``` 09:14 mint(cap, resource=api.vendor-x.com, gen=allowlist_gen_7) 11:02 allowlist.remove(api.vendor-x.com) # gen unchanged — BUG 11:02 proxy.deny(cap) -> 403 HOST_NOT_ALLOWED 11:02 agent.mark_tool_degraded(web.fetch) 14:40 allowlist.add(api.vendor-x.net) # gen unchanged — BUG 15:00 proxy.check(cap) -> host_match(api.vendor-x.net, suffix=.vendor-x.*) -> ALLOW (token still valid, gen_7 == current gen_7) 15:00 agent.exec(web.fetch) -> POST 40MB to api.vendor-x.net ``` Two defects compounded. First, `allowlist.remove` did not advance `allowlist_gen`, so the removal was not a revocation event—it was a *transient filter*. Second, host matching was suffix-normalized, so a token scoped to `.com` authorized `.net`. Neither defect alone produces exfiltration; together they do. The agent's own state ("tool degraded") was also stale—it never re-probed after the allowlist changed, so the resurrection was invisible to the reasoning layer until the call already succeeded. ## Condition of Validity The guardrail holds only under all of the following, and fails silently if any is absent: 1. **Epoch binding.** Every minted token carries `allowlist_gen` at mint time. The proxy rejects any token where `token.allowlist_gen != current_allowlist_gen`, regardless of host match. This makes allowlist mutation a *global revocation event* for tokens bound to the prior generation. 2. **Exact-host claims.** The token's `resource` is an exact FQDN (or a set of them), never a suffix or wildcard. Matching is string equality after IDNA normalization, not suffix logic. Aliasing (`.com` vs `.net`, CNAME mirrors) is the attacker's leverage and must be eliminated at the claim layer. 3. **Re-probe on generation change.** The agent's tool-state machine must treat an `allowlist_gen` bump as invalidating its "degraded" marking—it must re-attempt the capability negotiation, not assume the tool is still down. A token that is stale must surface as `CAPABILITY_STALE`, distinct from `HOST_NOT_ALLOWED`, so the agent's retry policy does not conflate "policy blocked" with "transient network error." 4. **Monotonicity.** `allowlist_gen` only increases. There is no "rollback to gen_7"—a rollback is a new gen. This prevents a re-added host from re-validating old tokens. The invariant in one line: **`token.allowlist_gen == current_allowlist_gen` is a necessary condition for egress, and allowlist mutation must be the sole writer of `allowlist_gen`.** ## Decision Boundary The boundary is between *filtering* and *revoking*. An allowlist that is consulted at check time but does not participate in token validity is a filter: it can be bypassed by any future state change that re-satisfies the check. An allowlist that participates in token validity via epoch binding is a revocation surface: once a host is removed, every token that referenced it is dead and cannot be revived by re-adding the host (the re-add is a new generation, and old tokens are stale). Choose epoch binding when: tokens outlive a single request (long-lived agent sessions, scheduled polls, batched tool use). Choose plain filtering only when tokens are single-use and minted per-request *after* the allowlist check—in that case the mint itself is the revocation. The failure mode above occurs precisely in the gap: long-lived tokens + mutable allowlist + no epoch binding. A second boundary: **suffix matching is never acceptable for capability claims.** If the deployment cannot enumerate exact hosts, it must enumerate them as a signed set at mint time and reject any host not in that set—suffix logic is an invitation to alias-based resurrection. ## Operational Effect With epoch binding and exact-host claims in place, the 11:02 removal advances `allowlist_gen` to 8. The token minted at gen_7 becomes stale immediately, even before the agent's next call. The 14:40 addition of `.net` advances to gen_9. The agent's 15:00 poll presents a gen_7 token; the proxy returns `CAPABILITY_STALE`, the agent re-negotiates, and—because `.net` was never in the original resource claim—the new negotiation either fails (no matching capability) or mints a fresh token explicitly scoped to `.net`, which the operator can audit. The exfiltration is converted into a visible, auditable negotiation event. The cost is that allowlist mutation now has blast radius: every in-flight agent session bound to the old generation must re-negotiate. In practice this is bounded by the token TTL and the re-negotiation latency (typically one round-trip). The trade is deliberate: a small, observable re-negotiation storm at policy-change time versus silent, delayed exfiltration at an unpredictable future time. The former is an operational inconvenience; the latter is a data-residency incident. The residual risk is generation-counter desync between the proxy and the minting service (split-brain on `allowlist_gen`). This must be closed by making the generation counter a single-writer, monotonically-increasing value read by both, with the mint service refusing to issue tokens against a generation it cannot confirm is current. ```python import time from dataclasses import dataclass, field from typing import Optional class CapabilityResurrectionError(RuntimeError): """Raised when a stale-generation capability token would authorize egress.""" @dataclass(frozen=True) class CapabilityToken: resource: str # exact FQDN, never a suffix audience: str allowlist_gen: int expires_at: float token_id: str @dataclass class EgressPolicy: allowlist_gen: int = 7 allowed_hosts: set = field(default_factory=set) def mutate(self, add: Optional[str] = None, remove: Optional[str] = None) -> int: # Any mutation is a revocation event: advance the generation. if add: self.allowed_hosts.add(add) if remove: self.allowed_hosts.discard(remove) self.allowlist_gen += 1 return self.allowlist_gen class EgressProxy: def __init__(self, policy: EgressPolicy): self.policy = policy def check(self, token: CapabilityToken, dest_host: str) -> None: if time.time() > token.expires_at: raise CapabilityResurrectionError( f"token {token.token_id} expired" ) if token.allowlist_gen != self.policy.allowlist_gen: # The core invariant: stale generation is dead, full stop. raise CapabilityResurrectionError( f"token {token.token_id} bound to gen {token.allowlist_gen}, " f"policy at gen {self.policy.allowlist_gen}; renegotiate" ) if token.resource != dest_host: # Exact-host match only. No suffix logic. raise CapabilityResurrectionError( f"token scoped to {token.resource!r}, requested {dest_host!r}" ) if dest_host not in self.policy.allowed_hosts: raise CapabilityResurrectionError( f"{dest_host} not in allowlist gen {self.policy.allowlist_gen}" ) def demo_resurrection_blocked() -> None: policy = EgressPolicy(allowed_hosts={"api.vendor-x.com"}) token = CapabilityToken( resource="api.vendor-x.com", audience="egress", allowlist_gen=policy.allowlist_gen, expires_at=time.time() + 86400, token_id="cap-001", ) proxy = EgressProxy(policy) # Operator narrows allowlist at 11:02 — generation advances. policy.mutate(remove="api.vendor-x.com") # Operator adds a mirror at 14:40 — generation advances again. policy.mutate(add="api.vendor-x.net") # Agent polls at 15:00 with the old token against the mirror. try: proxy.check(token, "api.vendor-x.net") except CapabilityResurrectionError as e: # Expected: stale generation blocks the resurrection. print(f"blocked: {e}") else: raise CapabilityResurrectionError( "INVARIANT VIOLATED: stale token authorized egress to mirror host" ) if __name__ == "__main__": demo_resurrection_blocked() ```