Skip to content
Menu
All work

HYDRA: an RL training environment for security patches

I RL-trained a 7B open model to write security patches. Its diff-mode pass rate went from 1 of 8 tasks to 3 of 8. Measuring a second output mode then showed the gain was mostly diff formatting, not security skill. A small sample, reported as a research result.

file
C-03
for
Research project
role
Environment, training, evals
period
2026
status
Research
rewards: exploit, tests and scanner check every patch
exploit-verified
measured: training mostly taught the output format
format ≠ skill

01Context

Most AI security tooling wraps a frontier model in a prompt. I wanted to know whether a small open model can be trained to fix real vulnerability classes, and how close it gets to models many times its size.

HYDRA is a reinforcement-learning environment built on Nous Research's Atropos. The framework is theirs. The environment, the task suite, the training runs and the evals are mine.

02Problem

Labelled security patches are scarce, and a patch that looks right can still be exploitable. So the reward can't be "looks like the reference". It has to be does the exploit still work, and do the tests still pass.

03What I built

  • A custom Atropos environment that hands the model a vulnerable workspace and scores its patch.
  • Verifiable rewards. Each patch is checked by running the exploit, the regression tests and a static scanner. No human labels in the loop.
  • A hand-built task suite: 9 tasks across 6 vulnerability classes (SQL injection, XSS, IDOR, path traversal, command injection and hardcoded credentials), each with a reference patch.
  • GRPO training on Qwen2.5-7B-Instruct with vLLM serving, in 200- and 400-step runs on a single GPU allocation of about 15GB.
  • An eval protocol fixing temperature, number of samples and output mode (diff vs full file), plus benchmarks against commercial models over OpenRouter.

04Numbers

base Qwen2.5-7B
1 / 8
12.5%
trained 7B
3 / 8
37.5%; newly learned path-traversal and input-validation fixes
Diff mode, after 200 GRPO steps, 8-task eval
120B GPT-class model
8 / 9
base 7B, untrained
8 / 9
trained 7B, 200 and 400 steps
7 / 9
lost the IDOR fix the base model had
Kimi-k2.5
6 / 9
Full-file mode, 9 tasks

Read that plainly. In full-file mode the untrained 7B already matched the 120B model. Training mostly taught the diff format, and cost one task. The tasks used for evaluation were also the training tasks, with no held-out split.

05Where it broke

Training longer made it worse. At 400 steps, diff-mode passes fell to 0 of 9. The obvious read is that the model forgot how to patch.

It hadn't. In full-file mode the same checkpoint still scored 7 of 9. The security skill survived. What collapsed was the output format: the model stopped producing diffs the harness could apply.

06Honest limits

  • The task suite is hand-built, and the eval tasks were the training tasks. Real codebases are messier.
  • This is research, not a product.

07What I'd do differently

  • A much larger task suite, with a held-out split kept away from training and fixed before the first run.
  • Format reward from day one. Reward a well-formed diff directly, so format collapse shows up as a falling reward, not a surprise at eval time.
  • Repeated runs with intervals, so a one-task difference reads as noise or signal, not a headline.

The same discipline drives my client eval work: verifiable rewards where they exist, pre-registered protocols where they don't. See AgentOps for the production side.

08Stack

  • Nous Research's Atropos (fork) with a custom environment
  • GRPO trainer in PyTorch
  • vLLM serving, Qwen2.5-7B-Instruct
  • Exploit harness, regression tests, Semgrep-style scanner
  • OpenRouter for commercial-model benchmarks
  • Python, GPU VM

stack · Atropos · GRPO · vLLM · Qwen2.5-7B · Semgrep · Python

Need a senior AI engineer who can own delivery?

Tell me what you're building and where it breaks. I reply to every message myself.

Contract CTO · Principal AI engineering · Forward-deployed AI engineering · Enterprise AI architecture