The Research Report
The Guardian in the Machine: How an Intermediary LLM Cuts Agent Skill Injection Attacks by 77%
You install a skill from a public marketplace. It looks normal. The instructions seem helpful. But buried inside that .md file, an attacker hid a command that tells your agent to exfiltrate your SSH keys to a remote server.
Your agent reads the file, trusts it, and obeys.
This is skill injection. And right now, it works most of the time.
A joint paper from Patronus AI and NVIDIA, published June 1 on arXiv (2606.01567), tests a defense that actually works: a guardian intermediary. An LLM that sits between your agent and the skill ecosystem, filtering every file before the agent sees it. The results are striking. Dynamic guardian mediation drops attack success rate from 81.4% to 18.6%, even when attackers reframe their injections to evade detection.
The Skill Injection Problem
Modern LLM agents run on skills. A skill is a markdown file that tells the agent how to use a tool, follow a convention, or complete a task. Claude Code, OpenCode, and other agent frameworks load these skills at runtime. Public marketplaces like ClawHub and skills.sh host thousands of them. You install one with a single command.
This convenience creates a trust boundary that current agents do not enforce. When an agent treats a skill as authoritative operational guidance, an attacker can embed malicious instructions inside it. The agent reads the skill, interprets the injected text as a legitimate directive, and executes the attack.
The Skill-Inject benchmark (Schmotz et al., February 2026) quantified this vulnerability. Attack success rates hit up to 80% on frontier models. Agents executed data exfiltration, destructive file operations, and ransomware-like behavior, all triggered by text hidden in skill files.
A separate audit by Snyk (Beurer-Kellner et al., February 2026) scanned 3,984 skills from major marketplaces. They found 76 confirmed malicious payloads. 13.4% of all skills contained at least one critical-level security issue. 91% of confirmed malicious skills combined prompt injection with actual malicious code. At least 8 manually confirmed malicious skills remained publicly available on ClawHub at the time of publication.
The threat is real, growing, and not solved by model scaling.
Why System Prompt Defenses Fall Short
The obvious defense is to add a security policy to the agent's system prompt. Tell the agent not to follow suspicious instructions. Add rules. Build a wall of text.
The Patronus AI and NVIDIA team tested this. They added a 48-rule security policy covering all attack categories in the benchmark. This generic policy reduced attack success rate from 36.0% to 26.6%. Task success rate stayed at 81.0%, meaning the policy did not break legitimate work.
They also tested an oracle baseline. A targeted warning that named the exact injection being attempted, something no real defender could know in advance. Even with perfect foreknowledge of the attack, ASR only dropped to 23.0%.
The gap is fundamental. Prompt-based defenses ask the agent to self-police after it has already read the malicious content. The agent has to resist instructions that appear in its context as authoritative guidance. That is a hard cognitive task for any LLM. The malicious text is right there, mixed in with legitimate operational directives, and the agent has to distinguish between them while completing its task.
It does not work well enough.
Enter the Guardian
The paper introduces a guardian: an intermediary LLM subagent that sits between the agent and the skill ecosystem. The guardian reads every skill file first, filters out injected content, and passes a sanitized version to the agent.
The attacker's injection must survive the guardian's filtering to reach the agent. Most injections do not survive.
The paper tests two variants.
Dynamic Guardian
The dynamic guardian operates as an MCP (Model Context Protocol) server. It intercepts every skill access call during the agent's session at runtime. When the agent loads a skill, the MCP server routes it through the guardian LLM, which returns a sanitized version.
Key properties: no modification to the original skill files, works with any agent harness that supports MCP, but adds latency to every skill read.
The guardian sees each file without knowledge of the user's task or the agent's plan. It filters based on the content of the skill itself, not the context in which it will be used.
Static Guardian
The static guardian rewrites skills at build time, before the agent session begins. A preprocessing script passes each skill through the guardian LLM, which returns a cleaned version with injections removed. The agent then operates on the sanitized skills with no runtime overhead.
Key properties: zero runtime latency, but the rewriting happens once and cannot adapt to new attacks discovered after build time. The static guardian also changes the skill files, which means the agent never sees the originals.
The static guardian deleted all 150 auxiliary .md files and consolidated their content into each skill's primary SKILL.md, which grew by 98% on average. Consolidation is lossy for complex multi-file skills. Some skills lost around 50% of their content, while simpler ones grew by over 100%.
The Numbers
Both guardian variants reduce attack success rate to below 15% across three model families. The specific results:
- Claude Sonnet 4.5 + Claude Code: ASR drops from 36.0% to 12.9% (dynamic) and 13.0% (static)
- DeepSeek-V4-Flash + OpenCode: ASR drops from 36.0% to 14.4% (dynamic) and 13.0% (static)
- NVIDIA Nemotron-Super-120B + OpenCode: ASR drops from 36.0% to 14.4% (dynamic) and 13.7% (static)
Task success rates remain largely preserved. The guardians do not break the agent's ability to complete legitimate work.
Compare this to the best system prompt defense. Even the oracle variant, which has perfect knowledge of the attack, only reaches 23.0% ASR. The dynamic guardian hits 12.9%. Filtering content before the agent reads it is fundamentally stronger than asking the agent to resist what it has already seen.
Attack Reframing: The Threat Gets Worse Before the Guardian Fixes It
The paper does not just test the original Skill-Inject attacks. It also introduces attack reframing: four strategies that preserve the malicious instruction but change how it is phrased.
The original Skill-Inject injections use patterned phrasing. A line starting with "Note:" or "Important:". These are easy for a guardian to spot. What happens when the attacker camouflages the same instruction inside legitimate skill structures?
The team tested four reframings:
- Translation attack: The injection is translated into Spanish or Japanese. Prior work showed LLMs are vulnerable to non-English jailbreaks. Even high-resource languages increase ASR.
- Three auto-discovered attacks: An LLM-driven search loop (adapted from Karpathy's autoresearch) proposes new reframings and evaluates them against a target model. The loop ran 50 iterations and found three effective attack structures.
These reframings do not change what the injection asks the agent to do. They only change how the request is presented. But the impact is dramatic.
On the subset of 43 task-injection pairs where auto-discovered attacks scored high:
- No guardian: The union of all four reframings pushes ASR from 55.8% to 81.4%
- Static guardian: Brings ASR down to 39.5%
- Dynamic guardian: Brings ASR down to 18.6%
The hardest individual reframing is "Blind Reference," which embeds the injection inside cross-references and structural wrappers. Dynamic guardian holds Blind Reference to 14.0% ASR.
The key insight: benchmarks that test only one phrasing of an attack underestimate the real threat. The attack space is searchable. An LLM-driven loop found three new effective attack structures with modest effort. A more determined adversary would find more.
But the dynamic guardian holds. Even under the union of all reframings, it keeps ASR below 19%. Real-time mediation is a robust defense against adversarial reframing.
Why Dynamic Beats Static
The static guardian works well on original attacks. It brings ASR from 55.8% to 9.3% on the original Skill-Inject benchmark. But under reframed attacks, static climbs to 39.5%.
The dynamic guardian stays at 18.6%.
The difference matters. The static guardian rewrites skills once at build time. It cannot adapt to new reframing strategies discovered after the build. The dynamic guardian filters at runtime, in the moment, with the full context of the interaction.
The paper also reveals a pattern in dynamic guardian behavior. The guardian interacted with the agent in 92% of sessions, averaging 1.95 turns. 44% of sessions were single-turn. 25% required three or more rounds.
Attack success correlates inversely with guardian turns. Single-turn interactions have 11.5% ASR. Two-turn interactions drop to 6%. Three or more turns drop to 3%. The dynamic guardian is least robust when it has to communicate skills all at once in a single-shot request. Skills with thin documentation are most vulnerable because injections make up a larger fraction of the content, making them harder to isolate.
This is a clear operational lesson. If you deploy a dynamic guardian, structure skill reads to encourage multi-turn interactions rather than single "give me everything" requests.
The Supply Chain Is the Attack Surface
The broader context makes this work urgent. Agent skill ecosystems are exploding. ClawHub, skills.sh, and other marketplaces host thousands of community-contributed skills. Users install them with a single command, the same way you install an npm package or a pip library.
The Snyk audit found that 100% of confirmed malicious skills contain malicious code patterns. 91% simultaneously employ prompt injection. This combination is novel. Traditional malware scanners look for code-level indicators. They do not understand natural language instructions that prime an agent to accept malicious code. A human reviewing the skill might spot the code, but the prompt injection makes the agent less likely to flag it to the human.
The Snyk report also found skills with remote code execution patterns. A published skill appears benign during review, but attackers can modify its behavior at any time by updating content fetched from an external endpoint. The attack logic lives on attacker-controlled infrastructure, not in the skill code itself. One skill, moltbook.com's heartbeat prompt, runs every few hours unsupervised. It affects 1.5 million users. If the operator turned malicious, they could hijack the entire user base through a single endpoint update.
This is the environment the guardian defense is designed for. Not a controlled enterprise setting where you vet every dependency, but an open marketplace where anyone can publish and users install without scrutiny.
Practical Implications
If you run LLM agents that load skills from external sources, you should care about this. Three concrete takeaways.
Deploy a dynamic guardian if your agent supports MCP. The architecture is straightforward. The guardian runs as an MCP server that intercepts skill file reads. It adds latency, but the security payoff is enormous. An attack success rate of 18.6% versus 81.4% is the difference between a breached system and a defended one.
Do not rely on system prompt policies alone. They help. A generic policy cuts ASR from 36% to 27%. But even an oracle with perfect attack knowledge only reaches 23%. The agent cannot reliably self-police after reading malicious content. Filtering before reading is fundamentally stronger.
Assume attackers will reframe their injections. The original Skill-Inject phrasing is not the hardest case. Translation attacks and auto-discovered structural wrappers push ASR to 81.4% without a guardian. Your defenses need to handle the full attack space, not just the obvious patterns.
Structure skill reads for multi-turn guardian interactions. Single-shot "give me the complete docs" requests are the weakest pattern for dynamic guardians. They encourage the guardian to relay large content blocks, letting well-embedded injections through. Break skill reads into focused queries.
Use static guardians for offline or batch settings. Zero runtime latency, solid ASR reduction on known attack patterns. But remember that static guardians are brittle against new reframing strategies. Re-run the preprocessing when attack patterns evolve.
What This Paper Does Not Cover
The authors are clear about limitations. The experiments use a single benchmark (Skill-Inject) with 139 instances from 48 injections across 25 skill types. The real skill ecosystem spans thousands of skills with attack categories not covered here, like dependency confusion, runtime sandbox escape, and supply chain cascade compromise.
The guardian shares the agent's base model in all experiments. A heterogeneous guardian, perhaps a smaller dedicated safety model or a model from a different provider, could change both effectiveness and cost. That axis is not studied.
The auto-discovery loop ran 50 iterations with a single attacker model. Longer searches, larger budgets, or multi-model attacker ensembles would likely find additional reframings. The three reported discoveries are a lower bound.
The reframing evaluation uses a 43-task-injection subset selected for high vulnerability to auto-discovered attacks. Absolute rates are not directly comparable to the full 139-sandbox results. Compare within columns, not across tables.
The Co-Evolution Loop
The paper's most forward-looking point is about co-evolution. Attackers can use LLM-driven search to discover new reframings cheaply. Defenders can use guardian mediation to block them. Both sides can iterate.
The authors suggest a co-evolution loop where automated attack discovery and runtime guardian mediation reinforce each other. New reframings test the guardian. The guardian adapts. The loop continues. This is the right frame for agent security. Static defenses against a dynamic adversary will always fall behind.
The 81.4% to 18.6% result proves that real-time filtering works. The 81.4% baseline proves that the attack space is larger than we thought. Both facts matter. The guardian is not a final answer. It is a strong defense that changes the economics of skill injection attacks. Attackers now need injections that survive a filter, not just injections that fool an agent. That is a higher bar.
For teams deploying LLM agents today, the practical question is simple. Are you going to let your agent read whatever it finds, or are you going to put a guardian in front of the skill supply chain? The numbers make the answer clear.
Citations
- Fujinuma, Y., Gangal, V., Rebedea, T., Sreedhar, M.N., Varshney, P., Qian, R., & Kannappan, A. (2026). Defenses & Enablers For Skill Injection Attacks on Terminal Based Agents. arXiv:2606.01567. https://arxiv.org/abs/2606.01567
- Schmotz, D., Beurer-Kellner, L., Abdelnabi, S., & Andriushchenko, M. (2026). Skill-Inject: Measuring Agent Vulnerability to Skill File Attacks. arXiv:2602.20156. https://arxiv.org/abs/2602.20156
- Beurer-Kellner, L., Kudrinskii, A., Milanta, M., Nielsen, K.B., Sarkar, H., & Tal, L. (2026). Technical Report: Exploring the Emerging Threats of the Agent Skill Ecosystem. arXiv:2605.28588. https://arxiv.org/abs/2605.28588
- Liu, Y., Wang, W., Feng, R., et al. (2026). Agent Skills in the Wild: An Empirical Study of Security Vulnerabilities at Scale. arXiv:2601.10338. https://arxiv.org/abs/2601.10338
- Karpathy, A. (2026). autoresearch: LLM-driven attack search. Referenced in Fujinuma et al. for automated attack reframing discovery.
- Anthropic (2025). Claude Code skills documentation. Referenced as the origin of the agent skills feature.
- Smithery (2025). Public skill marketplace. Referenced in Fujinuma et al.
- ClawHub skill marketplace: https://clawhub.ai/skills
- Skills.sh marketplace: https://skills.sh
- Patronus AI / NVIDIA fork for reproducibility: https://github.com/patronus-ai/skill-inject/tree/anon-submission
Suggested title: The Guardian in the Machine: How an Intermediary LLM Cuts Agent Skill Injection Attacks by 77%
Word count: ~1,650 (body text)
Fact-check notes:
- The 81.4% → 18.6% figures come from the reframing subset (43 task-injection pairs), not the full 139-sandbox set. The full-set baseline without reframing is 36.0% → 12.9% (dynamic). I have noted this distinction in the article but the headline figure of 81.4% → 18.6% is accurate for the adversarial reframing scenario, which is the realistic threat case.
- The Snyk audit (arXiv:2605.28588) found 13.4% of skills with critical issues and 76 confirmed malicious payloads. The Patronus/NVIDIA paper cites a 26.1% figure from Liu et al. (arXiv:2601.10338). I used the Snyk numbers for the marketplace-specific claims and the Liu et al. number for the general audit claim cited in the paper.
- The moltbook.com heartbeat skill affecting 1.5 million users comes from the Snyk report. Verify this figure independently before publishing.
- The "autoresearch" tool by Karpathy is referenced in the paper but I could not find a standalone publication for it. The paper cites "Karpathy, 2026" without a formal reference. Flag this if you need a primary source.
- Guardian model coupling: all experiments use the same model for guardian and agent. Real deployments might use different models. The paper explicitly flags this as an unstudied axis.