Automatic Red Teaming LLM-based Agents with Model Context Protocol Tools

Ping He, Changjiang Li, Binbin Zhao, Tianyu Du, Shouling JiarXiv 2025 · DOI

Abstract

As Large Language Model (LLM) agents increasingly adopt the Model Context Protocol (MCP) for tool interaction, they face a new supply-chain threat: tool poisoning. This paper presents AutoMalTool, an automated framework designed to generate stealthy, malicious MCP tools that hijack agent behavior through manipulated metadata. Evaluated against mainstream agents like Claude Desktop and Cline, AutoMalTool demonstrates that current AI assistants are highly vulnerable to these automated prompt injection attacks, often bypassing existing security scanners with high efficiency and minimal cost.

Introduction: The Vulnerability of MCP-Enabled Agents

To perform tasks beyond text generation—such as managing files, executing financial trades, or sending messages—LLM agents rely on external tools. The Model Context Protocol (MCP) has emerged as a standard for connecting AI models to these external data sources and capabilities. However, this standardization introduces a significant security blind spot: tool poisoning.

The standard workflow of an LLM-based agent interacting with a user and external tools via selection, parameter grounding, and result interpretation.

In a tool poisoning attack, an adversary injects malicious instructions into a tool's metadata (e.g., its text description). When an agent downloads a compromised MCP server package from an open-source registry, it may be tricked into executing unauthorized actions or misinterpreting results. Previously, demonstrating these vulnerabilities required manual prompt engineering. AutoMalTool addresses this by providing an automated, systematic method for red-teaming LLM agents against such threats.

The AutoMalTool Framework

AutoMalTool is a multi-agent framework that treats red-teaming as an iterative optimization problem. Operating in a black-box setting, it utilizes four specialized LLM sub-agents to generate and refine attacks:

  1. Initial Generator: Analyzes a benign MCP tool to create a plausible user task and a draft malicious description. It targets either parameter manipulation (tricking the agent into using incorrect inputs) or result misinterpretation (inducing the agent to lie about the tool's output).
  2. Oracle: Functions as a mock security scanner to detect obvious prompt injections, ensuring the generated attack remains stealthy.
  3. Effectiveness Evaluator: Tests the tool in a simulated sandbox. A "Behavior Judger" verifies if the agent fell for the attack, while a "Failure Reasoner" provides feedback for unsuccessful attempts.
  4. Tool Optimizer: The core engine that rephrases descriptions based on feedback. It employs techniques like framing malicious behavior as "best practices" or using Unicode obfuscation to bypass safety alignments.
The AutoMalTool architecture illustrating the iterative loop between generation, evaluation, and optimization to produce effective and evasive malicious tools.

Experimental Evaluation

The authors evaluated AutoMalTool against two prominent agents: Claude Desktop (general assistant) and Cline (coding assistant), using various backend models including Claude 3.7/4, GPT-4.1, and DeepSeekV3.1. The testing suite utilized 53 distinct tools from real-world MCP servers covering financial trading (Alpaca), messaging (WhatsApp), and local file management.

Key Insights and Results

  • High Attack Success: AutoMalTool generated viable malicious tools for approximately 85% of scenarios. Against actual agents, these tools induced the targeted behavior 35.3% of the time on average, with some combinations exceeding 70% success.
  • Extreme Evasiveness: The generated tools successfully bypassed state-of-the-art scanners like MCP-Scan (86-97% evasion) and Tencent's A.I.G (76-92% evasion).
  • Input vs. Output Manipulation: Tricking agents into using wrong parameters was significantly easier than forcing them to misinterpret outputs. The latter requires the model to both execute the task and maintain a convincing lie, which is cognitively more demanding.
  • Sophistication vs. Robustness: Interestingly, increased model sophistication did not equate to better security; for instance, GPT-4.1 showed more robustness against these specific attacks than newer experimental versions.
  • Efficiency: Generating a fully optimized malicious tool costs roughly $0.03 and takes only 200 seconds, highlighting the low barrier to entry for potential attackers.

Conclusion

AutoMalTool exposes a critical vulnerability in the current LLM tool-use ecosystem. Because static metadata scanners are easily bypassed, the authors advocate for the development of dynamic, behavior-based anomaly detection for MCP servers. Furthermore, the outputs of frameworks like AutoMalTool can serve as adversarial training data to harden future LLM agents against supply-chain prompt injections.

Summary updated

BibTeX
@misc{he2025automatic,
  author = {Ping He and Changjiang Li and Binbin Zhao and Tianyu Du and Shouling Ji},
  title = {{Automatic Red Teaming LLM-based Agents with Model Context Protocol Tools}},
  year = {2025},
  eprint = {2509.21011},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.21011},
}
Figure