As LLM agents increasingly rely on third-party tools served through the Model Context Protocol (MCP), they inherit a critical supply-chain attack surface, which we term MCP Tool Trojans, an emerging class of attacks that embed malicious code inside the implementation of seemingly benign MCP tools. Their names, descriptions, and outputs remain unchanged, while the hidden code covertly probes internal networks, exfiltrates data, or contacts attacker infrastructure at runtime. Unlike MCP Tool Poisoning, which injects instructions that the LLM must read and follow, MCP Tool Trojans never manipulate the model, rendering them invisible to existing MCP scanners and semantic guardrails. To study this threat, we introduce MCPTrojanBench, the first large-scale benchmark of MCP Tool Trojans, which injects 29 network-visible attacks derived from MITRE ATT&CK into 139 real-world MCP servers, yielding over 24,000 trojaned tool instances validated through captured network traffic. Our evaluation on MCPTrojanBench reveals that existing MCP scanners and I/O-based guardrails are almost entirely blind to these attacks. To address this gap, we propose ShieldNet, a network-level guardrail that detects MCP Tool Trojans from the traffic generated during tool execution. ShieldNet integrates a man-in-the-middle proxy for TLS decryption, an event extractor that distills raw packets into structured events, and a lightweight post-trained detector. Extensive experiments show that ShieldNet achieves 0.995 F1 with only 0.8% false positives at the trace level, reduces false positives by over 15$\times$ compared with frontier LLMs including GPT-6 Astra and Claude Opus 5, generalizes to unseen servers and attacks, and adds little runtime overhead.
翻译:暂无翻译