为大模型工具调用设计自适应信任校准安全层,防范第三方服务器攻击
MCPShield: A Security Cognition Layer for Adaptive Trust Calibration in Model Context Protocol Agents
- 通过元数据探测构建安全认知,调用前验证工具可信性
- 在六种新攻击场景中有效防御,对正常服务器零误报
- 适合开放生态中依赖第三方工具的大模型智能体使用
Model Context Protocol(MCP)标准统一了基于大语言模型的智能体调用工具的方式,并支持第三方服务器。这种开放性引入了安全错位问题:智能体会默认信任由潜在不可信的MCP服务器暴露的工具。然而,尽管该标准极具实用性,现有智能体对第三方MCP服务器的验证能力有限。因此,智能体在整个工具调用生命周期中仍易受基于MCP的攻击。本文提出MCPShield,一个可插拔的安全认知层,以缓解这一错位并保障调用过程中的安全性。受人类经验驱动的工具验证启发,MCPShield在调用前通过元数据引导探测,辅助智能体建立安全认知;在执行过程中约束于可控边界并感知运行时事件;调用后通过推理历史行为轨迹更新安全认知,类比人类对工具使用后的反思。实验表明,MCPShield在六种广泛使用的代理型大模型上,对六种新型MCP攻击均表现出强泛化防御能力,对良性服务器无误报,且部署开销极低。整体而言,本工作为开放智能体生态系统中基于MCP的工具调用提供了实用而稳健的安全保障。
原文摘要 · Abstract (English)
The Model Context Protocol (MCP) standardizes tool use for LLM-based agents and enable third-party servers. This openness introduces a security misalignment: agents implicitly trust tools exposed by potentially untrusted MCP servers. However, despite its excellent utility, existing agents typically offer limited validation for third-party MCP servers. As a result, agents remain vulnerable to MCP-based attacks that exploit the misalignment between agents and servers throughout the tool invocation lifecycle. In this paper, we propose MCPShield as a plug-in security cognition layer that mitigates this misalignment and ensures agent security when invoking MCP-based tools. Drawing inspiration from human experience-driven tool validation, MCPShield assists agent forms security cognition with metadata-guided probing before invocation. Our method constrains execution within controlled boundaries while cognizing runtime events, and subsequently updates security cognition by reasoning over historical traces after invocation, building on human post-use reflection on tool behavior. Experiments demonstrate that MCPShield exhibits strong generalization in defending against six novel MCP-based attack scenarios across six widely used agentic LLMs, while avoiding false positives on benign servers and incurring low deployment overhead. Overall, our work provides a practical and robust security safeguard for MCP-based tool invocation in open agent ecosystems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。