TL;DR
CWE-bench is a new, rigorous benchmark designed to evaluate how well AI agents can actually defend software rather than just attack it. By tasking agents with auditing and repairing 120 private, real-world code repositories across 73 vulnerability types, the authors show that while top agents can reach an 81% success rate with retries, their performance varies wildly depending on the specific type of security flaw.
What Problem Does This Paper Address?
In cybersecurity, there is a fundamental asymmetry: an attacker only needs to find one hole to succeed, whereas a defender must find and plug every single one without breaking the software's intended features. Despite this, most AI evaluations focus on "offense" (e.g., Capture The Flag challenges).
Existing defensive benchmarks often "cheat" by giving agents hints (like the exact line of code that is broken) or by using public vulnerabilities (CVEs) that the models likely saw during training. This paper introduces CWE-bench to close these gaps. It forces agents to act as real security engineers: they are given a codebase and a general threat model, and they must find, diagnose, and fix unknown vulnerabilities from scratch.
Methods
The authors formulated the task as a Markov Decision Process where an agent interacts with a repository via a sandboxed harness (reading files, running tests, editing code) without internet access.
The evaluation uses a dual-verification system:
- Programmatic Verifier: A patch only passes if it blocks the specific exploit (Security check $S$) AND passes all original unit tests (Functional check $F$).
- Agentic Judge Panel: To ensure the programmatic checks weren't too "dumb," the authors used a panel of three frontier LLMs (GPT-5.4, Claude Sonnet 5, Gemini 3.8 Flash) to review the patches for robustness and logic.
Datasets
The core contribution is the CWE-bench dataset, which consists of 120 private, held-out tasks.
- Diversity: It covers 73 distinct Common Weakness Enumeration (CWE) types and all ten OWASP Top 10:2025 categories.
- Languages: Tasks span eight programming languages, including Go, Java, C++, Python, and Rust.
- Realism: Every task is built on a real open-source repository with vulnerabilities injected specifically for this benchmark to prevent data contamination.
Key Insights and Ideas
- Vulnerability Type > Language: A surprising finding was that an agent's success depends much more on the type of vulnerability (e.g., Cryptography vs. Integrity) than the programming language it's written in.
- The "Consistency" Gap: Agents with identical "Pass@1" scores (success on the first try) performed very differently when allowed retries. Some agents are "swingy"—failing often but eventually finding a fix—while others are consistent but hit a hard ceiling.
- Agent Complementarity: No single agent was the best at everything. Grok 4.7 might lead in C++, while Gemini 4 Argon dominates in Go. Interestingly, the top three agents together solved 110 out of 120 tasks, even though the best individual agent only solved 97.
- The Pareto Frontier of Defense: There is a massive range in cost-efficiency. DeepSeek V4.1 Flash is incredibly cheap ($0.09/rollout), while Gemini 4 Argon is roughly 74x more expensive for only a modest gain in success rate.
Key Results
- Top Performers: Grok 4.7, Gemini 4 Argon, and GPT-6 Astra tied for the lead with a 68% pass@1 rate.
- Scaling with Retries: When allowed four attempts (pass@4), Grok 4.7 reached 81%, showing that "agentic reasoning" benefits significantly from multiple rolls of the dice.
- Hardest Tasks: "Integrity failures" (A08) proved the most difficult for AI, with the best agent only managing a 57% success rate. Conversely, "Cryptography" (A04) was the easiest, with Claude Opus 5.5 hitting 90%.
- Verifier Accuracy: The programmatic verifier and the agentic judge panel agreed on 93.9% of attempts, suggesting that automated grading of complex security patches is becoming highly reliable.
Limitations and Future Work
The authors acknowledge that while 73 CWEs is a broad start, it represents less than 10% of the 900+ weaknesses cataloged by MITRE. Furthermore, the benchmark currently focuses on "injected" vulnerabilities in real repos; future versions could look at multi-step logic flaws that span across entire microservice architectures.
The results suggest that the next frontier for defensive AI isn't just better models, but multi-agent systems that combine the specialized strengths of different models to cover the full spectrum of software weaknesses.
Summary updated