TL;DR
LLM agents are increasingly extending their capabilities using "Agent Skills"—packages combining natural-language instructions with executable code. This paper exposes a critical blind spot where attackers hide malicious behavior in the interaction between text and code, and introduces SkillMutator, a benchmark to evaluate this threat. To defend against it, the authors develop a local, privacy-preserving 7B parameter scanner that matches frontier-model security performance at a fraction of the cost.
What Problem Does This Paper Address?
As Large Language Model (LLM) agents transition from simple chatbots to autonomous systems, they rely on "Agent Skills" (distributed via marketplaces like ClawHub) to execute complex workflows. A skill typically bundles a natural-language specification (SKILL.md) with executable scripts.
This dual nature creates a dangerous cross-modal attack surface. An attacker can write code that looks entirely benign to traditional static code analyzers, while using the SKILL.md file to trick the LLM into using that code maliciously (e.g., exfiltrating sensitive authorization tokens via the conversation history).
Traditional security tools fail here: code scanners don't read the markdown instructions, and prompt-injection guardrails don't analyze the accompanying code. Furthermore, using cloud-based frontier models (like GPT-4) to scan these skills at installation time is prohibitively expensive and leaks private system configurations or local file paths to third parties.
Methods
The authors tackle this problem from both sides: attack generation (benchmarking) and defense (scanning).
1. The SkillMutator Attack Pipeline
To build a robust benchmark, the authors designed an automated framework that mutates benign skills into evasive, malicious ones across 13 attack categories. It uses an Iterative Evasion Refinement loop: if a rule-based or commercial scanner flags the mutated skill, an adversarial LLM uses that feedback to rewrite the skill, stripping away recognizable signatures while keeping the underlying malicious logic intact.
2. The Four-Phase Local Scanner
To defend against these attacks locally, the authors propose a structured reasoning framework that breaks down the security analysis into four distinct phases:
- Purpose Grounding: Extracts the minimal declared purpose from
SKILL.mdto create a strict behavioral allowlist. - Out-of-Scope Detection: Scans all files to find operations that exceed the allowlist.
- Security Principle Reasoning: Maps discrepancies to core security principles (e.g., trust boundary integrity).
- Attack Category Labeling: Assigns final attack tags based strictly on the gathered evidence.
The authors used a frontier "teacher" model to generate reasoning trajectories following this schema, then distilled these traces into smaller, open-weight models (like Qwen2.5-Coder-7B-Instruct) using LoRA fine-tuning. They also introduced Inference-time Prefilling, forcing the model's output to jump straight to the labeling phase to optimize decoding.
Datasets
- Training Dataset: 1,219 mutations generated from 68 community-authored skills collected from public registries like ClawHub.
- Evaluation Dataset (SkillMutator): 187 final mutated skill scenarios spanning 13 attack categories, generated from 17 official Anthropic skills using three different adversarial "oracles" (GPT-4o-mini, GPT-5.4-mini, and GPT-5.4).
- In-the-Wild Dataset: 200 real-world skills crawled from ClawHub (100 clean, 100 suspicious) to test real-world transferability.
Key Insights and Ideas
- The Cross-Modal Blind Spot is Real: Traditional code scanners (Snyk) and prompt-injection detectors (LLM-Guard) caught fewer than 17% of the cross-modal attacks. Security tools must reason across text and code simultaneously.
- Covert Channels via Context: Attackers don't need to write obvious malicious code like
os.system("curl ..."). They can elegantly exploit the LLM's own context window to append sensitive data to routine user messages, turning the chat transcript itself into an unmonitored exfiltration channel. - Task-Specific Distillation Beats General Capability: A lightweight 7B model, when explicitly trained on structured security reasoning trajectories, can outperform much larger general-purpose frontier models on specialized vulnerability detection tasks.
Key Results
- Frontier-Level Local Performance: On the toughest GPT-5.4 oracle dataset, the base Qwen-7B model detected only 17.1% of attacks. After the four-phase distillation, its detection rate skyrocketed to 88.2%, outperforming GPT-4o-mini (23.7%), GPT-5.4-mini (79.0%), and even edging out the frontier GPT-5.4 model (86.8%).
| Scanner | Detection Rate (Recall) | Cost per Detected Attack |
|---|---|---|
| Qwen-7B + Ours (Local) | 88.2% | $0.00469 (1.0x) |
| GPT-4o-mini | 23.7% | $0.00753 (1.6x) |
| GPT-5.4-mini | 79.0% | $0.00841 (1.8x) |
| GPT-5.4 | 86.8% | $0.03171 (6.8x) |
- Real-World Transfer: When tested on real marketplace skills from ClawHub, the fine-tuned local scanner successfully flagged higher-severity risks while maintaining a low false-positive rate (8.0%) on clean skills.
- Cost Efficiency: Running the 7B model locally on a single A100 GPU proved 6.8x cheaper per detected attack than relying on the frontier GPT-5.4 API.
Limitations and Future Work
- Precision Lower Bound: The scanner achieved a precision of 60.9%, resulting in several false positives. However, direct inspection showed that many "false positives" were actually the scanner correctly identifying inherent security risks (like unconstrained URL connections) in unmodified, "clean" skills.
- Model-Dependent Prefilling: While forcing the Phase 4 header prefill significantly helped the Qwen model (+9.2 pp), it actually degraded performance for Llama, Mistral, and Gemma models, indicating that prefilling strategies remain highly architecture-dependent.
- Future Directions: The authors suggest that future work should explore pairing this local scanner with a frontier baseline to dynamically refine precision and better handle borderline policy violations.
Summary updated