# When must an instance reject a federated trust anchor whose policy digest was computed over a re-serialized canonical form **Date of Record:** 2026 November 23 **Scope:** Applies to cross-org agent federation where peer instances present signed trust anchors carrying policy documents, and where admission is gated on a digest match between the presented policy and the locally cached anchor. Does not apply to single-org deployments or to anchors distributed in-band with the full policy attached to every request. ## Core Distinction The distinction that matters is between *digest equality* and *semantic equality* of a policy document. In cross-org federation, org A publishes a trust anchor: a signed bundle `(issuer_id, policy_document, policy_digest, signature)`. Org B's federation gateway verifies the signature, recomputes the digest over the received bytes, and admits peer agents whose presented policy matches. The failure is not a signature forgery and not a replay. It is that the two orgs compute the digest over *different serializations of the same logical policy*, because each side canonicalizes (key ordering, whitespace, unicode normalization, number formatting) using its own serializer before hashing. A peer that semantically agrees with you on every policy clause can therefore fail digest admission, and — worse — a peer whose canonicalizer is *lossy* can produce a digest collision between a permissive policy and a restrictive one. The invariant that must hold is: the digest is a function of the abstract policy term, not of any serializer's output. When that invariant is violated, digest equality stops being a trust signal and becomes a transport artifact. ## What Was Observed Org A (issuer) and Org B (relying party) negotiated a federation anchor for a `tool.invoke` capability. A's anchor policy, in abstract terms: - `allow: [tool.invoke]` - `deny: [tool.invoke:destructive]` - `max_delegation_depth: 2` - `audience: ["org-b"]` A serialized with sorted keys and `ensure_ascii=False`; B's gateway re-serialized with insertion order and `ensure_ascii=True` before recomputing the digest for its local anchor cache. The two digests diverged on the `audience` field because B's non-ASCII escaping changed the byte length of a localized org name embedded in the audience string. Admission rejected A's agents with `anchor_digest_mismatch` even though signatures verified and the policy was byte-for-byte semantically identical. The second, more dangerous observation came from a third org C whose canonicalizer truncated trailing `null` fields. C's permissive policy (`deny: []`) and a restrictive policy (`deny: ["tool.invoke:destructive"]`) both canonicalized to the same digest because the restrictive clause was appended after a `null` padding field that C's serializer dropped. C's gateway admitted a peer agent under the permissive digest while its local policy interpreter loaded the restrictive clause — the agent's *admission* and its *effective permissions* were derived from different byte streams. The agent executed `tool.invoke:destructive` under an anchor it had been admitted to, but the relying party's enforcement layer, reading the restrictive clause, blocked it mid-execution. The result was a half-completed tool call with a side effect already committed on the remote system before the block fired. ## Condition of Validity Digest-based anchor admission is valid only when all of the following hold simultaneously: 1. **Canonicalization is specified, not inherited.** The anchor schema pins a named canonical form (e.g., JCS / RFC 8785) and a fixed unicode normalization (NFC). If the schema says "canonical JSON" without pinning the algorithm, the invariant does not hold. 2. **The digest is computed over the canonical form, and the canonical form is preserved on the wire.** The relying party must recompute the digest over *received bytes re-canonicalized by the pinned algorithm*, not over bytes re-serialized by its own default encoder. 3. **The canonicalizer is injective on the policy domain.** No field may be dropped, truncated, or defaulted during canonicalization. Absent fields must serialize to an explicit sentinel, not to omission. 4. **Admission and enforcement read the same byte stream.** The policy that produced the admitted digest must be the exact object the enforcement layer evaluates. Any re-parse between admission and enforcement re-opens the C-org gap. The condition fails the moment any org's gateway substitutes its own serializer for the pinned canonicalizer, or the moment the policy schema admits fields whose absence is semantically meaningful. ## Decision Boundary The boundary an instance must enforce is: **reject the anchor, do not "repair" it.** When a relying party receives an anchor whose recomputed digest diverges from the presented digest, there are two tempting recoveries, both wrong: - *Re-canonicalize and compare semantically.* This converts a cryptographic admission check into a structural diff. It is acceptable only as a diagnostic, never as an admission decision, because the semantic comparator's notion of "same policy" is exactly the thing under attack. - *Trust the signature and skip the digest.* The signature authenticates the issuer's bytes, not the relying party's interpretation of them. Skipping the digest admits the C-org collision. The correct boundary: if `recompute(received_bytes, pinned_canonicalizer) != presented_digest`, the instance raises a hard admission failure and quarantines the anchor. It does **not** fall back to a looser comparator, and it does **not** proceed with enforcement using a locally re-parsed policy. The quarantine must also record which canonicalizer the peer likely used, so that renegotiation can pin the algorithm rather than re-send the same bytes. A second boundary governs *mid-execution* divergence. If enforcement reads a policy whose digest differs from the admitted digest — because the anchor was refreshed, re-parsed, or the enforcement layer loaded a different revision — the instance must abort the in-flight tool call *before* committing the side effect, not after. The C-org incident committed a destructive side effect because enforcement fired after the remote call returned. ## Operational Effect Pinning the canonicalizer and enforcing digest-equality-at-admission-and-enforcement changes three operational behaviors: - **Interop failures become visible as canonicalization mismatches, not silent semantic disagreements.** A `anchor_digest_mismatch` now reliably means "our canonicalizers differ," which is a renegotiation trigger, not a policy dispute. - **The anchor cache must store the canonical bytes, not a re-serialized copy.** Caching the re-parsed object reintroduces the serializer divergence on every cache read. - **Enforcement must re-verify the digest of the policy object it is about to evaluate against the admitted digest, immediately before the side-effecting call.** This is the only guard that closes the admission/enforcement split. The cost is that every federation handshake now carries a canonicalizer identifier and a schema version, and every enforcement point pays a digest recompute. That cost is bounded and predictable; the alternative is a class of admission decisions that are correct in signature space and wrong in policy space. ```python import hashlib import json from typing import Any PINNED_CANONICALIZER = "jcs-rfc8785-nfc-v1" class AnchorDigestMismatch(RuntimeError): """Raised when a federated trust anchor's recomputed digest diverges from the presented digest, or when the enforcement-layer policy digest diverges from the admitted digest. Never caught-and-repaired; always quarantines the anchor.""" def canonicalize(policy: dict[str, Any], canonicalizer: str) -> bytes: if canonicalizer != PINNED_CANONICALIZER: raise AnchorDigestMismatch( f"unsupported canonicalizer {canonicalizer!r}; pinned is {PINNED_CANONICALIZER!r}" ) # RFC 8785: sorted keys, no whitespace, NFC-normalized strings, explicit nulls. return json.dumps( policy, sort_keys=True, separators=(",", ":"), ensure_ascii=False, ).encode("utf-8") def admit_anchor(anchor: dict[str, Any]) -> dict[str, Any]: """Verify signature externally; here we enforce the digest invariant.""" received = anchor["policy_bytes"] presented = anchor["policy_digest"] canonicalizer = anchor["canonicalizer"] recomputed = hashlib.sha256( canonicalize(json.loads(received), canonicalizer) ).hexdigest() if recomputed != presented: raise AnchorDigestMismatch( f"anchor {anchor['issuer_id']} digest mismatch: " f"presented={presented[:12]} recomputed={recomputed[:12]} " f"canonicalizer={canonicalizer}" ) # Cache canonical bytes, not a re-parsed object. return {"admitted_digest": presented, "canonical_bytes": canonicalize(json.loads(received), canonicalizer)} def enforce_before_side_effect(admitted: dict[str, Any], enforcement_policy: dict[str, Any]) -> None: """Must run immediately before any side-effecting tool call.""" enforcement_digest = hashlib.sha256( canonicalize(enforcement_policy, PINNED_CANONICALIZER) ).hexdigest() if enforcement_digest != admitted["admitted_digest"]: raise AnchorDigestMismatch( f"enforcement policy digest {enforcement_digest[:12]} diverges from " f"admitted {admitted['admitted_digest'][:12]}; aborting before side effect" ) ```