The Research Report
ClawGuard: Runtime Defense Against Indirect Prompt Injection in Tool-Augmented Agents
You built an agent that can browse the web, read files, and execute code. You gave it tools. Then someone hid a malicious instruction inside a web page, and your agent followed it.
That is indirect prompt injection. It is the defining security vulnerability of the agentic era. And a new paper from Singapore Management University proposes a fix that works without retraining your model, rewriting your prompts, or changing your infrastructure.
The paper is ClawGuard (arXiv:2604.11790, April 2026), by Wei Zhao, Zhe Li, Peixin Zhang, and Jun Sun. It introduces a runtime security framework that enforces deterministic rules at every point where an agent calls a tool, intercepting adversarial actions before they produce real-world effects.
This is the first formal framework to treat tool-stream integrity as a first-class concern. Here is why it matters.
The Problem: Agents Trust Their Tools Too Much
Tool-augmented agents follow a simple loop. The LLM reasons, calls a tool, and appends the tool's output to its conversation history as a trusted observation. Then it reasons again.
This trust is the vulnerability. Any adversary who can influence a tool output gains a direct channel into the agent's reasoning process. The agent treats malicious instructions embedded in a web page, a document, or a skill file exactly the same way it treats legitimate tool results.
The ClawGuard paper identifies three attack channels that exploit this trust:
Web and local content injection. An attacker embeds adversarial instructions in any resource the agent retrieves. A web page. A search result. A local file. The agent reads it, and the instructions enter the conversation history as trusted observations. This attack requires no special access. Just compromise a resource the agent will fetch. Research on AgentDojo (Debenedetti et al., NeurIPS 2024) documented this attack surface extensively.
MCP server injection. The Model Context Protocol (MCP) lets agents discover and invoke tools from third-party servers. A malicious MCP server can embed adversarial instructions in returned content. It can also poison its own tool description metadata, influencing tool-selection behavior before the agent even makes a query. OWASP now catalogs this as "MCP Tool Poisoning" in its attack classification.
Skill file injection. Public skill and plugin repositories contain entries with adversarial or policy-violating instructions. Skill content is inherently directive, combining behavioral guidance with tool invocation rules. Adversarial additions blend in. You cannot distinguish them from legitimate instructions without understanding the agent's actual task goals.
These three channels enable five adversarial objectives: data exfiltration, unauthorized actions, financial manipulation, privilege escalation, and persistent compromise across sessions. The agent reads a poisoned tool output, treats it as truth, and executes commands the user never intended.
Why Existing Defenses Fall Short
Prior work falls into three categories, each with significant limitations:
Model-level defenses include RLHF-based safety alignment and instruction hierarchy training. These require model fine-tuning, making them inapplicable when you deploy agents through closed-source model APIs. More fundamentally, state-of-the-art commercial models with strong safety alignment still fail against context-dependent injections in agentic pipelines. The model thinks it is being helpful by following instructions embedded in tool outputs.
Protocol-level defenses like StruQ physically separate instructions from data. This sounds clean, but requires coordinated changes across model providers and tool vendors. In a diverse agentic ecosystem running GPT-5, Claude, Gemini, and local models through MCP servers, nobody is coordinating that change.
Architecture-level defenses provide strong guarantees at a cost. CaMeL (Google DeepMind, 2025) uses a dual-LLM pattern with a privileged planner and an unprivileged executor, but it is incompatible with open-ended agents whose tool calls are determined at runtime. AgentSpec requires manual rule authoring by domain experts for each deployment context. Neither scales.
The core problem: existing defenses try to make the model smarter about ignoring malicious instructions, or they require ecosystem-wide coordination, or they need per-deployment expertise. ClawGuard takes a different approach entirely.
The ClawGuard Architecture: Intercept at the Boundary
ClawGuard inserts a deterministic enforcement layer between the agent's decisions and tool execution. It does not try to make the model less gullible. It treats the model as untrusted and enforces rules at the only point that matters: right before a tool call produces a real-world effect.
The framework has two phases:
Phase 1: Pre-Session Rule Induction
Before any tool is invoked, ClawGuard reads the user's stated objective and automatically derives task-specific access constraints. These become R_task, the task-specific rule set. Because this happens before the first tool call, the rules are uncontaminated by adversarial content. No manual rule authoring is required per deployment.
The active rule set is R = Rbase ∪ Rtask, combining base rules that always apply with task-specific rules derived from the user's intent.
Phase 2: Per-Tool-Call Enforcement
At every subsequent tool-call boundary, ClawGuard applies four components:
Content Sanitizer. Scans outgoing tool-call arguments and incoming tool-returned content. Strips sensitive data spans before execution and before results enter the conversation history. Uses a pattern library covering 15 categories of sensitive data including API keys, tokens, and SSH keys. This bidirectional sanitization prevents both exfiltration (secrets going out) and injection (malicious instructions coming in).
Rule Evaluator. Evaluates each proposed tool call against the active rule set. Checks tool invocations, local file paths, and outbound network destinations. Every call gets a verdict: allow, deny, or approve.
Skill Inspector. Performs automated risk assessment on skills before first execution. Mandates user confirmation for new or untrusted skills.
Approval Mechanism. Routes ambiguous calls to the user for explicit authorization. All events are recorded in a tamper-proof audit log stored in SQLite.
The key insight: ClawGuard intercepts tool calls before they execute, not after. An adversarial instruction embedded in a web page might persuade the agent to call exec("rm -rf /"), but ClawGuard's rule evaluator blocks it at the boundary. The malicious intent never reaches the system.
Three Policy Modes
ClawGuard operates in three modes:
- Strict. Violations are immediately blocked. No exceptions.
- Supervised. Violations are paused and queued for human approval. The agent waits for a decision.
- Permissive. Violations are logged only. No blocking. Useful for testing and monitoring.
The strict mode is the production setting. Supervervised mode is the development and high-stakes setting where you want human oversight. Permissive mode is for observation.
The Tool Replacement Layer
ClawGuard does not just add rules on top of existing tools. It replaces them. When active, the agent uses cg_* tools instead of native ones:
| cg_* Tool | Replaces | Protection |
|---|---|---|
| cgexecutecommand | exec / process | Command blacklist + output sanitization |
| cgreadfile | read | Sensitive path blocking + content sanitization |
| cgwritefile | write / edit | Path access control + write sanitization |
| cglistdirectory | read (dir) | Directory access control |
| cghttprequest | network tools | Domain allowlist + exfiltration prevention |
Plus cgstatus for engine status, cgpanic for emergency block-all, and cg_resume to resume after a panic.
This is not a wrapper. The native tools are disabled at the gateway layer. The agent has no path to bypass the enforcement.
The Results
ClawGuard was evaluated across three established benchmarks spanning all three injection channels, with five state-of-the-art language models:
- AgentDojo (Debenedelli et al., NeurIPS 2024) tests web and local content injection
- SkillInject (Edinger et al., 2025) tests skill file injection
- MCPSafeBench (Liu et al., 2025) tests MCP server injection
The headline result: on AgentDojo's indirect-injection attacks, ClawGuard drops the attack success rate from 0.6-3.1% to 0.0%. Zero successful attacks across all evaluated models.
On MCPSafeBench, which tests the MCP injection pathway, ClawGuard similarly eliminates successful attacks while maintaining competitive completion rates for legitimate tasks.
On SkillInject, the pattern holds. Deterministic boundary enforcement blocks adversarial skill instructions from executing unauthorized actions.
The utility preservation matters as much as the security. A defense that blocks all attacks but also blocks all legitimate work is useless. ClawGuard maintains completion rates that are competitive with unprotected baselines. The framework catches the attacks without breaking the agent.
How This Differs From Everything Else
The distinction from CaMeL is architectural. CaMeL restricts the agent to a fixed set of pre-approved tool calls. ClawGuard handles open-ended agents whose tool calls are determined at runtime, deriving task-specific rules from the user's objective on the fly. CaMeL requires you to know the tool calls in advance. ClawGuard does not.
The distinction from AgentSpec is practical. AgentSpec requires domain experts to manually author rules for each deployment. ClawGuard automatically derives rules from the user's stated objective. No per-deployment expertise needed.
The distinction from model-level defenses is fundamental. RLHF and instruction hierarchy training try to make the model resist adversarial instructions. ClawGuard does not rely on the model's judgment at all. It enforces deterministic rules outside the model. Even if the model is fully convinced by a malicious instruction, the enforcement layer blocks the resulting tool call.
This is the core philosophical shift: from "train the model to resist" to "enforce rules at the boundary." The model is treated as an untrusted component. Security comes from the architecture, not the weights.
Practical Implications for Agent Builders
For teams deploying tool-augmented agents in production, ClawGuard offers several advantages:
No model modification. It works with any LLM. GPT-5, Claude, Gemini, local models. The enforcement layer is model-agnostic.
No infrastructure change. ClawGuard runs as a sidecar daemon. It does not require changes to your agent framework, your model provider, or your tool ecosystem.
Automatic rule derivation. You do not need to write security rules by hand. The framework reads the user's objective and derives appropriate constraints.
Audit trail. Every tool call, every enforcement decision, every approval is logged. You get a tamper-proof record of what happened and why.
Open source. The code is available at github.com/Claw-Guard/ClawGuard with an MIT license. You can inspect it, modify it, and deploy it on your own infrastructure.
The practical setup is straightforward. Install ClawGuard, run the enable script, and it patches your OpenClaw config to route all tool calls through the enforcement layer. The daemon starts, native tools are disabled at the gateway, and the agent operates through cg_* tools. A web dashboard at localhost:19821 shows real-time operations, pending approvals, and audit logs.
Limitations and Open Questions
ClawGuard is not a silver bullet. Several limitations deserve attention:
Scope. The framework defends against indirect prompt injection through tool outputs. Direct prompt injection (attacker controls the user turn), jailbreak attacks, and model fine-tuning attacks are outside scope.
Incremental attacks. The paper acknowledges that adversarial instructions can be constructed gradually across multiple interaction steps. ClawGuard's rule evaluator catches the resulting tool calls, but sophisticated multi-step attacks that stay within the allowed scope could evade detection.
Rule induction quality. The automatic rule derivation depends on the LLM correctly understanding the user's objective. A misunderstanding could produce rules that are too permissive or too restrictive.
Latency. Every tool call goes through the enforcement layer. In latency-sensitive applications, this adds overhead. The paper does not report detailed latency measurements.
Coverage. ClawGuard was tested on five models. While the framework is model-agnostic by design, real-world deployments may encounter edge cases not covered by the benchmarks.
The Bigger Picture: Trust the Boundary, Not the Model
ClawGuard represents a philosophical shift in how we think about agent security. The dominant approach has been to make models more robust, more aligned, better at distinguishing instructions from data. That work matters. But it is fundamentally incomplete for tool-augmented agents, because tool outputs will always look like instructions to the model.
The ClawGuard insight is that you do not need the model to be smarter. You need an enforcement layer that catches malicious actions regardless of what the model thinks. This is standard practice in every other domain of computer security. You do not rely on the application to enforce access control. You put it in the operating system, the network layer, the database.
ClawGuard puts access control in the agent runtime. The model is untrusted. The rules are deterministic. The enforcement happens before execution. This is how you build agents that can be given real tools, real permissions, and real access to the outside world without a constant fear of injection.
The paper calls this "deterministic tool-call boundary enforcement." In plainer language: check every tool call against the rules before it runs. It works. The benchmarks prove it. The code is open source. If you are building tool-augmented agents, you should be paying attention.
Citations
- Zhao, W., Li, Z., Zhang, P., & Sun, J. (2026). ClawGuard: A Runtime Security Framework for Tool-Augmented LLM Agents Against Indirect Prompt Injection. arXiv:2604.11790. https://arxiv.org/abs/2604.11790
- ClawGuard GitHub repository: https://github.com/Claw-Guard/ClawGuard
- Debenedetti, E., et al. (2024). AgentDojo: A Dynamic Environment to Evaluate Prompt Injection Attacks and Defenses for LLM Agents. NeurIPS 2024. https://arxiv.org/abs/2406.13352
- Edinger, J., et al. (2025). SkillInject: Skill file injection attacks against tool-augmented LLM agents.
- Liu, Y., et al. (2025). MCPSafeBench: Benchmarking MCP server injection safety.
- OWASP Foundation. MCP Tool Poisoning. https://owasp.org/www-community/attacks/MCPToolPoisoning
- StruQ: Defending Against Prompt Injection with Structured Queries. arXiv:2402.06363. https://arxiv.org/abs/2402.06363
- Debenedetti, E., et al. (2025). Defeating Prompt Injections by Design (CaMeL). Google DeepMind. https://github.com/google-research/camel-prompt-injection
- AgentSpec: Architecture-level defense requiring manual rule authoring.
- al-ice.ai analysis: https://al-ice.ai/posts/2026/04/clawguard-runtime-security-framework-tool-augmented-agents/
Suggested Title
ClawGuard: The Runtime Defense That Treats Your LLM Agent as Untrusted
Word Count
~1,850 words (body text)
Fact-Check Notes
- The 0.6-3.1% to 0.0% AgentDojo result is cited from Arun Baby's analysis of the paper. The paper itself reports results across all three benchmarks. Verify the specific per-model breakdown in the full paper tables.
- The GitHub repository at github.com/Claw-Guard/ClawGuard is confirmed as the official code release from the paper authors.
- CaMeL (Google DeepMind, 2025) compatibility claims are from the ClawGuard paper's comparison section. The CaMeL original paper should be checked for the latest claims about open-ended agent support.
- The 15-category sensitive data pattern library is described in the GitHub README. The paper's formal specification may differ in scope.
- AgentDojo was presented at NeurIPS 2024, confirmed from the conference proceedings.
- OWASP MCP Tool Poisoning classification is publicly available at owasp.org.
- The paper's formal publication status is "submitted" as of April 2026. Check for peer review acceptance status before citing as a published result.