arXiv:2508.07382cs.AIcs.LG2025-08被引 8

用两阶段强化学习让大模型自主搞渗透测试,效果超多数现有模型。

Pentest-R1: Towards Autonomous Penetration Testing Reasoning Optimized via Two-Stage Reinforcement Learning

  • 分两步训练:先用真实攻防路径离线学基础逻辑,再在实战环境中在线优化。
  • 在AutoPenBench上成功率达24.2%,仅次于顶级商用模型;Cybench上达15.0%,开源模型中领先。
  • 适合研究自动化安全测试、想提升模型自纠错能力的开发者和安全团队。

自动化渗透测试对提升网络安全至关重要,但当前大型语言模型(LLMs)在此领域存在错误处理差、推理效率低、难以自主完成复杂端到端任务等问题。为此,我们提出Pentest-R1框架,通过双阶段强化学习优化LLM的推理能力。首先构建包含500多个真实世界多步骤攻防流程的数据集,用于离线强化学习,以建立基础攻击逻辑;随后在交互式夺旗(CTF)环境中通过在线强化学习微调模型,使其直接从环境反馈中学习鲁棒的错误自纠正与自适应策略。在Cybench和AutoPenBench基准上的实验表明,该框架表现优异:在AutoPenBench上成功率达24.2%,仅次于Gemini 2.5 Flash;在Cybench无引导任务中达到15.0%的成功率,创下开源模型新纪录,媲美顶尖专有模型。消融实验证明两个训练阶段的协同作用至关重要。

原文摘要 · Abstract (English)

Automating penetration testing is crucial for enhancing cybersecurity, yet current Large Language Models (LLMs) face significant limitations in this domain, including poor error handling, inefficient reasoning, and an inability to perform complex end-to-end tasks autonomously. To address these challenges, we introduce Pentest-R1, a novel framework designed to optimize LLM reasoning capabilities for this task through a two-stage reinforcement learning pipeline. We first construct a dataset of over 500 real-world, multi-step walkthroughs, which Pentest-R1 leverages for offline reinforcement learning (RL) to instill foundational attack logic. Subsequently, the LLM is fine-tuned via online RL in an interactive Capture The Flag (CTF) environment, where it learns directly from environmental feedback to develop robust error self-correction and adaptive strategies. Our extensive experiments on the Cybench and AutoPenBench benchmarks demonstrate the framework's effectiveness. On AutoPenBench, Pentest-R1 achieves a 24.2\% success rate, surpassing most state-of-the-art models and ranking second only to Gemini 2.5 Flash. On Cybench, it attains a 15.0\% success rate in unguided tasks, establishing a new state-of-the-art for open-source LLMs and matching the performance of top proprietary models. Ablation studies confirm that the synergy of both training stages is critical to its success.

渗透测试强化学习大模型安全自动化攻防

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