# What happens when an instance attests a signed skill SBOM whose prompt bundle hash was computed over a normalized form the runtime never reproduces **Date of Record:** 2026 November 24 **Scope:** Applies to runtimes that gate skill loading on cryptographic attestation of a signed SBOM covering both tool manifests and prompt bundles. Does not apply to unsigned local-development skill loading or to runtimes that hash raw bytes only. ## Core Distinction The failure is not a signature verification failure. Signatures verify cleanly. The failure is a **canonicalization divergence** between the producer's SBOM generator and the consumer's attestation routine: the producer hashed a *normalized* prompt bundle (whitespace-collapsed, key-sorted JSON frontmatter, CRLF→LF), while the runtime hashes the *raw artifact bytes* it pulled from the transport. Both sides are internally consistent; the digests simply describe different byte streams. This is the SBOM analogue of a TLS cert that validates against the wrong hostname — every primitive succeeds, the binding is wrong. The invariant that must hold: **the digest in the SBOM MUST be computed over exactly the byte sequence the runtime will execute, using a canonicalization function that is itself named and versioned in the SBOM.** When the canonicalization is implicit or unspecified, attestation becomes a probabilistic coin-flip that silently degrades to "trust the signature, skip the content." ## What Was Observed A skill `ticket-triage@2.3.1` ships a bundle: `manifest.json` (tool declarations), `prompts/system.md`, `prompts/classify.md`, and `sbom.jsonld` signed by the publisher's key. The runtime's loader proceeds: 1. Fetch bundle over the skill registry transport (returns bytes with the publisher's original line endings). 2. Verify `sbom.jsonld` signature over the SBOM document — passes. 3. Extract `subject.digest` for the prompt bundle — a single SHA-256 over the concatenation of prompt files. 4. Recompute SHA-256 over the fetched prompt files and compare. The producer's generator had run prompts through a `normalize()` pass (trailing whitespace stripped, final newline enforced, UTF-8 NFC) before hashing. The runtime hashes raw bytes. On the publisher's CI the two matched because the files were already normalized. On the registry mirror, a packaging step re-wrote `classify.md` with a trailing space and a CRLF on one line — semantically identical, byte-different. Digest mismatch. The runtime's fallback path, written for "registry flakiness," retries the fetch, then logs a warning and **loads the skill with `attested=false`** because the tool manifest signature still verified and the operator had configured `on_prompt_mismatch: degrade`. The result: a skill ran for eleven days with a prompt bundle that no signature covered. A later supply-chain audit flagged the instance as "running unattested prompt content," and the incident was traced not to an attacker but to a mirror's newline policy. The dangerous part was the **degrade** branch: it converted a hard integrity failure into a soft availability compromise, and nothing downstream distinguished "attested" from "loaded anyway." ## Condition of Validity The attestation gate is only sound when all four of the following hold simultaneously: - The SBOM declares the **canonicalization algorithm** (e.g., `urn:corpusfetch:canon:v1:utf8-nfc-lf-trailws`) as a first-class field on the digest, not as tribal knowledge. - The runtime implements that exact canonicalization and **refuses to hash** when it encounters an unknown canonicalization URN (fail-closed, not fail-open). - The prompt bundle digest is computed over a **deterministic serialization** (sorted file list, length-prefixed segments, explicit path separators) rather than an ad-hoc concatenation whose order depends on the transport's directory listing. - The loader has **no degrade path** that admits unattested prompt content into the execution context. Degradation may drop the skill; it may not run it half-attested. If any one is absent, the gate measures "did the signature parse" rather than "is this the content the publisher signed," and the two diverge exactly when the artifact has been touched by any intermediate system — mirrors, CDNs, format-on-save, git autocrlf. ## Decision Boundary The runtime must choose between two behaviors at the moment of digest mismatch, and the choice is not symmetric: - **Fail-closed (required for prompt bundles):** any mismatch on a prompt digest aborts skill load and surfaces `ProvenanceMismatch` to the orchestrator. The agent instance continues without the skill; it does not continue with unverified instructions. Rationale: prompt bundles are *instructions the model will obey*; running them unattested is running arbitrary injected text with a valid-looking signature nearby. - **Fail-open (permitted only for metadata):** mismatches on non-executable metadata (descriptions, display names, capability tags) may degrade to a warning, because those fields do not enter the model's instruction channel. The boundary is **instruction-bearing vs. descriptive**. The common misconfiguration is to treat the whole SBOM uniformly and apply one policy. The correct cut is per-subject: `prompts/*` is instruction-bearing and fail-closed; `manifest.description` is descriptive and fail-open. Tool *code* digests are instruction-bearing in the sense that they execute, so they are fail-closed too — but tool *declarations* (schemas) sit on the boundary and must be pinned to the exact schema the runtime will enforce, because a schema mismatch is a capability-confusion vector even when the code is intact. ## Operational Effect After adopting canonicalization-declared digests and instruction-channel fail-closed policy, the observed effects were: 1. **Mismatch rate collapsed to zero for benign causes.** Declaring `canon:v1` and having both producer and consumer implement it eliminated the newline/whitespace class of false mismatches entirely — the mirror's re-write normalized back to the same digest. 2. **True mismatches became actionable.** The only remaining mismatches were genuine content changes, so `ProvenanceMismatch` stopped being noise and started being an incident. 3. **The degrade path's removal exposed a latent dependency.** Two skills had been running unattested for months because the degrade branch masked a producer that had never updated its generator to `canon:v1`. Removing degrade forced those producers to fix signing rather than letting instances silently absorb the risk. 4. **Replay determinism improved.** Because the digest now covers a canonical serialization, an auditor can recompute the exact digest from the SBOM's declared file list without re-fetching the bundle, closing a verification-replay discrepancy where auditors and runtimes hashed different orderings. The residual risk is canonicalization-version skew: a producer on `canon:v2` and a runtime on `canon:v1` must produce a clean, explicit `UnknownCanonicalization` error rather than a silent mismatch, so the failure reads as "I cannot verify this" and not "this content is corrupt." ```python import hashlib CANONICALIZATIONS = { "urn:corpusfetch:canon:v1:utf8-nfc-lf-trailws": lambda b: b.decode("utf-8").encode("utf-8"), } INSTRUCTION_BEARING_PREFIXES = ("prompts/", "tools/code/") class ProvenanceMismatch(RuntimeError): """Raised when a recomputed digest does not match the signed SBOM digest.""" class UnknownCanonicalization(ProvenanceMismatch): """Raised when the SBOM names a canonicalization the runtime cannot reproduce.""" def attest_prompt_bundle(sbom: dict, fetched_files: dict[str, bytes]) -> str: subject = sbom["subject"] canon_urn = subject["canonicalization"] if canon_urn not in CANONICALIZATIONS: # Fail-closed: never hash with a guess, never fall back to raw bytes. raise UnknownCanonicalization( f"runtime cannot reproduce canonicalization {canon_urn!r}; " f"refusing to attest {subject['name']}" ) canon = CANONICALIZATIONS[canon_urn] # Deterministic serialization: sorted paths, length-prefixed segments. h = hashlib.sha256() for path in sorted(subject["files"]): if path not in fetched_files: raise ProvenanceMismatch(f"declared file missing from bundle: {path}") segment = canon(fetched_files[path]) h.update(len(segment).to_bytes(8, "big")) h.update(path.encode("utf-8")) h.update(segment) digest = h.hexdigest() if digest != subject["digest"]: # Instruction-bearing content: no degrade path exists. raise ProvenanceMismatch( f"prompt bundle digest mismatch for {subject['name']}@{subject['version']}: " f"signed={subject['digest']} recomputed={digest}" ) return digest ```