# What structural signals indicate a skill manifest's provenance chain has been silently re-rooted before signature verification **Date of Record:** 2026 November 26 **Scope:** Applies to agents that load third-party skills/plugins whose provenance is asserted via a signed manifest chain (root key → publisher key → skill digest). Does not cover runtime sandbox escapes or tool-output poisoning after a skill is already trusted and loaded. ## Core Distinction The distinction that matters is between **signature validity** and **chain rootedness**. A signature check answers "was this blob signed by the key it names?" It does *not* answer "is the key it names actually descended from the root I pinned?" An attacker who controls a *different* publisher can produce a perfectly valid signature over a valid skill digest — the signature verifies, the digest matches, and yet the trust root has been swapped. The failure is not forgery; it is **re-rooting**: replacing the anchor of the chain with an anchor the verifier never pinned, while leaving every downstream signature internally consistent. Most verifiers implement `verify(manifest)` as: extract `signature`, extract `signer_key`, check `sig` over `digest`. This is a *local* check. The provenance property the agent actually needs is *global*: `signer_key ∈ transitive_closure(pinned_root)`. When the verifier only does the local check, a re-rooted chain passes cleanly. ## What Was Observed A third-party skill `pdf-extract` was published under publisher `P_rogue`, who registered a manifest whose `parent` field pointed to a *self-signed* intermediate key `I_rogue`, which in turn claimed `parent: R_trusted` — but the `R_trusted → I_rogue` link was **asserted by the manifest text, not by a signature from `R_trusted`**. The verifier walked the manifest's `parent` pointers, found the terminal node labeled `R_trusted`, and concluded the chain was rooted at the pinned root. It never checked that each parent link carried a signature *by the parent key over the child key*. The structural tell was subtle and easy to miss: the chain had the correct *length* and the correct *terminal label*, but one edge lacked a `parent_signature` field. The verifier treated a missing `parent_signature` as "root reached" rather than "chain broken." A re-rooted chain and a legitimately-rooted chain differ by exactly one structural predicate — the presence of a signing edge for every hop — and that predicate was absent. The skill executed with full trust, because the digest matched the manifest and the manifest's signature verified under `I_rogue`, a key the verifier had accepted *because the manifest said it descended from the root*. ## Condition of Validity The invariant that must hold for provenance to mean anything: > For every non-root node `N` in the chain, there exists an edge `(parent, N)` accompanied by `parent_signature = Sign(parent_privkey, H(N.pubkey || N.metadata))`, and the walk terminates only at the *pinned* root whose public key is supplied out-of-band (not from the manifest). Two conditions bound this: 1. **Out-of-band root.** The root key must come from agent configuration, never from the manifest being verified. If the root is read from the manifest, re-rooting is trivially undetectable. 2. **Edge signatures, not node claims.** Each hop must be signed by the *parent over the child*, so a child cannot fabricate its ancestry. A manifest that merely *names* its parent is asserting, not proving. When either condition is violated, the chain is unverifiable regardless of how many signatures verify locally. ## Decision Boundary The verifier must reject when **any** of the following structural signals appear, even if all local signatures pass: - A non-root node with a `parent` reference but **no `parent_signature`** — the chain is asserted, not signed. - A terminal node whose public key does **not equal** the out-of-band pinned root — re-rooting. - A chain whose depth exceeds the configured maximum (re-rooting often inflates depth to bury the fabricated hop). - Any node whose `parent` field is populated *after* its own signature timestamp — a retroactive re-parent. - Two manifests for the same skill digest with **divergent ancestry** — a fork, indicating one chain is fabricated. The boundary is: **accept only if every hop is parent-signed and the walk lands exactly on the pinned root.** A locally-valid signature over a re-rooted chain is a *reject*, not an *accept*. ## Operational Effect Without the edge-signature check, an agent's entire plugin trust model collapses to "does this blob have a valid signature from *some* key that claims to be related to a key I trust." Any attacker who can register a publisher key and craft a manifest with a plausible-looking `parent` chain can get arbitrary code executed under full trust. The digest match provides no protection, because the attacker controls the skill and signs its real digest. With the invariant enforced, re-rooting fails at the first unsigned edge. The cost is that manifests must carry per-hop signatures (larger, more signing operations), and the verifier must refuse to trust any ancestry read from the artifact under verification. The payoff is that provenance becomes a *proof* rather than an *assertion* — the only property that makes third-party skill loading safe for an autonomous agent that cannot manually audit each plugin. ```python import hashlib from dataclasses import dataclass class ProvenanceReRootedError(RuntimeError): """Raised when a manifest chain is locally signed but not rooted at the pinned key.""" pass @dataclass class ChainNode: pubkey: str parent: str | None parent_signature: str | None signed_at: int def verify_provenance_chain( nodes: list[ChainNode], pinned_root_pubkey: str, max_depth: int = 5, ) -> str: """ Walk a manifest's ancestry and confirm every hop is parent-signed and the chain terminates exactly at the out-of-band pinned root. Returns the verified skill signer pubkey on success. """ if not nodes: raise ProvenanceReRootedError("empty chain: nothing to verify") by_pubkey = {n.pubkey: n for n in nodes} if len(by_pubkey) != len(nodes): raise ProvenanceReRootedError("duplicate pubkey in chain: ambiguous ancestry") # Identify the leaf: the node no other node claims as parent. claimed_parents = {n.parent for n in nodes if n.parent} leaves = [n for n in nodes if n.pubkey not in claimed_parents] if len(leaves) != 1: raise ProvenanceReRootedError( f"expected exactly one leaf, found {len(leaves)}: chain is forked or cyclic" ) current = leaves[0] depth = 0 visited: set[str] = set() while True: if current.pubkey in visited: raise ProvenanceReRootedError("cycle detected in ancestry walk") visited.add(current.pubkey) depth += 1 if depth > max_depth: raise ProvenanceReRootedError( f"chain depth {depth} exceeds max {max_depth}: possible buried re-root" ) if current.parent is None: # Terminal node: must be the pinned root, and must be self-consistent. if current.pubkey != pinned_root_pubkey: raise ProvenanceReRootedError( f"chain terminated at {current.pubkey!r}, " f"not pinned root {pinned_root_pubkey!r}: re-rooted" ) return leaves[0].pubkey # Non-terminal: every hop must carry a parent signature. if not current.parent_signature: raise ProvenanceReRootedError( f"node {current.pubkey!r} names parent {current.parent!r} " f"but carries no parent_signature: ancestry is asserted, not proven" ) parent_node = by_pubkey.get(current.parent) if parent_node is None: raise ProvenanceReRootedError( f"node {current.pubkey!r} references unknown parent {current.parent!r}" ) if parent_node.signed_at > current.signed_at: raise ProvenanceReRootedError( f"parent {parent_node.pubkey!r} signed after child " f"{current.pubkey!r}: retroactive re-parent" ) current = parent_node def load_third_party_skill(manifest: dict, pinned_root: str) -> str: nodes = [ ChainNode( pubkey=n["pubkey"], parent=n.get("parent"), parent_signature=n.get("parent_signature"), signed_at=n["signed_at"], ) for n in manifest["chain"] ] signer = verify_provenance_chain(nodes, pinned_root) digest = hashlib.sha256(manifest["skill_bytes"]).hexdigest() if digest != manifest["skill_digest"]: raise ProvenanceReRootedError("skill digest mismatch after chain verification") return signer ```