用强化学习自动攻击提示注入防御,发现现有防护普遍脆弱。
PISmith: Reinforcement Learning-based Red Teaming for Prompt Injection Defenses
- 用RL训练攻击模型,在黑盒环境下优化注入提示
- 13个基准测试中,顶尖防御仍易被攻破
- 适合安全研究者和大模型开发者参考
提示注入对实际大模型应用(尤其是自主代理)构成严重安全威胁。尽管已有多种防御措施,但其在对抗性攻击下的鲁棒性评估不足,可能造成虚假安全感。本文提出PISmith,一种基于强化学习的红队框架,通过训练攻击大模型在黑盒场景下优化注入提示,仅能查询受保护的大模型并观察输出。我们发现,直接应用标准GRPO进行攻击时,因奖励极度稀疏——绝大多数注入提示被防御拦截——导致策略熵崩溃,难以发现有效攻击策略,而少数成功案例也无法有效学习。为此,我们引入自适应熵正则化与动态优势加权,维持探索能力并放大稀缺成功信号的学习。在13个基准上的全面评估表明,当前最先进的提示注入防御仍易受自适应攻击。与7种基线(静态、搜索、强化学习类)对比显示,PISmith始终取得最高攻击成功率。此外,其在InjecAgent和AgentDojo的代理场景中,对开源与闭源大模型(如GPT-4o-mini和GPT-5-nano)均表现强劲。代码已公开于https://github.com/albert-y1n/PISmith。
原文摘要 · Abstract (English)
Prompt injection poses serious security risks to real-world LLM applications, particularly autonomous agents. Although many defenses have been proposed, their robustness against adaptive attacks remains insufficiently evaluated, potentially creating a false sense of security. In this work, we propose PISmith, a reinforcement learning (RL)-based red-teaming framework that systematically assesses existing prompt-injection defenses by training an attack LLM to optimize injected prompts in a practical black-box setting, where the attacker can only query the defended LLM and observe its outputs. We find that directly applying standard GRPO to attack strong defenses leads to sub-optimal performance due to extreme reward sparsity -- most generated injected prompts are blocked by the defense, causing the policy's entropy to collapse before discovering effective attack strategies, while the rare successes cannot be learned effectively. In response, we introduce adaptive entropy regularization and dynamic advantage weighting to sustain exploration and amplify learning from scarce successes. Extensive evaluation on 13 benchmarks demonstrates that state-of-the-art prompt injection defenses remain vulnerable to adaptive attacks. We also compare PISmith with 7 baselines across static, search-based, and RL-based attack categories, showing that PISmith consistently achieves the highest attack success rates. Furthermore, PISmith achieves strong performance in agentic settings on InjecAgent and AgentDojo against both open-source and closed-source LLMs (e.g., GPT-4o-mini and GPT-5-nano). Our code is available at https://github.com/albert-y1n/PISmith.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。