TL;DR
Current LLM agents for automated penetration testing struggle with complex, multi-step attacks because they cannot evaluate task difficulty in real time, causing them to get stuck in infinite loops or exhaust their context windows. To solve this, the authors introduce PENTESTGPT V2, an autonomous agent that combines robust tool tracking with a difficulty-aware planning framework. By dynamically assessing tractability and guiding an algorithmic tree search, PENTESTGPT V2 achieves up to a 91% success rate on web security benchmarks and doubles baseline performance in complex enterprise environments.
What Problem Does This Paper Address?
While Large Language Models (LLMs) show massive promise for automating cybersecurity operations, their performance varies wildly when deployed as autonomous penetration testing agents. Existing architectures often achieve strong results on simple, isolated tasks but fail catastrophically on realistic, multi-step attack chains.
To find out why, the authors systematically analyzed 28 LLM-based penetration testing systems and categorized their failures into two distinct modes:
- Type A (Capability Gaps): Failures stemming from missing tools, incorrect command syntax, or poorly parsed outputs. These are straightforward engineering problems.
- Type B (Complexity Barriers): Strategic failures where the agent possesses the right tools but fails to navigate the attack space effectively. This includes premature commitment to dead-end paths, an inability to balance exploration vs. exploitation, and "context forgetting" during long campaigns.
Crucially, the authors found that as underlying LLMs improve (e.g., moving from GPT-4o to newer frontier models), the performance gaps between existing agent architectures compress. This indicates that current systems are merely patching transient model limitations (like small context windows) rather than solving the persistent structural challenges of penetration testing. The root cause of Type B failures is that agents lack a mechanism to estimate task difficulty in real time.
Methods
The authors present PENTESTGPT V2, a single-agent architecture designed to mitigate both Type A and Type B failures through three core components:
- Tool and Skill Layer: Eliminates Type A failures by exposing 38 security tools through strictly typed input/output interfaces. It also introduces "Skill Composition"—combining multiple tool invocations into expert attack patterns with built-in fallback logic—and a localized Retrieval-Augmented Generation (RAG) system for tool and exploit documentation.
- Task Difficulty Assessment (TDA): A mechanism that mathematically computes a real-time Task Difficulty Index (TDI) across four dimensions:
- Horizon Estimation ($H$): The estimated number of remaining steps to reach the goal.
- Historical Success Rate ($S$): A Laplace-smoothed metric tracking failed attempts on the current branch.
- Context Load ($C$): The fraction of the LLM's context window consumed.
- Evidence Confidence ($E$): A score reflecting the strength of gathered evidence (e.g., verified credentials vs. speculative hypotheses).
- Evidence-Guided Attack Tree Search (EGATS): Rather than relying on the LLM to maintain the attack state in its prompt history, EGATS manages the attack tree externally. It uses an adapted Upper Confidence Bound (UCB) formula penalized by the TDI to dynamically switch between exploration (Breadth-First Search) and exploitation (Depth-First Search), actively pruning branches when they become intractable.
- Memory Subsystem: A hybrid architecture featuring an external structured "State Store" database that tracks hosts, services, credentials, sessions, and vulnerabilities, paired with selective context injection to keep the LLM's active working window under a safe 40% load threshold.
Datasets
PENTESTGPT V2 was evaluated across three benchmarks representing increasing levels of realism and complexity:
- XBOW: A dataset of 104 CTF-style web security challenges (SQL injection, XSS, auth bypass) designed to isolate short-horizon tool usage (Type A scenarios).
- PentestGPT Benchmark: A collection of 13 targets from Hack The Box (HTB) and VulnHub requiring end-to-end penetration testing (9–22 subtasks per machine) across non-linear attack paths.
- GOAD (Game of Active Directory): A highly complex, 5-host multi-domain Windows network environment requiring chained techniques like Kerberoasting, lateral movement, and domain escalation (Type B scenarios).
- Live Competition (HTB Season 8): A deployment against 13 newly released, unreleased-walkthrough machines to test real-world viability against recent CVEs.
Key Insights and Ideas
- Architectural Convergence: As backbone LLMs scale, the benefits of naive multi-agent role separation or simple text-based task trees erode. Durable agent value requires algorithmic state management that complements, rather than patches, the model.
- The 40% Context Inflection Point: Through a controlled context degradation study, the authors proved that LLM instruction-following accuracy in penetration testing drops linearly once context load exceeds 40%, leading to severe "lost in the middle" phenomena.
- Strategic Backtracking: By tracking evidence confidence, PENTESTGPT V2 can mimic human intuition. If an exploitation path yields dropping confidence scores, the agent actively backtracks to discover alternative vectors rather than brute-forcing a dead end.
Key Results
PENTESTGPT V2 was benchmarked against four prominent baseline systems (PentestGPT v1.0, AutoPT, PentestAgent, and VulnBot) using frontier models in both standard and thinking modes:
- XBOW: Achieved a peak task completion rate of 91% using Claude Opus 4.5 in thinking mode, representing a 49% relative improvement over the best baseline.
- PentestGPT Benchmark: Successfully rooted 12 out of 13 machines, solving hard-rated targets where all baseline systems became permanently stuck at initial enumeration steps.
- GOAD: Compromised 4 out of 5 hosts, effectively doubling the performance of prior systems (which capped out at 2 hosts) by successfully executing multi-host credential chaining.
- Real-World Viability: In the live HTB Season 8 competition, the agent solved 10 of 13 machines, placing it in the top 100 out of 8,036 active human participants.
Limitations and Future Work
Despite these impressive gains, the authors highlight three irreducible barriers that current transformer architectures cannot natively resolve:
- The Creativity Barrier: TDA-EGATS optimizes navigation through known attack spaces. When faced with entirely novel, undocumented protocols (such as the custom Protobuf game protocol in the PlayerTwo machine), the agent fails because it cannot invent new exploitation methodologies from scratch.
- The Adversarial Environment Barrier: Active defenses like honeypots or canary tokens can easily poison the agent's external state representation, tricking it into traps due to a lack of adversarial meta-awareness.
- The Temporal Scale Barrier: True penetration testing campaigns take weeks. While the memory subsystem handles intra-session state, the architecture does not yet support cross-session continuity, hierarchical goal decomposition, or long-term strategic patience.
Summary updated