Red team, blue team agents
A single review pass finds only what one agent thinks to look for. Pit an
attacker agent against a defender agent with an independent referee between
them, and security becomes a loop that keeps score: every fix is re-attacked,
every finding graded by someone who did not write it. Skip the referee and the
attacker inflates its own exploits while the defender declares victory on the
first patch.
Team
- Red agent (
security-engineer-role, penetration-test-prep): attacks an
assigned surface and files findings.
- Blue agent (
security-code-review): fixes the highest-ranked findings and
writes fix notes.
- Referee (
vulnerability-triage): dedupes, scores, and confirms, so
neither side marks its own homework.
Shape: an adversarial pair driven around a fix-and-re-attack loop.
Method
- Assign the surface with rules of engagement. Split targets by trust
boundary: authentication, input parsing, multi-tenancy, deserialization.
Hand red a scope file listing in-bounds targets and forbidding the rest, so
it probes the system, not the harness or third-party hosts.
- Run the red pass into
findings.jsonl. One record per finding: target,
technique, repro steps, evidence, claimed severity. Require a working repro;
a finding without one is a hypothesis the referee will drop.
- Triage before anyone fixes. The referee dedupes, scores with CVSS
adjusted for reachability, and cuts false positives into a ranked
triage.md. Attackers over-rate severity and defenders under-rate it; a
neutral score ends that argument.
- Blue fixes highest risk first. For each finding id, patch and write a fix
note stating what changed and why the whole bug class is closed, not just the
one repro.
- Red re-verifies against the patched build. Re-run every fixed finding
(pass or fail) plus a regression sweep for new surface the patch opened.
Verdicts return to
findings.jsonl as verified or reopened.
- Loop to the bar. Stop when a full red pass yields no new critical or high
and all triaged criticals are verified closed, or a round budget of three to
five is spent. Ship remaining mediums under a written risk acceptance.
Run it
In Claude Code, spawn red and blue as separate subagents with their role skills
loaded and one shared directory for the artifact files; the orchestrator runs
red, referee, blue, red again, reading each file to pick the next call, and
keeps the referee distinct so scoring stays independent. Port the loop to CrewAI
as three agents in a sequential process re-queued each round, to AutoGen as a
GroupChat whose referee gates turns, or to LangGraph as a cyclic graph with a
conditional edge on the termination check.
Signals it works
- The referee reopens some fixes, proving verification is real, not a rubber
stamp.
- Shipped severity is the referee's number, not red's or blue's.
- New-critical count per round trends to zero instead of oscillating.
Boundaries
This runs the adversarial loop; it does not replace a human penetration test or
a design threat model, which threat-modeling owns. Agents miss novel logic
flaws and anything needing real credentials or physical access. Rules of
engagement, disclosure, and the meaning of "critical" are your organization's
policy, and a human signs the final risk acceptance.
1---2name: agent-red-team-blue-team3description: Run attacker and defender agents in a fix-and-re-attack loop so exploitable bugs get found, triaged, fixed, and verified before ship. Use when you want a system probed and hardened by an agent team rather than one pass of review.4---56# Red team, blue team agents78A single review pass finds only what one agent thinks to look for. Pit an9attacker agent against a defender agent with an independent referee between10them, and security becomes a loop that keeps score: every fix is re-attacked,11every finding graded by someone who did not write it. Skip the referee and the12attacker inflates its own exploits while the defender declares victory on the13first patch.1415## Team1617- **Red agent** (`security-engineer-role`, `penetration-test-prep`): attacks an18 assigned surface and files findings.19- **Blue agent** (`security-code-review`): fixes the highest-ranked findings and20 writes fix notes.21- **Referee** (`vulnerability-triage`): dedupes, scores, and confirms, so22 neither side marks its own homework.2324Shape: an adversarial pair driven around a fix-and-re-attack loop.2526## Method27281. **Assign the surface with rules of engagement.** Split targets by trust29 boundary: authentication, input parsing, multi-tenancy, deserialization.30 Hand red a scope file listing in-bounds targets and forbidding the rest, so31 it probes the system, not the harness or third-party hosts.322. **Run the red pass into `findings.jsonl`.** One record per finding: target,33 technique, repro steps, evidence, claimed severity. Require a working repro;34 a finding without one is a hypothesis the referee will drop.353. **Triage before anyone fixes.** The referee dedupes, scores with CVSS36 adjusted for reachability, and cuts false positives into a ranked37 `triage.md`. Attackers over-rate severity and defenders under-rate it; a38 neutral score ends that argument.394. **Blue fixes highest risk first.** For each finding id, patch and write a fix40 note stating what changed and why the whole bug class is closed, not just the41 one repro.425. **Red re-verifies against the patched build.** Re-run every fixed finding43 (pass or fail) plus a regression sweep for new surface the patch opened.44 Verdicts return to `findings.jsonl` as verified or reopened.456. **Loop to the bar.** Stop when a full red pass yields no new critical or high46 and all triaged criticals are verified closed, or a round budget of three to47 five is spent. Ship remaining mediums under a written risk acceptance.4849## Run it5051In Claude Code, spawn red and blue as separate subagents with their role skills52loaded and one shared directory for the artifact files; the orchestrator runs53red, referee, blue, red again, reading each file to pick the next call, and54keeps the referee distinct so scoring stays independent. Port the loop to CrewAI55as three agents in a sequential process re-queued each round, to AutoGen as a56GroupChat whose referee gates turns, or to LangGraph as a cyclic graph with a57conditional edge on the termination check.5859## Signals it works6061- The referee reopens some fixes, proving verification is real, not a rubber62 stamp.63- Shipped severity is the referee's number, not red's or blue's.64- New-critical count per round trends to zero instead of oscillating.6566## Boundaries6768This runs the adversarial loop; it does not replace a human penetration test or69a design threat model, which `threat-modeling` owns. Agents miss novel logic70flaws and anything needing real credentials or physical access. Rules of71engagement, disclosure, and the meaning of "critical" are your organization's72policy, and a human signs the final risk acceptance.