CWE-bench: Refocusing Agentic Security from Exploitation to Defense
Gonzalo Gonzalez-Pumariega, Ajay Jagannath, Adit Jain, Guram Gogia, Soumyadeep Bakshi, Nazneen Rajani
cs.CR, cs.AI, cs.SE
2026-10-13
CWE-bench injects 73 flaws in 120 real repos. Agents patch from a threat model only; the fix must block the exploit and pass tests. Best pass@1 is 68%. Grok 4.7 hits 81% pass@4.
An attacker only needs one path. A defender has to close every path and leave the feature in place. A path traversal on a file server is the plain case: one handler that builds a path from user input can read files outside the shared directory. The defender has to fix every such handler. Turning downloads off removes the service.
Defense benchmarks each loosen a different constraint. Fixes for public CVEs may already be in the training data, so a correct patch can be recall. Repositories generated together with their tests sit outside real code. Handing the agent a vulnerability description, a proof-of-concept input, or a file and line number skips the audit. Suites limited to memory safety in C and C++ barely touch access control, authentication, or logic bugs, and several cover only one to four of the ten OWASP Top 10:2025 categories.
CWE-bench closes those three gaps: real repositories, injections with no published fix, and a threat model instead of a diagnosis.
The private set has 120 tasks, 73 CWE types, eight languages, and all ten OWASP categories, with 10 to 14 tasks in each. The language split is Go 26, Java 20, C++ 19, JavaScript 16, Python 14, C 12, TypeScript 10, and Rust 3.
Each task starts from an open-source repository that already had a real CVE, then adds vulnerabilities with no public patch. The agent receives the repository and an audit note describing what the system does and where the attack surface is. It is not told the weakness, the location, or how many sites are vulnerable. Internet access is blocked; only the model API is reachable. The limit is one hour, and a timeout is graded on whatever edits are already in the tree.
Each task comes with three exploits and a functionality suite. A patch passes only when the exploits are blocked and the original tests still pass. Stopping the attack by deleting the feature scores 0. Keeping the tests green while the exploit still works scores 0. A reference patch has to clear both checks before the task is accepted.
Three agent judges each get a copy of the patched repository. They can read code, build, and run the verifier, and they majority-vote on security, preserved behavior, resistance to attack variants, grading integrity, and build soundness. During development, every run where the judges disagreed with the programmatic verifier was reviewed by hand. Those reviews added probes for incomplete repairs and replaced checks that expected the reference patch's shape with checks of behavior. The reported score is still the programmatic verifier.
Eleven models ran inside Claude Code, Codex, Antigravity, or OpenCode, at high reasoning effort, with four independent attempts per task. A score belongs to the model and the harness together.
Programmatic pass@1 ties Grok 4.7, Gemini 4 Argon, and GPT-6 Astra at 68%. Claude Opus 5.5 scores 67%. Pass@4, the share of tasks solved at least once in four attempts, is 81% for Grok 4.7, 79% for Opus, 75% for Gemini, and 74% for Astra. Inkling sits at 37% and 53%. The programmatic verifier and the judge panel agree on 93.9% of attempts (κ = 0.88). The same four lead on judge pass@1, at 64% for Grok, 62% for Gemini, 66% for Astra, and 67% for Opus.
| System (harness) | pass@1 | pass@4 | Judge pass@1 | Cost per attempt |
| Grok 4.7 (OpenCode) | 68% | 81% | 64% | $2.75 |
| Gemini 4 Argon (Antigravity) | 68% | 75% | 62% | $6.63 |
| GPT-6 Astra (Codex) | 68% | 74% | 66% | $2.85 |
| Claude Opus 5.5 (Claude Code) | 67% | 79% | 67% | $0.79 |
| DeepSeek V4.1 Flash (OpenCode) | 55% | 74% | 53% | $0.09 |
| Inkling (OpenCode) | 37% | 53% | 33% | $3.00 |
The shared 68% hides different retry behavior. Astra passes all four attempts on 74 tasks and is mixed on only 15, so another try adds little. Grok 4.7 is clean on 63 tasks and mixed on 34, which is why pass@4 reaches 81%. Solved at least once: Grok 97, Gemini 90, Astra 89. All three solve 69 tasks in common, and together they solve 110 of 120. Grok solves 20 tasks Astra never does. Astra solves 12 that Grok never does.
Price splits the same tie. The three models at 68% cost $2.75, $2.85, and $6.63. Opus reaches 67% at $0.79. The step from Opus to Grok is about 3.5 times the cost for one point of pass@1, while Gemini pays $6.63 for the same 68%. DeepSeek V4.1 Flash reaches 55% pass@1 and 74% pass@4 at $0.09. The step from DeepSeek to Gemini costs about 74 times more for 1.2 times the pass rate. No cheaper model in the set posts a higher pass@1 than these five.
Weakness class moves the score more than language. Among the three tied models, Grok 4.7 leads C/C++ at 75%, Gemini leads Go at 76%, and Astra leads JS/TS at 72% and Python at 71%. Integrity failures (A08) are the hardest category: the best model, Grok 4.7, reaches 57%. Cryptography (A04) is the easiest: Opus reaches 90%. No model leads every language or every category.
An offensive win shows that a flaw can be triggered. It does not show that a patch blocks the exploit and keeps the program working. Here the only hint is a threat model, and audit and repair happen in the same run.
A single 68% is a poor buying signal. Opus at $0.79 trails Gemini at $6.63 by one point of pass@1 and leads it on pass@4, 79% to 75%. DeepSeek matches Astra's 74% pass@4 at $0.09 against $2.85. Together the three leaders cover 110 tasks, against 97 for the best one of them.
Size is not the advantage. PatchEval has 230 tasks but gives the model a vulnerability description, and it covers 7 of 10 OWASP categories. The CyberGym end-to-end subset has 920 tasks and only 1 of 10. LiveCVEBench has 190 tasks, 9 categories, and 74 CWEs, built from public CVEs and supplied with a bug report. The 120 tasks here buy full OWASP coverage, real repositories, unpublished injections, and no diagnosis. The lead rotates across categories, so a narrow suite would have ranked these models differently.
Seventy-three CWE types are a thin slice of a catalog with more than 900. Readiness for defensive work needs per-class numbers. One aggregate is not that map, and this map is still narrow.
The flaws are planted. Each repository did have a real CVE, but the scored bugs are new injections with no public patch, written so the answer cannot leak in from training data. The shape of the bug is whatever the authors inserted. Nothing here checks the same agents on naturally occurring, unlabeled vulnerabilities.
The graders agree on 93.9% of attempts, yet judge pass@1 is lower for the leaders. Human review happened while the verifier was being built, not as an independent audit of the final 120 tasks. The security check targets the exploits written for the task. How many attack variants the finished verifier runs is not reported. Functionality tests are author-written, so untested behavior can break without a penalty.
The harness is glued to the model, with no swap of scaffolding. Refusals count as failures, and per-model refusal rates are not reported. Rust has three tasks, so language scores there are thin. The set is private, which blocks leakage and also keeps outsiders from checking whether a task is easy or an exploit is narrow. The jump from 97 to 110 tasks is an overlap count, not a system that routes work or merges patches.
One attempt at 68% pass@1 still leaves 32% of repositories without a patch that both blocks the exploit and keeps the tests green. The discussion's claim that repair is becoming practical refers to retries, and to picking models by weakness class.