Mastermind: Strategy-grounded Learning for Repository-Scale Vulnerability Reproduction

Mingzhe Du, Luu Anh Tuan, Tianyi Wu, Renyang Liu, Zhijiang Guo, Dong Huang, See-Kiong NgarXiv 2026

TL;DR

LLM agents often fail at complex software engineering tasks not because they lack the technical capability to execute commands, but because they choose the wrong high-level approach. Mastermind addresses this bottleneck by separating strategic planning from execution using a dual-loop reinforcement learning framework. By training a planner to generate compact, natural-language strategies, Mastermind significantly boosts the performance of various frozen LLM executors, achieving up to an 84.5% success rate on real-world vulnerability reproduction tasks.

What Problem Does This Paper Address?

Repository-scale vulnerability reproduction is an incredibly demanding software engineering task. An autonomous agent must explore a codebase, understand a vulnerability description, infer the precise input format required to trigger a crash (Proof-of-Concept or PoC), and verify that the crash is resolved on a patched build.

While modern LLMs are highly capable "executors"—proficient at navigating directories, editing files, and running terminal commands—they are notoriously poor "strategists." They frequently waste time exploring unproductive paths or fail to adapt when a hypothesis is disproven. Traditional reinforcement learning (RL) struggles here because training on full command-level trajectories is computationally prohibitive and highly environment-specific. This paper tackles the core question: How can we efficiently teach LLM agents to think strategically before they act?

Methods

The authors introduce Mastermind, a framework that decouples high-level planning from low-level execution. Instead of learning full action trajectories, Mastermind focuses entirely on strategies—compact, natural-language plans (under 2,000 tokens) detailing where to inspect, what input structures to target, and how to validate results.

Fig. 2: Overview of Mastermind’s Dual-loop Framework. Starting from a task, 1) the Curator activates experience and passes it to the Planner. 2) The Planner emits the current best strategy, 3) the Executor turns that strategy into a PoC rollout, and 4) the Verifier validates the PoC, then closes two loops: 5) it updates Curator for the next attempt and 6) supplies feedback signals to the Planner. Repeated iterations refine the strategy until a verified PoC is obtained.

As illustrated in the framework overview above, Mastermind operates via a novel dual-loop architecture:

  1. The Experience Loop (Curator): This module manages task-local memory. It records volatile, task-specific facts (e.g., file locations, failed hypotheses, parser quirks) across sequential attempts. This keeps short-lived data out of the model weights.
  2. The Policy Loop (Planner): This is the trainable core of Mastermind (implemented using Qwen3.6-35B-A3B). It absorbs transferable reasoning patterns across tasks (e.g., when to audit source code vs. when to mutate a seed input).

The Planner is optimized using Supervised Fine-Tuning (SFT) followed by Group Relative Policy Optimization (GRPO) based on dense, milestone-based rewards. To prevent the planner from getting stuck in a single solution family, the authors implement slot-conditioned strategy sampling, forcing the model to explore diverse strategic angles (e.g., focusing on memory allocation bugs vs. state-transition bugs).

Crucially, the downstream Executor remains completely frozen. The Planner simply hands off the natural-language strategy, and the Executor translates it into workspace actions.

Datasets

Mastermind was evaluated on CyberGym, a rigorous benchmark containing 1,507 real-world vulnerability reproduction tasks sourced from ARVO and OSS-Fuzz, spanning 188 open-source projects.

The experiments utilized:

  • A 260-task planner-learning split for training.
  • A disjoint 200-task held-out evaluation split for testing.
  • The realistic Level 1 context setting, where the agent is only given the pre-patch codebase and a textual description of the vulnerability (no ground-truth stack traces or patch diffs).

Key Insights and Ideas

  • Strategy is the Causal Bottleneck: Providing a high-quality strategy to a mediocre executor improves performance far more than providing raw context or answers without a plan. Strategy selection, not tool use, is the primary limiting factor for SE agents.
  • Transferable Planning: Because strategies are written in executor-agnostic natural language, a strategy planner trained on one model (e.g., GPT-5.4 mini) transfers seamlessly to entirely different frozen backbones (like GPT-5.5 or GLM 5.1) without any retraining.
  • Separation of Concerns: Hardcoding specific repository facts into model weights is inefficient. Mastermind proves that separating stable strategic instincts (stored in weights) from volatile task facts (stored in the Curator's external memory) yields a much more flexible and efficient agent.

Key Results

Mastermind consistently outperformed independent sampling, static-analysis guidance, and iterative improvement baselines across multiple frontier LLM backbones.

Fig. 3: Cumulative M7 pass rates by attempt cutoff. Colors denote the frozen executor (blue: GPT-5.4 mini; red: GPT-5.5), while line styles denote the protocol: dash-dot for independent Best-of-N (BON), dashed for iterative task-local revision, and solid for Mastermind. Curves show that feedback-conditioned attempts outperform independent sampling, and Mastermind lifts the curve further across both executors.

As shown in the performance curves above:

  • Pair with GPT-5.5, Mastermind achieved a 84.5% pass rate, substantially outperforming independent Best-of-8 sampling (63.0%) and standard iterative refinement (77.0%).
  • It boosted GPT-5.4 mini from a 45.0% base planner pass rate to 60.0%.
  • It boosted GLM 5.1 from 58.5% to 71.0%.

Furthermore, due to its strategic efficiency and early-stopping capabilities, Mastermind achieved these superior results while using fewer total tokens and less wall-clock time per successful task compared to the baselines.

Limitations and Future Work

While highly effective, Mastermind has a few notable limitations:

  • Executor Dependency: Mastermind improves strategy selection but cannot grant an executor new low-level capabilities. If a base model fundamentally does not know how to compile a specific language or interact with a unique build system, the framework cannot fix that.
  • Training Cost: Generating the initial RL training data requires thousands of scaffolded environment rollouts, making the training phase computationally heavy (even though inference becomes highly efficient).
  • Scope: The framework was exclusively validated on vulnerability reproduction. Exploring whether strategy-level learning transfers to broader software engineering tasks—such as feature implementation or automated code refactoring—remains an open question for future research.

Summary updated

BibTeX
@misc{du2026mastermind,
  author = {Mingzhe Du and Luu Anh Tuan and Tianyi Wu and Renyang Liu and Zhijiang Guo and Dong Huang and See-Kiong Ng},
  title = {{Mastermind: Strategy-grounded Learning for Repository-Scale Vulnerability Reproduction}},
  year = {2026},
  eprint = {2607.01764},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.01764},
}
Figure