# Gemma security agents fix more vulnerabilities with auto-built harnesses, not retraining

A NIST and Grenoble preprint lets a strong model rewrite the instructions, tools and controls around a weaker one. On SEC-bench, Gemma-4-31B went from fixing under half of real vulnerabilities to more than three quarters, with no change to its weights.

- Category: Agents
- Readiness level: III (Open source) on Science Underway's four-step scale, as proposed
- Published: 2026-11-30
- Editor: Stefan Perdal
- URL: https://scienceunderway.com/articles/gemma-security-agents-fix-more-vulnerabilities-with-auto-built-harnesses-not-ret

## The study

Reinforcement Building: Toward Self-Improving Harnesses for Defensive Software Security Agents (preprint, not peer reviewed). arXiv 2611.36559. https://arxiv.org/abs/2611.36559

## At a glance

- What it shows: An AI model that studies another model's failed attempts can redesign the software around it, its instructions and tools, so that it fixes far more security bugs. On the main benchmark, this beat both rival methods and retraining the model, and needed far fewer practice runs than retraining.
- What it does not show: It does not show the method working on new, unreleased bugs or inside a real security team. Every test used public, known vulnerabilities in C and C++ code.
- Why it matters: New AI models arrive every few weeks, and hand-tuning the setup for each one is slow. A cheap, automatic way to tune that setup could let defenders adopt new models quickly, including small ones they can run in-house.

## What the study shows

An AI agent is a language model wrapped in a harness. The harness is everything around the model: its instructions, the tools it can call, memory notes and rules such as step limits. Harnesses are usually written by hand for one model and may work worse with another.

The authors, from the US National Institute of Standards and Technology (NIST) and Université Grenoble Alpes, propose a loop they call Reinforcement Building. A target model tries to patch training vulnerabilities. A program checks each patch by building the project and replaying the crashing input. A stronger optimiser model, Claude Opus 5.5 in the main runs, reads every attempt and proposes edits to the harness. An edit is kept only if it improves results on a separate set of held-out tasks by a statistical test.

They tested it on two open-weight models, Gemma-4-31B and the much smaller Gemma-4-E4B. The main benchmark was SEC-bench, 200 real vulnerabilities with public CVE identifiers. With a single attempt per bug, the built harness lifted Gemma-4-31B from about 46% to about 78% fixed. The best rival harness builder, ContraFix, reached about 64%. Reinforcement learning with verifiable rewards (RLVR), which retrains the model on pass or fail scores, reached about 58%.

The small model gained most. It went from fixing about 5% of SEC-bench bugs to about 41%. RLVR made no significant gain for it, because the model almost never succeeded, so the pass or fail score gave it almost nothing to learn from.

The authors report that the method learns quickly. On Gemma-4-31B it reached its best score after 190 practice runs, while RLVR needed about seven times as many. For the Gemma-4-31B build, the optimiser worked for 85 minutes, at about $22 in API fees.

Each model got a different harness, fitted to its own weakness. Gemma-4-31B often got stuck re-reading the same code, so its harness gained a loop guard and a rule to write a hypothesis before each command. Gemma-4-E4B gave up before testing its patch, so its harness gained a one-step rebuild-and-test tool and a rule not to finish until the test passes. A harness built for one model sometimes made another model worse.

## Our reading

In our reading, the central point is about where improvement comes from. A failed attempt holds a lot of information: where the agent looped, which edit broke the build, when it quit. Retraining on a pass or fail score throws all of that away. Letting a capable model read the record and change the setup uses it. That explains why the small model improved here when retraining did nothing.

The result also suggests that a poor benchmark score can understate a model. Gemma-4-E4B looked nearly useless at about 5%. Much of that turned out to be bad habits that a better harness could correct. For teams that want small models running on their own hardware, that matters.

The evidence is strongest on SEC-bench. On the two harder benchmarks, with 41 and 53 tasks, the method still beat the plain setup, but it was not clearly better than the rivals. This is a preprint and has not been peer reviewed. We rate it Readiness level III, open source available: the authors say they release code, harnesses and results, at an anonymous review link.

The rest of the article (what it means, limits, what to watch) is free for members: https://scienceunderway.com/articles/gemma-security-agents-fix-more-vulnerabilities-with-auto-built-harnesses-not-ret

## How this was made

An AI model read the study and wrote this article in the structure Science Underway uses. An editor reviewed it and approved it for publication. Check the original study before you rely on the details.

---
Source: Science Underway, https://scienceunderway.com/. Please link to the article when you cite it.
