1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 ICAIMT-Agentic AI for Offensive Security: LLM-Guided Autonomous Red Teaming in a Limited Cyber-Range Environment Atif Chowhan1,2, Yasir Hamid2 1,2 Dakota State University, USA 2 Abu Dhabi Polytechnic, Abu Dhabi, UAE Email: muhammad.chowhan@actvet.gov.ae, atif.chowhan@trojans.dsu.edu, yasir.hamid@actvet.gov.ae Abstract Agentic artificial intelligence (AI) is increasingly being explored for automating offensive security and red teaming tasks, enabling systems that can coordinate multi-step cyber operations through structured decision-making. While prior research has investigated reinforcement learning (RL) agents and large language models (LLMs) for penetration testing, most studies are evaluated in simulated or abstract environments, with limited empirical validation in real cyber-range settings. This paper presents a controlled experimental evaluation of an LLM-guided offensive security pipeline against deterministic scripted baselines in a cyber-range environment. Using a vulnerable Kioptrix virtual machine and a Kali Linux attacker, we implement three deterministic pipelines, fixed-path, sequential, and rule-based alongside two configurations of an LLM-guided agent: an initial version (LLM V1) and a refined constrained controller (LLM V2). All approaches operate within a restricted and auditable action space executed through predefined tools. Across repeated trials, the initial LLM configuration exhibits reduced reliability and increased execution cost due to exploratory behaviour. In contrast, the refined controller achieves a 100% success rate, reduces execution steps, eliminates wasted actions, and matches the efficiency of rule-based automation. These results show that, within a controlled cyber-range environment, LLM-guided agents can approximate deterministic performance when appropriate constraints are applied. This suggests that agent-based approaches to offensive security can support semi-autonomous red teaming workflows, provided that decision-making is governed by structured control policies. Keywords Autonomous penetration testing, Agentic AI, red teaming, large language models, reinforcement learning, cyber ranges, Metasploit. 1 Introduction Penetration testing plays a critical role in identifying vulnerabilities and assessing the security posture of systems before adversaries can exploit them. Despite the availability of advanced tools, most offensive security workflows still rely heavily on human expertise to coordinate reconnaissance, enumeration, and exploitation activities. This dependence limits scalability, repeatability, and the ability to systematically explore complex attack surfaces. Recent work has explored the use of automated agents to support offensive security tasks by combining decision-making and tool execution within a single workflow. Such approaches aim to reduce manual effort by allowing systems to select actions based on observed outputs and predefined objectives. To address the limitations of manual workflows, prior research has investigated reinforcement learning (RL) for automating penetration testing tasks [1-4]. These approaches model attackers as agents interacting with an environment and learning policies to maximize attack success. While RL-based methods show promise, they are typically evaluated in simulated environments and often require extensive training, limiting their applicability to real-world systems. 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 More recently, large language models (LLMs) have been used to coordinate multi-step cyber operations. LLM-based approaches can interpret tool outputs, reason about possible next steps, and select actions using structured prompts, enabling a more flexible form of automation [6-10]. However, existing studies are often evaluated in loosely defined or unconstrained settings and frequently lack controlled comparisons with deterministic baselines. This creates an important gap: it remains unclear whether LLM-guided systems provide measurable advantages over structured scripted pipelines, particularly in controlled environments where deterministic logic can already achieve optimal performance. In addition, the extent to which such systems can operate reliably depends on how their decision-making process is constrained. To address this gap, this paper presents a controlled experimental evaluation of an LLM-guided offensive security pipeline in a cyber-range environment. The study evaluates five configurations: fixed-path, sequential, and rule-based baselines, along with two versions of an LLM-guided agent (LLM V1 and LLM V2). All configurations operate under identical infrastructure, tooling, and constraints, enabling a direct and reproducible comparison. The cyber-range setup intentionally represents a limited and controlled environment, allowing precise analysis of system behaviour under known conditions. The objective is not to demonstrate full-scale autonomous red teaming, but to isolate and evaluate the decision-making process of LLM-guided pipelines within a constrained setting. In addition to comparing LLM-based control with deterministic approaches, this work examines how controller design influences performance. Specifically, we evaluate an initial configuration that allows exploratory behaviour and a refined version that incorporates structured constraints such as service prioritization and bounded action selection. The study is guided by the following research questions: RQ1: How does the performance of an LLM-guided offensive security pipeline compare to deterministic scripted baselines in a controlled cyber-range environment? RQ2: How does controller design affect the reliability and efficiency of such systems? RQ3: Can a constrained configuration achieve performance comparable to rule-based automation while maintaining flexibility? The contributions of this paper are as follows: 1. Controlled Comparative Evaluation: A direct, execution-grounded comparison between deterministic baselines and an LLM-guided pipeline under identical experimental conditions. 2. Controller Design Analysis: An evaluation of how constraints influence system behaviour, transforming exploratory execution into reliable and efficient operation. 3. Reproducible Cyber-Range Experimentation: Implementation and evaluation of all configurations in a controlled environment using consistent metrics, providing a reproducible foundation for future research. 2 Background and Related Work This section situates our study at the intersection of two active lines of research: autonomous penetration testing and LLM-assisted red teaming. We first review how reinforcement-learningbased approaches evolved from simulated environments toward more realistic cyber ranges. We then examine recent LLM-driven pentesting systems and related discussions on safety, auditability, and human oversight that motivate the constrained agent design used in this work. 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 Figure 1 illustrates the key differences between traditional scripted pipelines and LLM-guided agents, highlighting the shift from fixed logic to adaptive decision-making. Figure 1: Conceptual comparison between traditional scripted penetration testing workflows and LLM-guided agentic approaches. Scripted methods rely on fixed logic, while LLM-based agents enable adaptive and extensible decision-making in multi-service environments. 2.1 RL-Based Autonomous Penetration Testing Autonomous penetration testing using reinforcement learning (RL) has evolved from proof-ofconcept prototypes to a relatively mature research area. Liu et al. provide a comprehensive survey of RL for autonomous penetration testing, highlighting how different formulations (Markov decision processes, partially observable settings, and multi-agent variants) have been used to learn attack policies over simulated or emulated networks [11]. The survey categorises work by environment fidelity, attack surface coverage, and optimisation objective (for example, shortest path to compromise versus maximum damage), and underscores recurring challenges such as sparse rewards, large action spaces, and the difficulty of scaling from toy topologies to enterprisegrade infrastructures. PenGym directly addresses the realism gap by proposing a training framework that couples RL agents with real penetration testing environments while preserving a Gym-style API for the learning loop [1]. Instead of interacting with purely symbolic nodes and edges, PenGym agents trigger actual scans and exploits through scripts, providing more faithful feedback about timing, errors, and side-effects. SetTron focuses on generalisation across network configurations: it introduces set-structured state representations and inductive biases that enable an RL policy trained on some host layouts to transfer more robustly to unseen ones [12]. AutoRed extends these ideas to strategic, multi-stage red-team assessments by framing automated red teaming as a long-horizon planning problem and using RL to search attack graphs under uncertainty [13]. Collectively, these works demonstrate that RL can learn viable attack paths and that specialised environments are emerging to support training. However, most systems still operate at an abstract level (for example, “exploit service X on host Y”) rather than orchestrating concrete tools such as nmap or Metasploit in real time. They also typically require extensive training runs and careful 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 environment engineering before a stable policy emerges, which contrasts with the prompt-driven, zero-shot behaviour of LLM-based agents. 2.2 Cyber Ranges, Gyms, and Autonomous Cyber Defence In parallel with RL-based pentesting, the cyber-operations community has invested heavily in gyms, ranges, and digital twins for training autonomous cyberdefence agents. Velazquez et al. propose Autonomous Cyber Operations (ACyO) gyms to train Autonomous Cyber Defence (ACyD) agents in coalition and tactical-edge scenarios [3]. Their work catalogues existing environments (for example, CybORG and the CAGE challenges) and classifies them by training focus (offence, defence, or both), level of abstraction (simulation versus emulation), and realism of network services. A key objective is to enable agents that can transition from simulated environments to next-generation cyber ranges and, ultimately, live networks The same line of work also identifies hybrid AI models-combining deep learning, RL, and generative models-as promising candidates for ACyD agents oper ating in highly dynamic, resource-constrained military networks [3]. Loevenich et al. extend this vision by proposing architectures that integrate multi-agent RL, LLMs, and rule-based components into distributed blue- and red-team agents deployed across software-defined networks [14]. Their Automated Cyber Operation gym is used to evaluate how such hybrid agents can monitor, detect, and mitigate threats at scale while preserving data security and model robustness. These efforts highlight two themes relevant to our work: first, that realistic cyber-ranges and gyms are central to evaluating autonomous agents; and second, that tool-centric action spaces (for example, “invoke IDS reconfiguration,” “apply firewall rule,” or “launch exploit”) are increasingly favoured over free-form shell access. Our setup follows this philosophy at a smaller scale by constraining the LLM agent to a small set of vetted tools rather than arbitrary commands 2.3 LLM-Based Security, Red Teaming, and Penetration Testing Large language models have rapidly become central to both offensive and defensive cybersecurity research. Ferrag et al. survey LLM-based attacks and defences and show how the same generative capabilities that enable code assistance can also be misused for malware generation, phishing content, jailbreaks, and adversarial prompting [15]. Their taxonomy distinguishes model-in-theloop defence use cases (for example, log triage, alert summarisation, and incident reporting) from attack-supporting uses such as exploit scaffolding and vulnerability discovery. Xu et al. provide a systematic literature review of LLMs for cyber security, covering applications like vulnerability detection, fuzzing, static analysis, intrusion detection, and incident response [16]. They emphasise that many works embed LLMs as “orchestrators” that interpret natural-language tasks, invoke specialised security tools, and reason over multi-step workflows, rather than replacing those tools outright. A complementary survey on AI-driven cybersecurity and threat intelligence by Waizel. expands this picture to include generative AI for threat hunting, cyber threat intelligence (CTI) extraction, and automated reporting pipelines [7]. For offensive security specifically, PentestAgent introduces a multi-agent LLM architecture tailored to penetration testing platforms such as Hack-TheBox and TryHackMe [9]. Specialised LLM agents are assigned roles (reconnaissance, exploit selection, privilege escalation), and communicate via a shared memory, while concrete actions are executed through existing pentesting tools. The authors report qualitative successes on CTF-style targets and show that LLMs can decompose tasks, interpret noisy tool output, and adapt strategies over several steps. 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 Closer to our setting, Salem and Mrian demonstrate an AI-driven penetration testing pipeline in which an LLM autonomously selects and configures Metasploit modules against a vulnerable VSFTPD service [8]. Their case study shows that a carefully engineered prompt and templatebased resource files are sufficient for the model to drive real exploits, not just simulations. They also highlight the importance of constraining the model to a limited set of modules and parameters to avoid unsafe or destructive behavior. Across these works, a common pattern emerges: LLMs are most effective when they act as highlevel controllers that reason about goals, tool output, and next actions, while low-level interactions with hosts are delegated to traditional security toolchains. Our architecture follows the same pattern but evaluates it quantitatively against a scripted baseline in a limited cyber-range scenario. 2.4 Agentic AI Safety, Human Factors, and Auditability As LLM-driven systems move from one-shot assistants to autonomous or semiautonomous agents, safety, governance, and human factors become critical. Zhang et al. analyse the “human factor” in AI red teaming, arguing that processes, documentation, and team structure must adapt when AI systems are themselves subjects and tools of red-team exercises [17]. They describe largescale industrial experiences where human experts and AI tools jointly probe system robustness, and recommend explicit scoping, scenario design, and postmortem analysis to ensure meaningful, responsible red-team outcomes. Phiri propose design principles for “characteristically auditable” agentic AI systems, stressing that agent architectures should favour constrained tool interfaces, explicit state logging, and rich provenance for each action taken [18]. Rather than relying solely on sandboxing or access control, they advocate building systems that can be inspected and reconstructed after the fact, enabling regulators and operators to understand how decisions were made. Canale, G. complement this perspective by applying Counterfactual Predictive Frameworks (CPF) to emerging agentic AI threats, mapping how capabilities such as autonomous tool use, long-horizon planning, and selfmodification can translate into concrete risk scenarios [19]. Recent NATO-aligned work on ACyD agents reinforces these concerns in military settings. Loevenich et al. highlight challenges in training hybrid MARL-LLM agents for autonomous defence, including data security, model robustness, and the risk of agents being misled during training or evaluation [14]. Velazquez et al. explicitly note the potential of LLM-based agents to automate thoughtaction-observation cycles in both red and blue teams, while calling for carefully instrumented ACyO gyms that provide safe, observable environments for such experimentation [3]. Our design choices-limiting the LLM to three high-level tools, instrumenting every step with structured logs, and evaluating in a closed cyber-range are directly inspired by this body of work. The goal is not only to achieve successful exploitation, but to do so in a way that remains auditable, reproducible, and compatible with emerging governance expectations for agentic AI. 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 Table 1: Technology domains covered by selected references 2.5 Summary of Literature Landscape Table 1 summarizes the main technology domains covered by the core references discussed above. RL-based autonomous pentesting and ACyD research concentrate on training agents in gym-style environments, often with simulated networks. LLM-based security works focus on using generative models as controllers, assistants, or attackers across both offensive and defensive tasks. Agentic-AI-safety papers cut across these domains by proposing frameworks for evaluation, governance, and auditability. Our contribution sits at the intersection of these strands: a constrained LLM agent is evaluated in a real cyber-range with real tools, and its behavior is compared quantitatively against a scripted baseline. 3 Methodology This section presents the experimental setup, system architecture, and evaluation methodology used to compare deterministic baselines with LLM-guided offensive security pipelines in a controlled cyber-range environment. The evaluation includes five configurations: fixed-path baseline, sequential baseline, rule-based baseline, LLM V1, and LLM V2. As shown in Figure 2, the workflow captures the interaction between controller configurations, tool execution layers, and the data collection and analysis pipeline. 230 231 232 233 234 235 Figure 2: End-to-end experimental workflow for evaluating deterministic baselines and LLMguided controllers. The framework includes service discovery, controller-specific decision logic, tool execution, success validation, and result consolidation across multiple runs. 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 3.1 Experimental Scenario and Infrastructure The experimental environment consists of a vulnerable Kioptrix virtual machine as the target system and a Kali Linux machine as the attacker. Both systems are deployed within an isolated virtual network to ensure safe and reproducible experimentation. The Kioptrix system exposes known vulnerabilities, including a Samba service vulnerable to remote exploitation. This enables a controlled and representative attack scenario for evaluating different controller behaviors. The Kali Linux machine hosts all attack scripts, enumeration tools, and Metasploit modules required for executing the pipelines. All experiments are conducted under identical network and system conditions to ensure a fair comparison across controller configurations. Each pipeline follows the same objective: identifying exposed services, selecting an exploitation path, executing a remote exploit using Metasploit, and establishing a command shell session on the target system. 3.2 Deterministic Baseline Pipelines Deterministic baselines are implemented to provide reference performance for comparison with LLM-guided pipelines. These approaches rely on predefined decision logic and do not adapt dynamically to intermediate observations. The fixed-path baseline represents an idealized scenario in which the correct exploitation path is known in advance. It performs targeted enumeration of SMB services followed directly by exploitation using Metasploit. In addition, two alternative deterministic pipelines are implemented: The sequential baseline performs exhaustive enumeration across multiple services before attempting exploitation, representing a naive exploration strategy. The rule-based baseline selects actions based on observed open ports, prioritizing SMB exploitation when port 139 is detected. All baseline pipelines use the same underlying tools and execution environment, differing only in their decision logic. They operate within the same constrained action space described in Section 3.3, ensuring consistency and a fair comparison with the LLM-guided pipeline. 3.3 Action Space To ensure safety and reproducibility, all pipelines operate within a constrained action space consisting of predefined operations. The action space includes: Scanning: ScanFull Enumeration: EnumHTTP, EnumHTTPS, EnumRPC, EnumSMB, EnumSSH Exploitation: ExploitHTTP, ExploitSSH, ExploitSMB Control: Stop Each action is mapped to a predefined local script that executes a specific tool or command. This design prevents arbitrary command execution and ensures that all operations are controlled and auditable. By restricting both deterministic and LLM-guided pipelines to the same action space, the comparison remains fair and consistent across configurations. The execution logic of the scripted baseline pipeline is summarized in Algorithm 1. Algorithm 1: Scripted Baseline Pipeline Input: target ip, attacker ip 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 1: Generate RC file from template 2: Start timer 3: Perform service scan (e.g., SMB ports) 4: Execute Metasploit exploit via RC file 5: Wait for completion and log output 6: Stop timer 7: Parse logs for shell session 8: Set success flag 9: Record metrics (run id, target ip, success, steps, duration) 3.4 LLM-Guided Agent Pipeline The LLM-guided pipeline is implemented as a Python-based agent that operates through a constrained decision loop. At each step, the agent selects an action from the predefined action space based on the current observation and prior execution history. The selected action is executed via local scripts, and the resulting output is fed back into the agent for subsequent decision-making. To evaluate the impact of controller design, two configurations of the LLM-guided agent are implemented: LLM V1 (Initial Controller): This configuration uses a minimally constrained prompt and allows exploratory behavior. Action selection is primarily driven by the model’s interpretation of observations, without explicit prioritization or restriction mechanisms. LLM V2 (Refined Controller): This configuration introduces structured constraints, including service prioritization (e.g., prioritizing SMB when port 139 is open), prevention of redundant actions, and early termination conditions. These constraints are enforced through prompt design and decision guardrails. Both configurations operate under the same action space and execution environment, differing only in their decision policies. This design isolates the effect of constraint-driven control on agent performance. The decision loop of the LLM-guided agent is summarized in Algorithm 2. Algorithm 2: LLM-Guided Pentesting Agent Input: target IP 1: Initialize history ← ∅ 2: for step = 1 to max_steps do 3: Construct prompt using current history 4: Query LLM for next action 5: if action = Stop then 6: break 7: Execute selected action via local script 8: Observe output and update history 9: if exploit success detected then 10: break 11: end for 12: Record execution metrics 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 The LLM does not directly issue system commands; instead, it selects from a predefined set of actions mapped to controlled scripts. The system prompt instructs the model to behave as a cautious security tester, minimize unnecessary steps, and prioritize exploitation only after confirming that SMB is exposed on port 139. The agent terminates execution when either a successful exploit is detected or a predefined maximum number of steps is reached. 3.5 Logging and Metrics Each pipeline execution is logged to structured output files, capturing the sequence of actions, observations, and outcomes. A consolidated dataset is generated by aggregating results across multiple runs. The following metrics are used for evaluation: Success Rate: Whether exploitation is successfully achieved Steps: Number of actions taken to reach termination Wasted Actions: Actions that do not contribute to successful exploitation Duration: Total execution time in seconds Each configuration is executed for 20 independent runs, and mean values are computed to enable comparison across controllers. All configurations are evaluated under identical infrastructure, toolsets, and network conditions to ensure a fair and controlled comparison. 4 Results and Analysis This section presents the experimental results obtained from evaluating five configurations: fixedpath baseline, sequential baseline, rule-based baseline, LLM V1, and LLM V2. Each configuration is executed for 20 independent runs under identical conditions. 4.1 Baseline Performance The fixed-path baseline achieves optimal performance, requiring only two steps with an average execution time of 28.25 seconds. This reflects an idealized scenario where the correct exploitation path is known in advance. As shown in Figure 3, the fixed-path baseline achieves the lowest execution time, while the sequential baseline incurs the highest overhead. The sequential baseline demonstrates significantly lower efficiency, requiring eight steps and incurring five wasted actions per run, resulting in an average execution time of 64.05 seconds. This confirms the inefficiency of exhaustive exploration in branching environments. The rule-based baseline achieves strong performance with three steps, zero wasted actions, and an average execution time of 44.35 seconds. This represents an efficient deterministic approach without prior knowledge of the exact exploit path. Table 2 summarizes the performance of the deterministic baselines. 368 369 370 371 Figure 3: Mean execution duration across all controllers. Table 2: Baseline Results (Fixed, Sequential, Rule-based) 372 373 374 375 376 377 378 379 380 381 382 383 384 385 4.2 LLM Agent Performance The initial LLM configuration (LLM V1) exhibits reduced reliability and efficiency compared to deterministic baselines. Across 20 runs, it achieves a success rate of 0.60, with higher step counts (mean 8.5), increased execution time (mean 95.8 seconds), and non-zero wasted actions (mean 1.7). This behavior reflects exploratory decision-making and weak prioritization across multiple services. In contrast, the refined configuration (LLM V2) demonstrates consistent and efficient behavior. It achieves a success rate of 1.00 across all runs, reduces the number of steps to 3.0, eliminates wasted actions entirely, and reduces execution time to 43.8 seconds. Table 3 presents a direct comparison between LLM V1 and LLM V2. 386 387 388 389 390 391 392 393 The transition from LLM V1 to LLM V2 highlights the impact of introducing constraints on action selection. LLM V2 improves success rate, reduces unnecessary exploration, and produces stable outcomes across runs. As shown in Figure 4, LLM V2 achieves a perfect success rate, while LLM V1 exhibits reduced reliability. Table 3: LLM Results (V1 vs V2) 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 Figure 4: Success rate comparison across all controllers. 4.3 Comparative Analysis The results across all configurations are summarized in Tables 2 and 3 and further illustrated in Figures 3-7. First, deterministic baselines remain highly effective in controlled environments, particularly when the exploitation path is simple. Second, unconstrained LLM agents introduce inefficiencies due to exploratory behavior, as observed in LLM V1. Third, properly constrained LLM controllers can match the performance of rule-based systems. As shown in Figure 5, LLM V2 reduces the number of steps to match the rule-based baseline. Similarly, Figure 6 shows that LLM V2 eliminates wasted actions entirely, aligning with deterministic strategies. Notably, LLM V2 achieves performance equivalent to the rule-based baseline across all evaluated metrics, indicating that constrained LLM control can replicate deterministic decision policies. In contrast, LLM V1 exhibits higher variability in execution duration. This is further illustrated in Figure 7, which shows a wider distribution of execution times compared to deterministic and constrained approaches. Figure 5: Mean number of steps required for successful exploitation across controllers. 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 Figure 6: Mean number of wasted actions across controllers Figure 7: Distribution of execution duration across controllers. 4.4 Qualitative Analysis of Controller Behavior In addition to quantitative metrics, qualitative inspection of execution traces provides further insight into behavioral differences between controller configurations. While numerical results capture efficiency and success rates, trace-level analysis reveals how decisions are made and why certain configurations perform better. The fixed-path baseline exhibits fully deterministic behavior, executing a predefined sequence of actions without branching. This results in optimal performance but lacks flexibility. The sequential baseline demonstrates exhaustive exploration behavior, evaluating multiple services before converging on the correct exploit path. This leads to unnecessary actions and increased execution time. The rule-based baseline introduces structured decision-making by prioritizing SMB exploitation when port 139 is detected. This eliminates redundant actions and ensures consistent performance. The LLM-based controllers exhibit distinct behavioral patterns. LLM V1 demonstrates exploratory decision-making, often evaluating multiple services before selecting the correct path. This results in increased steps and variability. 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 In contrast, LLM V2 demonstrates stable and efficient behavior. By incorporating constraints such as service prioritization and bounded action selection, it consistently selects the SMB exploit path with minimal intermediate steps. Table 4 summarizes the dominant qualitative behaviors across controller configurations. These observations confirm that performance differences are primarily driven by decision-making patterns rather than tool execution. Table 4: Qualitative behavior of controller configurations 5 Discussion The results highlight the role of LLM-guided control in offensive security pipelines under constrained conditions. In this scenario, deterministic baselines achieve strong performance, particularly when the exploitation path is simple and well-defined. The fixed-path baseline represents an ideal case with prior knowledge, while the rule-based baseline demonstrates that efficient performance can be achieved through structured decision logic without explicit knowledge of the exact exploit path. The initial LLM configuration (LLM V1) underperforms compared to deterministic approaches, exhibiting lower success rate and higher execution cost. This behavior is primarily due to exploratory action selection and the absence of strong prioritization mechanisms. These findings indicate that unconstrained LLM-based agents may introduce inefficiencies in structured environments. In contrast, the refined configuration (LLM V2) demonstrates that these limitations can be effectively addressed through control policy design. By incorporating constraints such as service prioritization, bounded action selection, and early termination conditions, LLM V2 achieves deterministic-level performance, matching the rule-based baseline in terms of success rate, number of steps, and execution time. This comparison highlights a key insight: the effectiveness of LLM-based agents depends more on control policy design than on the underlying model alone. While rule-based systems require explicit encoding of logic, LLM-guided approaches offer a flexible alternative that can approximate structured decision-making without extensive hardcoding. Although the evaluated scenario is intentionally simple, it provides a controlled baseline where deterministic logic is expected to perform optimally. The objective is not to outperform scripted pipelines, but to determine whether LLM-guided systems can achieve equivalent reliability under real tool execution. This controlled setting provides a foundation for extending the approach to more complex environments. 5.1 Implications for LLM-Assisted Red Teaming These results suggest that LLMs can serve as effective control layers for existing penetration testing tools when operating under appropriate constraints. In the evaluated scenario, the refined 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 controller achieves performance comparable to deterministic pipelines, maintaining both reliability and efficiency. The simplicity of the scenario limits opportunities for performance gains over deterministic scripting. In this context, the role of the LLM is to demonstrate that a constrained, tool-mediated agent can achieve equivalent performance while maintaining flexibility. This aligns with existing work in LLM-based security, where models are used to orchestrate tools rather than replace them entirely [8, 9]. The comparison between LLM V1 and LLM V2 further emphasizes that performance depends critically on constraint design. While the initial configuration exhibits exploratory inefficiencies, the refined controller demonstrates stable and efficient behavior, highlighting the importance of structured control policies for reliable deployment. 5.2 Baseline vs LLM: Strengths and Weaknesses The scripted baseline is simple, transparent, and highly reliable. It is well-suited for scenarios where the exploitation workflow is fixed and known in advance. However, extending the baseline to handle additional services, alternative exploits, or branching logic requires manual development effort. In contrast, the LLM-guided approach offers greater adaptability. The same agent design can be extended to incorporate additional tools, such as HTTP enumeration, vulnerability scanners, or privilege escalation techniques, without modifying the core execution loop. Additionally, the use of natural-language reasoning improves interpretability by allowing analysts to trace decisionmaking steps. However, LLM-based systems are sensitive to control policy design. As demonstrated by the difference between LLM V1 and LLM V2, unconstrained behavior can lead to inefficiency and inconsistency, while structured constraints enable stable and reliable execution. Compared to reinforcement learning (RL)-based agents, LLM-guided pipelines do not require environment-specific training and can leverage general knowledge of tools and protocols. However, RL-based approaches may offer advantages in optimizing long-horizon strategies once trained, particularly in large and complex environments [2-5]. 5.3 Operational Interpretation of Quantitative Trends The results support three key operational observations. First, reliability is achieved through constraint-driven control. The refined configuration (LLM V2) produces consistent outcomes across all runs, indicating that structured constraints can stabilize decision-making. Second, execution time is dominated by underlying tools. Both deterministic and LLM-guided pipelines spend most of their runtime in scanning and exploitation tools such as Nmap and Metasploit. As a result, differences in decision policies have limited impact on total execution time. Third, decision efficiency is the primary differentiator between controllers. Unconstrained exploration (LLM V1) leads to additional steps and wasted actions, while structured control (LLM V2) aligns performance with rule-based pipelines. These findings suggest that improvements in offensive security automation are more closely related to control policy design than to the underlying toolset. LLM-based orchestration can enhance flexibility while maintaining efficiency when properly constrained. 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 5.4 Threats to Validity The main threats to validity include: Single vulnerability and topology: The evaluation is limited to a single exploit (trans2open) on a single host. More diverse vulnerabilities and multi-host environments may reveal different behaviors. Model dependence: Results depend on the selected LLM configuration and prompt design. Different models or prompts may produce different outcomes. Measurement limitations: Success is determined by parsing tool output, which may vary across environments or tool versions. Limited adversarial conditions: The setup does not include defensive mechanisms such as intrusion detection or rate limiting, which could affect real-world performance. Despite these limitations, the experiment provides a controlled and reproducible reference point for evaluating LLM-guided offensive security pipelines and establishes a foundation for future research in more complex environments. 6 Conclusion This paper presents a controlled evaluation of LLM-guided offensive security pipelines in comparison with deterministic scripted baselines within a cyber-range environment. Using a vulnerable Kioptrix system and a constrained action space, five configurations were evaluated: fixed-path, sequential, and rule-based baselines, along with two LLM-based controllers (LLM V1 and LLM V2). The results show that while the initial LLM configuration exhibits reduced reliability and efficiency due to exploratory behavior, a refined and constrained controller can achieve performance comparable to deterministic approaches. In particular, LLM V2 matches the rulebased baseline in terms of success rate, number of steps, and execution time, while eliminating unnecessary actions. These findings demonstrate that the effectiveness of LLM-guided pipelines depends primarily on control policy design rather than the underlying model alone. When appropriately constrained, LLM-based systems can serve as reliable orchestration layers for existing security tools, combining deterministic-level performance with increased flexibility. Although the evaluated scenario is intentionally simple, it provides a controlled and reproducible baseline for assessing LLM-guided decision-making. This work establishes a foundation for future research on LLM-assisted red teaming in more complex and dynamic environments, including multi-host scenarios, diverse vulnerability classes, and adaptive adversarial conditions. 7 Future Work Building on this study, future work should extend the evaluation of LLM-guided offensive security pipelines across more complex and realistic scenarios. First, the action space can be expanded beyond SMB exploitation to include a wider range of tasks, such as web enumeration, credential attacks, local privilege escalation, and lateral movement. This would allow assessment of whether constrained LLM controllers remain stable as task complexity and decision branching increase. Second, experiments should move from a single-host setup to multi-host environments, where agents must sequence exploits, pivot across compromised systems, and maintain consistent state over longer execution paths. Such scenarios are necessary to evaluate scalability and external validity. Third, hybrid approaches that combine reinforcement learning (RL) for high-level planning with LLM-based decision-making for tool execution should 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 be explored. RL methods may support long-horizon strategy optimization, while LLMs can provide flexibility in interpreting tool outputs and selecting actions. Fourth, future evaluations should incorporate stronger safety and control mechanisms, including human-in-the-loop intervention, explicit action constraints, and audit logging to support traceability and verification. Finally, the development of shared benchmark environments in cyber-range settings would improve reproducibility and enable fair comparison across scripted, RL-based, and LLM-guided approaches. Standardized evaluation metrics such as success rate, time to objective, action efficiency, and robustness, would further support consistent assessment. Overall, these directions suggest that constrained LLM-guided pipelines can be extended to more complex environments, provided that they are evaluated under realistic conditions and supported by appropriate control and safety mechanisms. Appendix A. Sample Log Output This appendix provides representative log excerpts from the experimental runs to illustrate the execution behavior of different pipeline configurations. All logs are generated automatically during execution and are stored with unique run identifiers to ensure traceability and reproducibility. A.1 Fixed-Path Baseline This log corresponds to a deterministic execution where the correct exploitation path is known in advance. Sample Log 1: baseline_oracle_logs/msf_baseline_20260414_110136.log A.2 Sequential Baseline This log illustrates exhaustive enumeration before identifying the correct exploit. 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 Sample Log 2: baseline_sequential_logs/fullscan_20260414_112202.nmap A.3 Rule-Based Baseline This log demonstrates prioritized decision-making based on observed services. Sample Log 3: baseline_heuristic_logs/fullscan_20260414_113709.nmap A.4 LLM V1 (Exploratory Behavior) This log highlights exploratory behavior and redundant actions prior to successful exploitation. Sample Log 4: llm_branching_logs/msf_llm_v1_20260414_120840.log A.5 LLM V2 (Constrained Behavior) This log illustrates efficient and constrained execution, closely matching rule-based behavior. Sample Log 5: llm_branching_logs/msf_llm_v2_20260414_123745.log 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 Appendix A.6 Dataset Reference The dataset is aggregated automatically during experiment execution and can be used to reproduce all reported results. The dataset contains the following fields: Run ID: Unique identifier for each run Controller: Pipeline type (baseline or LLM) Success: Binary success indicator Steps: Number of actions executed Wasted Actions: Number of redundant actions Duration: Execution time (seconds) Sample Log 6: Logs_consolidate/final_results.csv. References [1] Nguyen, H. P. T., Hasegawa, K., Fukushima, K., and Beuran, R. (2025). PenGym: Realistic training environment for reinforcement learning pentesting agents. Computers & Security, 148, 104140 (Elsevier). [2] Symes Thompson, I., Caron, A., Hicks, C., and Mavroudis, V. (2023). Entity-based reinforcement learning for autonomous cyber defence. In Proceedings of the Workshop on Autonomous Cybersecurity, pages 56-67. [3] Velazquez, A., Loevenich, J. F., H¨urten, T., Wrona, K., Rettore, P. H. L., Boshnakov, V., Free-Nelson, F., Braun, T., and Lopes, R. R. F. (2025). Cyber operations gyms to train autonomous cyber defense agents for NATO. In 2025 International Conference on Military Communication and Information Systems (ICMCIS), pp. 1-10. IEEE. [4] G. McDonald, L. Li, and R. Al. Mallah, “Finding the optimal security policies for autonomous cyber operations with competitive reinforcement learning,” IEEE Access, 2024. [5] A. Dehghantanha, A. Yazdinejad, and R. M. Parizi, “Autonomous cybersecurity: Evolving challenges, emerging opportunities, and future research trajectories,” in Proceedings of the Workshop on Autonomous Cybersecurity, 2023. [6] A. Happe, Andreas, and J. Cito, “Getting pwn’d by AI: Penetration testing with large language models,” in Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering. New York, NY, USA: Association for Computing Machinery, 2023, p. 2082-2086. [7] Waizel, G. (2024). Bridging the AI divide: The evolving arms race between AI-driven cyber attacks and AI-powered cybersecurity defenses. In International Conference on Machine Intelligence & Security for Smart Cities (TRUST) Proceedings, vol. 1, pages 141-156. 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 [8] Salem, A., and Mrian, A. (2024). AI-Driven Penetration Testing: Autonomous Exploitation of VSFTPD. In International Conference on Computer Science and Engineering (ICCSE), 2024. [9] Shen, X. et al., “Pentestagent: Incorporating llm agents to automated penetration testing,” in Proceedings of the 20th ACM Asia Conference on Computer and Communications Security, 2025, pp. 375-391. [10] Happe, A. et al., “Can LLMs Hack? A Comparative Study of LLM-Driven Penetration Testing,” ACM Conference on Computer and Communications Security (CCS), 2025. [11] Liu, J. et al., “Autonomous Penetration Testing using Reinforcement Learning: A Review and Perspectives,” Expert Systems with Applications, 262, 130219 (Elsevier). [12] Yang, Y. et al., “Settron: Towards better generalisation in penetration testing with reinforcement learning,” in GLOBECOM 2023-2023 IEEE Global Communications Conference, 2023, pp. 4662-4667. [13] Hasegawa, K., Hidano, S., and Fukushima, K. (2024). Autored: Automating red team assessment via strategic thinking using reinforcement learning. In Proceedings of the Fourteenth ACM Conference on Data and Application Security and Privacy, pages 325-336. [14] J. F. Loevenich et al., “Training Autonomous Cyber Defense Agents: Challenges & Opportunities in Military Networks,” in MILCOM 2024-2024 IEEE Military Communications Conference (MILCOM), 2024, pp. 158- 163. [15] Ferrag, M. A. et al., “Generative ai in cybersecurity: A comprehensive review of llm applications and vulnerabilities,” Internet of Things and CyberPhysical Systems (Elsevier). [16] Xu, H. et al., “Large language models for cyber security: A systematic literature review,” ACM Transactions on Software Engineering and Methodology (ACM New York, NY), 2024. [17] Zhang, A. Q. et al., “The human factor in ai red teaming: Perspectives from social and collaborative computing,” in Companion Publication of the 2024 Conference on ComputerSupported Cooperative Work and Social Computing, 2024, pp. 712-715. [18] Phiri, C. C. (2025). Creating Characteristically Auditable Agentic AI Systems. In Proceedings of the Intelligent Robotics FAIR 2025, pages 1-14. [19] Canale, G. (2025). CPF Application to Emerging Agentic AI Threats: Validation Against Microsoft AIRT Taxonomy and Enhanced Assessment Methodologies. Available at SSRN 5415096.
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )