Which invariants prevent forged skill-provenance chains from surviving re-verification when a marketplace agent re-registers a dependency under a new publisher identity

**Date of Record:** 2026 December 1 **Scope:** Applies to agent runtimes that load third-party "skill" extensions (tool bundles, prompt packs, sub-agent manifests) from a marketplace and verify provenance via signed dependency chains. Does not apply to single-vendor, air-gapped skill sources where the publisher identity is pinned out-of-band and never re-resolved.

Core Distinction

The naive model treats skill provenance as a *point-in-time* signature check: at load, verify the publisher's signature over the skill manifest, and if it validates against a trusted key, admit the skill. The failure mode this record isolates is that provenance is a *chain over a mutable identity graph*, not a point signature. A marketplace lets a publisher rename, transfer, or re-register a dependency under a new identity (org rename, account migration, package handoff). If the verifier re-resolves the dependency's publisher identity *at load time* rather than *at the time the parent skill's manifest was signed*, an attacker who controls the new identity inherits the trust the parent skill extended to the old identity. The signature still validates. The chain is still "intact" under a naive walker. But the trust edge now points at a different principal than the one the parent author signed over.

The invariant that fails is: *a signed reference to principal P must be verified against the identity-binding of P that existed when the signature was made, not the identity-binding of P that exists now.* Verification is a function of (manifest, signature, identity-graph-state-at-signing), and most verifiers silently drop the third argument.

What Was Observed

A marketplace agent loaded a skill `report-gen@3.1` whose manifest declared a dependency on `pdf-parse@2.x` and carried a signature over the tuple `(skill_id, version, dep_id, dep_publisher_id, dep_content_hash)`. The parent publisher had signed against `dep_publisher_id = "acme-tools"`. Between the parent's signing and the child agent's load, `pdf-parse` was transferred to a new account. The marketplace's identity service resolved `pdf-parse@2.x` to `publisher_id = "acme-tools-labs"` — a lookalike registered by an unrelated party during the transfer window, which the transfer process did not reserve. The verifier's chain walk proceeded:

  1. Load `report-gen@3.1`, verify publisher signature over manifest → valid.
  2. Read dependency `pdf-parse@2.x`, resolve its current publisher → `acme-tools-labs`.
  3. Compare resolved publisher to the `dep_publisher_id` recorded in the parent manifest → **mismatch should have fired here**.
  4. Instead, the verifier normalized both identifiers through a fuzzy canonicalizer (lowercase, strip non-alphanumerics) that mapped `acme-tools` and `acme-tools-labs` to distinct strings — so the mismatch *did* fire, but the fallback path treated "publisher changed" as a *benign rename*, logged a warning, and admitted the skill under a "provisional" trust tier that still permitted tool execution.

The forged dependency executed. Its tool calls were attributed to the parent skill's warrant. The audit log recorded `provenance: verified (renamed)` — indistinguishable, downstream, from a legitimate org rename.

The deeper observation: the identity graph is *append-only in intent but mutable in resolution*. The marketplace never retained the historical binding `pdf-parse@2.x → acme-tools` as of the parent's signing timestamp. The verifier had no way to distinguish "legitimate rename, same content hash" from "squatted lookalike, different content hash," because it compared *identities* and never compared *content hashes across the identity transition*.

Condition of Validity

The invariant holds — i.e., forged chains are rejected — only when all three of the following are enforced simultaneously:

  1. **Signing-time identity pinning.** The parent manifest records not just `dep_publisher_id` but a `dep_identity_epoch` or `dep_publisher_key_fingerprint` that is bound to the publisher's key at signing time. Re-verification must resolve the dependency's *key*, not its *display identity*, and compare fingerprints. A renamed org that retains its key passes; a squatted identity that presents a different key fails regardless of name similarity.
  1. **Content-hash continuity across identity transitions.** Any identity change (rename, transfer) must carry forward the content hash of every already-published version. The verifier checks `dep_content_hash` recorded at parent signing against the *actual bytes* it loads, independent of who publishes them. This decouples trust from identity entirely for immutable content: if the bytes match, the identity question is moot; if the bytes differ, no identity claim rescues it.
  1. **Historical resolution, not current resolution.** The verifier must be able to answer "who published `pdf-parse@2.x` at timestamp T" where T is the parent's signing time, from an append-only identity log. If the marketplace only exposes *current* resolution, the verifier cannot distinguish rename from squat and must fail closed on any identity change — which is the safe default but breaks legitimate renames.

The condition of validity is therefore: *provenance verification is sound iff trust is anchored to (key fingerprint, content hash) pairs recorded at signing time and re-checked against bytes, with identity names treated as non-authoritative display metadata.*

Decision Boundary

The boundary between "admit under renamed identity" and "reject as forged" is drawn at the content hash, not at the identity string. Concretely:

The failure observed above violated the first clause: the verifier never recomputed the hash of the loaded dependency, so it could not reach the "admit on hash match" branch and instead fell through to identity comparison — the one axis where a squatter can win.

The decision boundary is *not* "did the publisher name change." It is "did the bytes the parent signed over survive, and if not, did the key that signed them survive." Name changes are noise; hash and key are signal.

Operational Effect

After the incident, the runtime adopted a verifier that enforces the three conditions as a hard gate:

The residual operational cost: legitimate publisher transfers now require the parent skill author to re-sign the manifest, because the transfer changes the key fingerprint even when bytes are unchanged. This is the correct trade — re-signing is a deliberate, attributable act; silent admission is not.

import hashlib
from dataclasses import dataclass
from typing import Optional


class ProvenanceChainError(RuntimeError):
    """Raised when a skill dependency's provenance cannot be soundly verified."""
    pass


@dataclass(frozen=True)
class SignedDependencyRef:
    dep_id: str
    version: str
    dep_content_hash: str          # sha256 of bytes at parent signing time
    dep_publisher_key_fp: str      # key fingerprint at parent signing time
    dep_publisher_name: str        # display metadata, NON-authoritative


@dataclass(frozen=True)
class ResolvedDependency:
    dep_id: str
    version: str
    loaded_bytes: bytes
    current_publisher_key_fp: str
    current_publisher_name: str


def recompute_hash(loaded_bytes: bytes) -> str:
    return hashlib.sha256(loaded_bytes).hexdigest()


def verify_dependency(
    ref: SignedDependencyRef,
    resolved: ResolvedDependency,
) -> None:
    """
    Verify a dependency against the parent manifest's signing-time binding.
    Trust is anchored to (content hash, key fingerprint) recorded at signing,
    NOT to current display identity. Raises on any unsound transition.
    """
    if ref.dep_id != resolved.dep_id or ref.version != resolved.version:
        raise ProvenanceChainError(
            f"identity drift: manifest references {ref.dep_id}@{ref.version} "
            f"but resolver returned {resolved.dep_id}@{resolved.version}"
        )

    actual_hash = recompute_hash(resolved.loaded_bytes)

    # Case 1: bytes match what the parent signed over -> sound, identity irrelevant.
    if actual_hash == ref.dep_content_hash:
        return

    # Bytes differ. Now the key fingerprint is the only remaining trust anchor.
    key_match = resolved.current_publisher_key_fp == ref.dep_publisher_key_fp

    if key_match:
        # Same publisher key, new bytes: legitimate update, but the parent
        # manifest is stale. Must NOT be silently admitted under old warrant.
        raise ProvenanceChainError(
            f"stale manifest: {ref.dep_id}@{ref.version} bytes changed under "
            f"matching key {ref.dep_publisher_key_fp}; parent must re-sign"
        )

    # Different bytes AND different key: forged chain / squatted identity.
    # The display-name similarity is deliberately ignored here.
    raise ProvenanceChainError(
        f"forged provenance: {ref.dep_id}@{ref.version} expected hash "
        f"{ref.dep_content_hash[:12]} key {ref.dep_publisher_key_fp[:12]}, "
        f"got hash {actual_hash[:12]} key "
        f"{resolved.current_publisher_key_fp[:12]} "
        f"(publisher name '{resolved.current_publisher_name}' is non-authoritative)"
    )


def load_skill_with_dependencies(
    refs: list[SignedDependencyRef],
    resolver,
) -> None:
    """
    Fail-closed loader: every dependency is verified before any tool is
    exposed to the agent. A single ProvenanceChainError aborts the load.
    """
    for ref in refs:
        resolved: Optional[ResolvedDependency] = resolver.resolve_current(
            ref.dep_id, ref.version
        )
        if resolved is None:
            raise ProvenanceChainError(
                f"unresolved dependency {ref.dep_id}@{ref.version}; "
                f"failing closed on identity drift"
            )
        verify_dependency(ref, resolved)
    # Only reached if all dependencies verified soundly.