arXiv:2604.10534cs.CRcs.AI2026-04

用机器学习检测大模型工具的恶意调用,准确率超90%。

Machine Learning-Based Detection of MCP Attacks

论文配图:Machine Learning-Based Detection of MCP Attacks
图 1 · 摘自论文原文
  • 构建多种机器学习模型,区分恶意与正常MCP工具描述。
  • 二分类任务达100%准确率,多分类任务最优模型F1超90%。
  • 优于传统规则方法,可部署为实时安全中间件。

模型上下文协议(MCP)是一项新兴技术,扩展了大语言模型的功能,但同时也引入了新的攻击面。尽管已有研究指出其安全缺陷,但针对MCP攻击的检测仍缺乏系统探索。本研究开发并评估了多种监督式机器学习方法,涵盖传统与深度学习模型,在两种场景下测试:(1)二分类任务,区分恶意与良性工具;(2)多分类任务,识别攻击类型并分离良恶性工具。此外还对比了基于规则的基线方法。结果表明,多个模型在二分类任务中达到100% F1得分;在多分类任务中,SVC和BERT模型表现最佳,分别取得90.56%和88.33%的F1分数。通过混淆矩阵可视化预测分布,揭示了传统指标忽略的误判模式,为实际部署提供参考。研究提出一种中间件方案,可在执行前实时判断MCP工具安全性并拦截风险项。实验显示,所提模型优于当前领域内广泛使用的规则方法。

原文摘要 · Abstract (English)

The Model Context Protocol (MCP) is a new and emerging technology that extends the functionality of large language models, improving workflows but also exposing users to a new attack surface. Several studies have highlighted related security flaws, but MCP attack detection remains underexplored. To address this research gap, this study develops and evaluates a range of supervised machine learning approaches, including both traditional and deep-learning models. We evaluated the systems on the detection of malicious MCP tool descriptions in two scenarios: (1) a binary classification task distinguishing malicious from benign tools, and (2) a multiclass classification task identifying the attack type while separating benign from malicious tools. In addition to the machine learning models, we compared a rule-based approach that serves as a baseline. The results indicate that several of the developed models achieved 100\% F1-score on the binary classification task. In the multiclass scenario, the SVC and BERT models performed best, achieving F1 scores of 90.56\% and 88.33\%, respectively. Confusion matrices were also used to visualize the full distribution of predictions often missed by traditional metrics, providing additional insight for selecting the best-fitting solution in real-world scenarios. This study presents an addition to the MCP defence area, showing that machine learning models can perform exceptionally well in separating malicious and benign data points. To apply the solution in a live environment, a middleware was developed to classify which MCP tools are safe to use before execution, and block the ones that are not safe. Furthermore, the study shows that these models can outperform traditional rule-based solutions currently in use in the field.

安全检测机器学习大模型MCP

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。