arXiv:2511.05867cs.CRcs.CL2025-11

用合成日志测试大模型识别MCP服务器风险的能力

Can LLM Infer Risk Information From MCP Server System Logs?

  • 构建9类风险的1800条合成日志,嵌入243个模拟MCP服务
  • 微调模型误报率高,强化学习使小模型准确率达83%
  • 适合关注LLM安全、工具链防护的研究者和开发者

大型语言模型(LLMs)在集成外部工具时展现出解决复杂任务的强大能力,而模型上下文协议(MCP)已成为支持此类交互的标准接口。然而,这种交互引入了显著的安全隐患,尤其当MCP服务器被攻破或不可信时。尽管现有基准主要关注提示注入攻击或分析LLM-MCP交互轨迹中的漏洞,但对恶意MCP服务器相关的系统日志却关注不足。为此,我们提出了首个用于评估LLMs从系统日志中识别安全风险的合成基准。定义了九类MCP服务器风险,使用十种先进LLMs生成1,800条合成日志,并将其嵌入243个精心筛选的MCP服务器返回值中,形成包含2,421条聊天历史的训练数据集和471个评估查询。初步实验表明,小模型常无法检测到风险日志,导致高漏报;经监督微调(SFT)训练的模型则过度标记良性日志,引发高误报;而采用可验证奖励强化学习(RLVR)方法后,模型在精确率与召回率间取得更好平衡。特别是经过分组相对策略优化(GRPO)训练的Llama3.1-8B-Instruct模型达到83%准确率,超越最佳远程大模型9个百分点。细粒度分类分析进一步证明强化学习在提升MCP框架下LLM安全性方面的有效性。代码与数据已开源。

原文摘要 · Abstract (English)

Large Language Models (LLMs) demonstrate strong capabilities in solving complex tasks when integrated with external tools. The Model Context Protocol (MCP) has become a standard interface for enabling such tool-based interactions. However, these interactions introduce substantial security concerns, particularly when the MCP server is compromised or untrustworthy. While prior benchmarks primarily focus on prompt injection attacks or analyze the vulnerabilities of LLM-MCP interaction trajectories, limited attention has been given to the underlying system logs associated with malicious MCP servers. To address this gap, we present the first synthetic benchmark for evaluating LLMs' ability to identify security risks from system logs. We define nine categories of MCP server risks and generate 1,800 synthetic system logs using ten state-of-the-art LLMs. These logs are embedded in the return values of 243 curated MCP servers, yielding a dataset of 2,421 chat histories for training and 471 queries for evaluation. Our pilot experiments reveal that smaller models often fail to detect risky system logs, leading to high false negatives. While models trained with supervised fine-tuning (SFT) tend to over-flag benign logs, resulting in elevated false positives, Reinforcement Learning with Verifiable Reward (RLVR) offers a better precision-recall balance. In particular, after training with Group Relative Policy Optimization (GRPO), Llama3.1-8B-Instruct achieves 83 percent accuracy, surpassing the best-performing large remote model by 9 percentage points. Fine-grained, per-category analysis further underscores the effectiveness of reinforcement learning in enhancing LLM safety within the MCP framework. Code and data are available at https://github.com/PorUna-byte/MCP-RiskCue.

LLM安全日志分析MCP强化学习

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