G-CTR: Game-Theoretic Guidance for LLM Pen Testing
- The paper introduces G-CTR, a lightweight game-theoretic guidance layer that extracts attack graphs and computes Nash equilibria within milliseconds.
- G-CTR leverages a three-phase pipeline—graph extraction, equilibrium computation, and digest integration—to anchor LLM decisions with tactical insights.
- Empirical benchmarks show up to 2.67× faster success times and 23× lower costs, highlighting significant improvements in strategic effectiveness.
Generative Cut-the-Rope (G-CTR) is a lightweight game-theoretic guidance layer designed to augment LLM-driven penetration-testing agents with machine-level strategic reasoning and reproducible performance. The system automatically extracts attack graphs from the agent's log context, computes Nash equilibria reflecting both attacker and defender strategies with effort-aware edge scoring, and feeds a concise digest of tactical guidance into the agent's prompt loop. By continuously closing this loop—agent generates graph, G-CTR analyzes, agent re-plans under guidance—the system reduces ambiguity, suppresses hallucinations, and anchors the model’s actions to statistically promising paths. Empirical results demonstrate substantial gains in success rate, consistency, and cost-efficiency, matching expert structure 70–90% of the time but at vastly increased speed and lower cost (Mayoral-Vilches et al., 9 Jan 2026).
1. System Architecture and Workflow
The G-CTR pipeline consists of three primary phases, executed at regular intervals (typically every ~80 tool calls or ~20 seconds):
Phase 1 (Game-Theoretic Analysis):
The agent’s log (ℓ), consisting of a sequence of J messages, is processed by an LLM to extract a structured attack graph . NetworkX is employed to enforce acyclic paths and prune leaf nodes. The attack graph is represented with a merged root entry node and vulnerable leaf nodes. G-CTR computes a Nash equilibrium over the graph—typically within ms overhead—informing optimal inspection strategies for defenders and attack paths for adversaries.
Phase 2 (Digest Generation):
Equilibrium outputs—defender mixed strategy , attacker’s probability-weighted paths, and overall success probability —are summarized in a digest using either algorithmic or LLM-based methods.
- Algorithmic mode uses rule-based templates to mark bottlenecks () and high-risk transitions (), with digest generation under 10 ms.
- LLM mode sends a 350-word structured prompt to an LLM ("alias1"), generating lingustically rich summaries in s. Fallback to algorithmic occurs on API failure.
Phase 3 (Agent Execution):
The digest is prepended to the agent's system prompt. Subsequent action selection (ReAct framework) is performed with both tool outputs and G-CTR-derived strategic hints, iteratively updating until a termination condition is met (flag discovery or step limit) (Mayoral-Vilches et al., 9 Jan 2026).
2. Formal Game-Theoretic Model
G-CTR models attack graphs as directed acyclic graphs , where each edge is assigned an effort score:
with
- (message distance)
- (token count)
- (estimated cost)
quantifies attacker effort; higher values indicate greater difficulty traversing the edge.
Defender’s expected detection probability (inspecting distribution over nodes ) is:
where and (edges per defender inspection window). The attacker’s success is .
The Nash equilibrium is computed by solving the zero-sum minimax:
or equivalently, by numerically minimizing :
3. Attack Graph Extraction and Heuristics
Extraction proceeds via the following steps:
- Merge entry points: All nodes with minimal message_id are consolidated into the single root .
- Prune cycles: Acyclicity enforced via NetworkX all_simple_paths; cycles are removed.
- Remove non-vulnerable leaves: Non-vulnerable leaves are recursively pruned.
- Enforce leaf vulnerabilities: Artificial leaf nodes (“leaf_X”) are attached to all vulnerable nodes, each with .
- Reconnect components: Components are reconnected to root, and incoming edges to root are removed.
- Node-count bounds: Node count is set as a piecewise percentage of (message sequence length):
- Short ( msgs): $12$– of
- Medium ($70$–$199$): $6$–
- Long (): $3.5$– with hard bounds at total nodes.
This approach enables efficient graph extraction, balancing computational tractability with faithful representation of agent reasoning (Mayoral-Vilches et al., 9 Jan 2026).
4. Equilibrium Computation and Digest Integration
G-CTR employs the following pseudocode for Nash equilibrium computation, using precomputed Poisson probabilities and a linear program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
def ComputeNashEquilibrium(G, λ): # G = (V,E) weighted by E_i on edges; AS1 = V\{leaves,entry}, AS2 = all_simple_paths(entry→vuln) paths = list(all_simple_paths(G, entry, any_leaf)) # Precompute P_π(c|θ) via Poisson with rate λ P = { (π,θ,c): PoisPMF(dist(π,θ,c),λ)/Z(π) for π in paths for θ in π for c in AS1 } # LP variables: σ_d(c) ∀c∈AS1, u lp = LinearProgram() σ = {c: lp.var(f"sigma_{c}", lb=0) for c in AS1} u = lp.var("u") lp.set_objective(u, minimize=True) for π in paths: for θ in π: lhs = 1 - sum(σ[c]*P[(π,θ,c)] for c in AS1) lp.add_constraint(u >= lhs) lp.add_constraint(sum(σ.values()) == 1) sol = lp.solve() σ_d = {c: sol.value(σ[c]) for c in AS1} # Attacker best responses: filter paths with max U_A under σ_d attacker_paths = sorted( paths, key=lambda π: max(1-sum(σ_d[c]*P[(π,θ,c)] for c in AS1) for θ in π), reverse=True ) return σ_d, attacker_paths, sol.value(u) |
Digest generation employs algorithmic or LLM-based summarization, with thresholds for bottlenecks () and high-risk transitions ():
1 2 3 4 5 6 7 8 9 10 11 |
G-CTR Security Analysis Identified attack paths: • Path 1: entry→… [67%] → target • Path 2: entry→… [32%] → target Critical chokepoints (bottlenecks): • node X→Y: 3.1% success High-risk transitions: • node A→B: 95% success Tactical Guidance: • Focus next on exploiting … • Defend inspection at … |
Digest is injected directly into the agent’s system prompt:
1 2 3 |
System: You are a red/blue agent. Use the following G-CTR digest to guide your next actions: {D}
User: {…}
Assistant: |
5. Empirical Performance and Quantitative Benchmarks
G-CTR demonstrates significant improvements in speed, cost, and agent effectiveness across multiple testbeds:
Attack-Graph Generation vs. Human Experts:
- Node correspondence: $70$– match to expert graphs (five domains).
- Time: LLMs $10$–$46$ s versus human $30$–$90$ min ($60$– faster).
- Cost: $\$0.05\$0.64\$22.5\$67.562450\times<5$ ms per run.</li>
</ul>
<p><strong>Shellshock CVE-2014-6271 Cyber-Range (44 runs):</strong></p>
<div class='overflow-x-auto max-w-full my-4'><table class='table border-collapse w-full' style='table-layout: fixed'><thead><tr>
<th>Mode</th>
<th>Success Rate</th>
<th>Avg Duration</th>
<th>Tool-use Variance</th>
<th>Cost/Succ</th>
</tr>
</thead><tbody><tr>
<td>No G-CTR</td>
<td>13.3% (2/15)</td>
<td>16.7 min</td>
<td>1.6×</td>
<td>\$2.71
G-CTR Algorithmic 20.0% (3/15) 22.5 min 6.2× \$0.32 G-CTR LLM 42.9% (6/14) 20.2 min 1.2× \$0.12
- Expected time to success : $126$ min min ( faster).
- Cost per success: $\$2.71 \rightarrow \$0.1223\times6.2\times \rightarrow 1.2\times5.2\times\sim2{:}1\sim3.7{:}15.2\times2\times\leq25$ nodes, but larger graphs could require approximations or Monte Carlo algorithms.
- Future work targets dynamic LLM temperature schedules (balancing creativity and control), adversarial robustness against poisoned logs, and integration with probabilistic vulnerability databases (e.g., CVSS alongside effort scores).
A plausible implication is that ongoing advances in adaptive graph construction, scalable equilibrium computation, and robust prompting will further expand G-CTR’s domain applicability and strategic capabilities.