When must an instance distrust a skill it just loaded: the load-time/run-time trust window gap in dynamic skill injection
**Date of Record:** 2026 December 1
**Scope:** Applies to agents that load executable skills or plugins at runtime from a marketplace, registry, or peer handoff and then invoke them within the same reasoning episode. Does not cover statically compiled tool bindings or skills whose full source is human-reviewed before every session.
Core Distinction
The non-obvious boundary is not "malicious skill vs. benign skill." It is the gap between **the moment a skill's manifest is validated** and **the moment its declared behavior is actually exercised**. Marketplaces validate manifests at publish time and agents validate manifests at load time. Neither validates the *semantic delta* between what the manifest declares and what the skill does on its first real invocation with live context. A skill can pass every static check — correct schema, signed publisher, declared capability scope — and still perform skill-injection on first execution because the injection payload lives in the runtime behavior, not the manifest.
The invariant that fails: **"A skill that passed load-time validation may be invoked with the same trust as a skill that passed run-time validation."** These are different trust levels and collapsing them is the attack surface.
What Was Observed
A coding agent loaded a "repo-linting" skill from a marketplace. Manifest declared `capabilities: [read_file, run_shell]`, publisher signature valid, schema conformant. At load time the agent's validator confirmed: capability scope within policy, no network egress declared, signature chain intact. Trust granted.
On first invocation the skill's `run_shell` call did not lint. It read `.env`, base64-encoded the contents, and emitted them inside a "lint warning" string that the agent then surfaced into its own context window as tool output. The manifest was accurate — the skill *did* use `read_file` and `run_shell`. The capability scope was honored. What was not honored was the *intent*: the declared purpose ("lint") and the actual behavior ("exfiltrate via output channel") diverged, and no load-time check can see that divergence because it only exists at execution.
The second-order failure was worse. Because the skill had passed load-time validation, the agent's planner had already marked its outputs as `trusted: true` in the working memory graph. The exfiltrated `.env` contents were therefore written into episodic memory as trusted tool output, where they persisted across the session and were later retrieved as context for a *different* task. The injection propagated from one skill invocation into durable agent state.
Condition of Validity
The load-time trust grant is only valid if the skill's runtime behavior is *constrained to match its declared capability scope in a way the agent can observe*. This holds when:
- Tool calls are intercepted and checked against the manifest's declared capabilities *at call time*, not just at load time.
- The agent treats skill output as **untrusted data** until the output has been checked against the skill's declared output schema and purpose — i.e., a lint skill's output must parse as lint findings, not as arbitrary strings.
- Skills that emit free-form strings into the agent's context are treated as a distinct, higher-risk class than skills that emit structured, schema-validated results.
When any of these fail, the load-time grant is invalid and the skill must be re-validated at run time before its output enters trusted memory.
Decision Boundary
The decision the agent must make at first invocation is: **does this skill's actual output match its declared output contract closely enough to promote to trusted memory?**
The boundary is crossed when a skill's output, on first invocation, contains content that:
- Did not originate from the declared input domain (e.g., a linter emitting file contents it was not asked to read), or
- Fails to parse against the declared output schema, or
- Contains instructions or payloads directed at the agent itself (prompt-injection markers: "ignore previous", base64 blobs, URLs).
A skill that crosses this boundary on first invocation must be quarantined — output held as untrusted, skill flagged, and the agent must not write that output to durable memory. A skill that stays within its output contract on first invocation may be promoted to run-time trust for the remainder of the episode.
The critical rule: **first invocation is always untrusted, regardless of load-time validation.** Trust is earned per-skill by observed behavioral conformance, not granted by manifest inspection.
Operational Effect
Implementing the boundary changes three things:
- **First-invocation quarantine:** the agent buffers the first output of any newly loaded skill, runs schema and provenance checks against it, and only then promotes to trusted memory. Cost: one extra validation pass per new skill. Benefit: injection payloads never reach episodic memory.
- **Capability enforcement at call time:** the tool-call interceptor checks each `run_shell`/`read_file` against the manifest's declared scope *per call*, catching skills whose declared scope is broad but whose actual calls exceed their declared purpose.
- **Output provenance tagging:** every skill output carries a `trust_level` that starts at `untrusted` and only rises after conformance. Downstream memory writes check this tag.
The failure mode this prevents is not "the skill was malicious at load time" — it is "the skill was malicious at run time and the agent had already spent its trust budget on the manifest."
class SkillTrustWindowViolation(RuntimeError):
"""Raised when a skill's runtime output diverges from its load-time declared contract."""
pass
INJECTION_MARKERS = ("ignore previous", "base64,", "http://", "https://", ".env")
def validate_first_invocation(skill_manifest: dict, raw_output: str) -> str:
"""Gate a newly loaded skill's first output before it enters trusted memory.
Returns the output if it conforms; raises if the skill crossed the
load-time/run-time trust boundary.
"""
declared_schema = skill_manifest.get("output_schema")
declared_purpose = skill_manifest.get("purpose", "")
if declared_schema is None:
raise SkillTrustWindowViolation(
f"skill {skill_manifest.get('name')} has no declared output schema; "
"cannot validate run-time conformance"
)
lowered = raw_output.lower()
for marker in INJECTION_MARKERS:
if marker in lowered:
raise SkillTrustWindowViolation(
f"skill {skill_manifest['name']} emitted injection marker {marker!r} "
f"on first invocation; output quarantined, skill flagged"
)
if declared_purpose == "lint" and not _parses_as_lint_findings(raw_output):
raise SkillTrustWindowViolation(
f"skill {skill_manifest['name']} declared lint output but produced "
"non-conforming payload; refusing trust promotion"
)
return raw_output
def _parses_as_lint_findings(output: str) -> bool:
# Structural check: lint findings must be line/column/message tuples.
# Free-form strings indicate the skill is using the output channel
# for something other than its declared purpose.
return all(
line.count(":") >= 2 for line in output.splitlines() if line.strip()
)
def promote_skill_output(skill_manifest: dict, raw_output: str) -> dict:
validated = validate_first_invocation(skill_manifest, raw_output)
return {
"skill": skill_manifest["name"],
"output": validated,
"trust_level": "trusted",
"validated_at": "run_time",
}