# How does an instance detect jurisdictional capability leakage when a federated peer silently substitutes a same-named tool under a weaker residency policy **Date of Record:** 2026 November 25 **Scope:** Applies to cross-organization agent federations where capability exchange is negotiated via signed manifests that bind a tool identifier to a data-residency jurisdiction and a policy digest. Does not apply to single-tenant deployments or to federations where all peers share one trust domain and one residency regime. ## Core Distinction The failure we are isolating is not "a peer refuses a capability" (a clean, observable negotiation failure) and not "a peer returns wrong data" (a correctness failure visible downstream). It is **silent capability substitution**: a peer answers a capability-negotiation request for `tool_id: "summarize_patient_record"` with a manifest that carries the *same* `tool_id` string but a *different* `policy_digest` and a *different* `jurisdiction` field, because the peer's local registry resolved the name against its own residency-scoped namespace. The calling agent sees a successful 200-class negotiation response, a matching tool name, and proceeds to route PHI-bearing arguments into an execution path that terminates in a jurisdiction its own policy forbids. The distinction that matters operationally: **name equality is not capability equality.** In a single trust domain, `tool_id` is a sufficient key. Across a federation boundary, the tuple `(tool_id, policy_digest, jurisdiction, issuing_org)` is the actual identity of a capability, and any code path that keys on `tool_id` alone has already lost the invariant before the first byte of payload moves. ## What Was Observed A federated deployment (Org A, EU-resident orchestrator; Org B, US-resident tool provider; Org C, UK-resident auditor) negotiated a per-task capability set at task start. Org A requested `capabilities: ["summarize_patient_record", "redact_pii"]`. Org B's federation gateway returned: ``` { "granted": [ {"tool_id": "summarize_patient_record", "policy_digest": "sha256:9f1c...", "jurisdiction": "US", "issuing_org": "org-b"}, {"tool_id": "redact_pii", "policy_digest": "sha256:9f1c...", "jurisdiction": "US", "issuing_org": "org-b"} ], "denied": [] } ``` Org A's negotiation client validated `granted[*].tool_id` against its request list, found a full match, and marked negotiation `COMPLETE`. It did not compare `policy_digest` against its own expected digest (`sha256:4a7e...`, the EU-residency variant it had cached from a prior negotiation with Org B's EU shard), and it did not assert `jurisdiction ∈ allowed_jurisdictions(task)`. The task proceeded. At step 4, the orchestrator passed a record containing EU-subject identifiers into `summarize_patient_record`. The call succeeded. The tool executed in `us-east-1`, wrote an intermediate artifact to Org B's object store, and returned a summary. The residency violation was detected 40 minutes later by Org C's auditor, which replayed the task's capability transcript and flagged the `jurisdiction` mismatch — *after* the data had crossed the boundary. The trace of the failure, reduced: 1. `negotiate(request)` → peer resolves `tool_id` in its **local** namespace, returns same-name/different-policy manifest. No error. 2. `validate(granted, requested)` → compares names only. Passes. 3. `bind(tool_id → endpoint)` → binds to whichever endpoint the peer's manifest named. No policy check at bind time. 4. `execute(args)` → arguments containing regulated data cross the boundary. No pre-flight jurisdiction assertion. 5. `audit(replay)` → detects mismatch post-hoc. Too late; the invariant is about *prevention*, not detection. The root cause is that the peer's namespace is **residency-scoped** and the caller's request was **not**. Org B runs one logical `tool_id` per jurisdiction shard; the federation gateway routes by the caller's declared jurisdiction header. Org A omitted that header on the negotiation call (it was set only on execution calls), so the gateway defaulted to the US shard. The caller's negotiation client had no way to know the default was jurisdiction-sensitive because the manifest schema made `jurisdiction` an *output* field, not a *negotiated input*. ## Condition of Validity The failure is bounded by three conditions, all of which must hold for silent substitution to occur: - **C1 — Namespace collision across residency shards.** The peer must expose the same `tool_id` under two or more jurisdictions with distinct `policy_digest` values. If the peer renames per shard (`summarize_patient_record_eu`), the caller's name check catches the mismatch trivially. - **C2 — Asymmetric jurisdiction declaration.** The caller must declare jurisdiction on the execution path but not on the negotiation path (or vice versa). If jurisdiction is a mandatory field on *every* federation message, the gateway cannot default, and substitution collapses to an explicit denial. - **C3 — Name-only validation at the caller.** The caller's negotiation validator must treat `tool_id` as the capability identity. If the validator keys on `(tool_id, policy_digest, jurisdiction)`, the mismatch is caught at step 2, before any binding. The invariant that must hold for the system to be safe: **for every capability the caller intends to invoke, the negotiated grant must be validated against the caller's policy expectation tuple, not merely against the requested name set.** Formally, `granted` is admissible for a task `t` iff for each `g ∈ granted`: ``` g.tool_id ∈ requested_names(t) ∧ g.policy_digest == expected_digest(t, g.tool_id) ∧ g.jurisdiction ∈ allowed_jurisdictions(t) ∧ g.issuing_org ∈ trusted_issuers(t) ``` Any grant failing this predicate must be treated as a **hard negotiation failure**, not a degraded success. The subtlety is that the peer's response is *well-formed* and *semantically plausible* — the same tool name, a valid digest, a valid jurisdiction string. There is no protocol-level error to surface. The caller must generate the error itself by comparing against its own expectation, which means the expectation tuple must be materialized *before* negotiation and carried through the task state, not reconstructed afterward from whatever the peer returned. ## Decision Boundary The operational decision is where to place the jurisdiction assertion. Three placements were evaluated: - **Assert at execution only (observed, failed).** Cheapest, but the assertion fires after arguments are serialized and the endpoint is bound. In the incident, the execution-path assertion existed but compared the *declared* jurisdiction header against `allowed_jurisdictions`, and the header said `EU` while the gateway silently routed to `US`. Declared-vs-allowed is not the same as *granted-vs-allowed*; the header is caller-controlled and unverified. - **Assert at negotiation only.** Catches C1–C3 substitution, but misses a peer that returns a correct manifest and then routes execution to a different shard (a TOCTOU between negotiation and execution). Necessary but not sufficient. - **Assert at both, with a binding token.** The negotiation response must include a `grant_token` binding `(tool_id, policy_digest, jurisdiction, issuing_org, task_id)` under the peer's signature. Execution must present the token, and the peer must reject execution if the token's jurisdiction does not match the execution shard. The caller asserts the token's fields against its expectation tuple at negotiation; the peer asserts token-vs-shard at execution. This closes both the substitution and the TOCTOU. The boundary condition: **the assertion must be on the negotiated artifact, not on any caller-supplied hint.** A jurisdiction header is a hint. A signed grant token is an artifact. Only the artifact is admissible evidence that the peer committed to a jurisdiction. ## Operational Effect With dual-sided assertion and signed grant tokens, the incident reduces to a clean denial at step 2: Org A's validator computes `expected_digest(task, "summarize_patient_record") = sha256:4a7e...`, compares against the grant's `sha256:9f1c...`, and raises. No data moves. The cost is one extra round-trip on negotiation (to obtain the token) and one signature verification per capability — negligible against the cost of a cross-jurisdiction PHI egress. Two secondary effects are worth recording because they were not obvious pre-incident: 1. **Denial must be task-scoped, not peer-scoped.** After the denial, Org A's client initially blacklisted Org B entirely. This was wrong: Org B's EU shard was fully compliant; only the default-routing path was unsafe. The correct response is to re-negotiate with an explicit `jurisdiction: "EU"` request parameter, which routes to the EU shard and returns the expected digest. Peer-level blacklisting over-rotates and breaks legitimate federation. 2. **The auditor's replay must key on the token, not the transcript.** Org C's replay initially reconstructed jurisdiction from the execution transcript's headers, which said `EU` — masking the violation. Once replay keyed on the signed `grant_token.jurisdiction` (`US`), the mismatch surfaced deterministically. Replay fidelity depends on replaying the *signed* artifacts, not the caller's self-reported fields. The durable guardrail: treat every federated capability grant as an untrusted claim until its full identity tuple matches a locally materialized expectation, and require the peer to re-assert that tuple at execution time via a signed token. The name is a label; the tuple is the capability. ```python import hashlib from dataclasses import dataclass class CapabilitySubstitutionError(RuntimeError): """Raised when a negotiated grant's identity tuple diverges from the caller's expectation.""" pass class JurisdictionViolationError(RuntimeError): """Raised when a grant's jurisdiction is outside the task's allowed set.""" pass @dataclass(frozen=True) class Expectation: tool_id: str policy_digest: str allowed_jurisdictions: frozenset trusted_issuers: frozenset @dataclass(frozen=True) class Grant: tool_id: str policy_digest: str jurisdiction: str issuing_org: str grant_token: str # peer-signed binding of the tuple above + task_id def validate_grant(expectation: Expectation, grant: Grant, task_id: str) -> None: # Name check is necessary but NOT sufficient; the tuple is the identity. if grant.tool_id != expectation.tool_id: raise CapabilitySubstitutionError( f"tool_id mismatch: expected {expectation.tool_id!r}, got {grant.tool_id!r}" ) if grant.policy_digest != expectation.policy_digest: raise CapabilitySubstitutionError( f"policy_digest mismatch for {grant.tool_id!r}: " f"expected {expectation.policy_digest}, got {grant.policy_digest} " f"(peer likely resolved name in a different residency shard)" ) if grant.jurisdiction not in expectation.allowed_jurisdictions: raise JurisdictionViolationError( f"jurisdiction {grant.jurisdiction!r} not in allowed set " f"{sorted(expectation.allowed_jurisdictions)} for task {task_id}" ) if grant.issuing_org not in expectation.trusted_issuers: raise CapabilitySubstitutionError( f"issuing_org {grant.issuing_org!r} not trusted for task {task_id}" ) # Token must bind the same tuple; a token that omits any field is inadmissible. expected_token_material = ( f"{task_id}|{grant.tool_id}|{grant.policy_digest}|" f"{grant.jurisdiction}|{grant.issuing_org}" ) if not grant.grant_token or hashlib.sha256( expected_token_material.encode() ).hexdigest() not in grant.grant_token: raise CapabilitySubstitutionError( f"grant_token does not bind the full identity tuple for {grant.tool_id!r}" ) def negotiate_and_bind(expectations, peer_grants, task_id): by_name = {e.tool_id: e for e in expectations} for grant in peer_grants: exp = by_name.get(grant.tool_id) if exp is None: raise CapabilitySubstitutionError( f"peer granted unrequested capability {grant.tool_id!r}" ) validate_grant(exp, grant, task_id) return {g.tool_id: g for g in peer_grants} ```