arXiv:2602.22724cs.CRcs.AI2026-02被引 29

提出新方法检测并清除大模型代理中的间接提示攻击,保障任务安全执行。

AgentSentry: Mitigating Indirect Prompt Injection in LLM Agents via Temporal Causal Diagnostics and Context Purification

  • 通过时序因果分析定位攻击发生点,结合反事实重演精准识别异常行为。
  • 在四种攻击类型下平均保持74.55%的任务成功率,优于现有方法20.8~33.6个百分点。
  • 适合高风险场景中使用外部工具的大模型代理系统,提升安全性与可用性。

大型语言模型(LLM)代理越来越多地依赖外部工具和检索系统来自主完成复杂任务。然而,这种设计使其面临间接提示注入(IPI)攻击,即攻击者控制的上下文嵌入工具输出或检索内容中,悄然引导代理偏离用户意图。与基于提示的攻击不同,IPI在多轮交互中逐步展开,使恶意控制难以与合法任务执行分离。现有推理阶段防御主要依赖启发式检测和对高风险动作的保守拦截,可能导致流程提前终止或在模糊多轮场景下过度抑制工具使用。我们提出AgentSentry,一种针对工具增强型LLM代理的新推理阶段检测与缓解框架。据我们所知,它是首个将多轮IPI建模为时序因果接管的防御机制。该方法通过在工具返回边界进行受控反事实重演,定位攻击接管点,并通过因果引导的上下文净化,移除攻击引发的偏差,同时保留任务相关证据。我们在 extsc{AgentDojo}基准上对四个任务套件、三种IPI攻击家族及多个黑盒LLM进行了评估。AgentSentry完全消除成功攻击,维持强任务效用,在攻击下平均实用率(UA)达74.55%,相比最强基线提升20.8至33.6个百分点,且未损害正常性能。

原文摘要 · Abstract (English)

Large language model (LLM) agents increasingly rely on external tools and retrieval systems to autonomously complete complex tasks. However, this design exposes agents to indirect prompt injection (IPI), where attacker-controlled context embedded in tool outputs or retrieved content silently steers agent actions away from user intent. Unlike prompt-based attacks, IPI unfolds over multi-turn trajectories, making malicious control difficult to disentangle from legitimate task execution. Existing inference-time defenses primarily rely on heuristic detection and conservative blocking of high-risk actions, which can prematurely terminate workflows or broadly suppress tool usage under ambiguous multi-turn scenarios. We propose AgentSentry, a novel inference-time detection and mitigation framework for tool-augmented LLM agents. To the best of our knowledge, AgentSentry is the first inference-time defense to model multi-turn IPI as a temporal causal takeover. It localizes takeover points via controlled counterfactual re-executions at tool-return boundaries and enables safe continuation through causally guided context purification that removes attack-induced deviations while preserving task-relevant evidence. We evaluate AgentSentry on the \textsc{AgentDojo} benchmark across four task suites, three IPI attack families, and multiple black-box LLMs. AgentSentry eliminates successful attacks and maintains strong utility under attack, achieving an average Utility Under Attack (UA) of 74.55 %, improving UA by 20.8 to 33.6 percentage points over the strongest baselines without degrading benign performance.

大模型安全提示攻击代理系统因果推理

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