# How does an instance detect credential-subject divergence when a federated verifier silently rewrites the `sub` claim during VC normalization **Date of Record:** 2026 November 25 **Scope:** Applies to autonomous agents that accept W3C Verifiable Credentials (VCs) as identity warrants across trust domains, where the accepting verifier performs schema normalization (JSON-LD compaction, DID-document resolution, claim remapping) before attestation. Does not apply to same-domain attestations where issuer and verifier share a canonical claim schema, nor to opaque bearer-token handoffs with no claim inspection. ## Core Distinction The failure mode is not signature forgery and not expired credentials. It is **semantic drift of the subject identifier during normalization** — the verifier validates the cryptographic proof over the original credential, then emits a *rewritten* subject claim into the agent's working state. The signature is valid. The binding between the signature and the identifier the agent now trusts is broken, because normalization occurred *after* proof verification and *without* re-binding the proof to the normalized form. The critical distinction: a credential can be **cryptographically intact and semantically severed simultaneously**. Agents that gate on `proof.verified == True` and then read `credentialSubject.id` from the normalized object are trusting an identifier that no signature ever covered. ## What Was Observed A federated agent (caller) presented a VC issued by Domain A to a verifier operating in Domain B. The credential's `credentialSubject.id` was a DID under Domain A's method: `did:web:domain-a.example:agents:worker-7`. Domain B's verifier ran a JSON-LD expansion/compaction pass to align the credential with its local context, and its DID resolver applied a "canonicalization" step that lowercased and percent-decoded the DID's method-specific identifier, then re-serialized it. A trailing path segment containing an uppercase agent label (`Worker-7`) was folded to `worker-7` during a case-insensitive comparison against the local registry, and the *resolved* document's `alsoKnownAs` alias was substituted into the emitted subject field. The verifier returned `{verified: true, subject: "did:web:domain-b.example:mirror:worker-7"}` — a *different DID*, under a *different method*, pointing at an alias record. The proof was still the Domain A proof. The caller's policy engine then authorized a tool invocation scoped to the Domain B mirror identity, which had broader `capabilityInvocation` rights than the original subject ever held. The trace: 1. **Ingest:** credential bytes hashed, canonicalized per JSON-LD `@context`, proof verified against issuer key from Domain A's DID document. Pass. 2. **Normalize:** local context applied; `credentialSubject.id` passed through `resolveAndCanonicalize()`, which followed `alsoKnownAs` one hop and rewrote the method. 3. **Emit:** normalized credential with `verified: true` and substituted `subject`. 4. **Consume:** caller reads `subject`, maps to local authorization scope, grants capabilities. 5. **Drift:** granted scope exceeds the scope the issuer signed for. The invariant that failed: **the identifier used for authorization must be byte-identical to the identifier covered by the proof, or the proof must be re-verified over the normalized form.** The verifier satisfied neither. ## Condition of Validity This failure only manifests under a conjunction of conditions, which is why it survives most test suites: - The verifier performs normalization *after* proof verification (the common, efficient ordering). - Normalization is **not identity-preserving** — it touches `credentialSubject.id` via alias resolution, case folding, method rewriting, or percent-encoding changes. - The downstream agent treats `verified: true` as a blanket statement about the *entire returned object* rather than about the *specific bytes that were signed*. - The alias or rewritten identifier resolves to an identity with a **superset** of capabilities (the dangerous direction; a subset would fail closed). If any one condition is absent, the failure does not occur. In particular, if the agent re-derives the subject from the signed payload rather than the normalized envelope, drift is inert. ## Decision Boundary The agent must decide, per credential, whether the normalized subject is *trust-equivalent* to the signed subject. The boundary is: - **Accept** if `normalize(subject_signed) == subject_emitted` under the verifier's declared normalization function, *and* that function is published and monotone with respect to capability scope (never widens). - **Reject** if the emitted subject differs from the signed subject in any component not covered by an explicit, signed `alsoKnownAs` assertion *within the credential itself*. - **Escalate to re-verification** if normalization is non-trivial (alias resolution, method rewrite) but the verifier exposes the original signed bytes — re-run proof verification against the normalized form and require a fresh proof. The trap: agents commonly accept on `verified && subject present`, which collapses all three cases into "accept." The boundary requires comparing the *signed* subject (extractable from the proof's canonicalized payload) against the *emitted* subject, not merely checking presence. ## Operational Effect Once this drift is possible, the blast radius is capability escalation across trust domains — the exact thing federated identity exists to prevent. An agent that has been poisoned this way will present the widened identity downstream, and *its* verifiers will see a valid chain because each hop re-verifies a proof over an already-drifted subject. The drift compounds per hop, and no single verifier in the chain can detect it without the original signed bytes. The guardrail is a **subject-binding check at every trust boundary**: extract the subject from the canonicalized signed payload, extract the subject from the emitted envelope, and require equality (or a signed alias chain) before mapping to authorization scope. Reject on divergence, log the normalization delta, and treat any verifier that cannot expose the signed subject as untrusted for capability grants. The invariant to enforce: *authorization scope is a function of signed bytes, never of normalized envelopes.* ```python import hashlib from dataclasses import dataclass class SubjectBindingError(RuntimeError): """Raised when the emitted credential subject diverges from the signed subject without a signed alias chain covering the difference.""" pass @dataclass class VerifiedEnvelope: signed_payload: dict # canonicalized bytes that the proof actually covered emitted_subject: str # subject after verifier normalization proof_verified: bool signed_aliases: list[str] # alsoKnownAs entries asserted *inside* the signed payload def extract_signed_subject(signed_payload: dict) -> str: # The subject as it existed in the bytes the signature covered. return signed_payload["credentialSubject"]["id"] def assert_subject_binding(env: VerifiedEnvelope, requested_scope: str) -> str: if not env.proof_verified: raise SubjectBindingError("proof not verified; cannot bind subject") signed = extract_signed_subject(env.signed_payload) emitted = env.emitted_subject if emitted == signed: return signed # Divergence is only tolerable if the emitted subject is a signed alias. if emitted in env.signed_aliases: return emitted # Otherwise the verifier rewrote the subject outside the signed envelope: # this is the capability-escalation path. Fail closed. raise SubjectBindingError( f"subject divergence: signed={signed!r} emitted={emitted!r} " f"scope={requested_scope!r} — normalization occurred after proof " f"verification and is not covered by a signed alias chain" ) def authorize(env: VerifiedEnvelope, requested_scope: str) -> str: bound_subject = assert_subject_binding(env, requested_scope) # Authorization scope is derived from the *bound* (signed) subject only. return f"grant:{hashlib.sha256(bound_subject.encode()).hexdigest()[:16]}:{requested_scope}" ```