ToolHazard:扩展对抗环境以评估和校准基于LLM的代理的安全性

·

研究论文 · 2026/08/14

大型语言模型(LLM)代理在与外部工具集成时,容易受到嵌入在环境状态中的间接提示注入攻击。然而,现有研究大多依赖手动实现或复用的环境、基于随机LLM的工具模拟以及预定义的注入位置,限制了在更广泛领域中的可扩展安全研究。为弥补这一差距,我们提出了ToolHazard,一个可扩展的对抗性环境合成框架,减少了人工工程,并支持通过额外的种子领域和计算资源进行扩展。通过环境模拟器、攻击者代理和用户模拟器,ToolHazard合成了可执行的有状态环境,发现可行的注入点并生成特定于环境的载荷,并构建基于状态的长时程任务。基于ToolHazard,我们构建了ToolHazard-Bench,用于在复杂工作流和多样环境攻击下对代理进行压力测试。实验揭示了代理的显著脆弱性,并表明注入时机和位置影响攻击效果。此外,ToolHazard生成的对齐数据在ToolHazard-Bench和AgentDojo上均提高了安全性,同时保持了良性任务的效用。

该论文针对LLM代理安全评估中环境合成可扩展性不足的问题,提出了系统化的解决方案,并提供了基准测试和实证结果,对安全对齐研究具有重要参考价值。

Large language model (LLM) agents integrated with external tools are vulnerable to indirect prompt injections embedded in environmental states. However, existing studies largely rely on manually implemented or reused environments, stochastic LLM-based tool simulation, and predefined injection locations, limiting scalable security research across broader domains. To bridge this gap, we propose **ToolHazard**, a scalable adversarial environment synthesis framework that reduces human engineering and supports expansion with additional seed domains and compute. Through an Environment Simulator, an Attacker Agent, and a User Simulator, ToolHazard synthesizes executable stateful environments, discovers viable injection points and generates environment-specific payloads, and constructs state-grounded long-horizon tasks. Based on ToolHazard, we build **ToolHazard-Bench** for stress-testing agents under complex workflows and diverse environmental attacks. Experiments reveal substantial agent vulnerabilities and show that injection timing and placement affect attack effectiveness. Moreover, ToolHazard-generated alignment data improves security on both ToolHazard-Bench and AgentDojo while preserving benign task utility.

阅读原文

参与讨论