NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SecureAgentBench: Benchmarking Secure Code Generation under Realistic Vulnerability Scenarios

Junkai Chen, Huihui Huang, Yunbo Lyu, Junwen An, Jieke Shi, Chengran Yang, Ting Zhang, Haoye Tian, Yikun Li, Zhenhao Li, Xin Zhou, Xing Hu, David Lo · DOI

Executive Summary

SecureAgentBench is a rigorous new benchmark designed to evaluate the security of code generated by LLM-powered agents in complex, repository-level environments. The study reveals a critical gap in current AI capabilities: even top-performing agents produce "correct and secure" code less than 15% of the time. Often, these agents fix one bug while inadvertently introducing entirely new vulnerabilities, highlighting that functional correctness is not a reliable proxy for security.

The Challenge of Secure Autonomous Coding

While Large Language Models (LLMs) excel at generating isolated code snippets, the emergence of code agents—autonomous systems like SWE-agent, OpenHands, or Aider that edit entire repositories—introduces significant security risks.

Existing benchmarks often rely on "toy" problems, such as single-function completions without project context. These fail to reflect real-world software development, where vulnerabilities typically arise from multi-file edits within large codebases. Furthermore, standard evaluations often only check if a known bug is fixed, ignoring whether the agent introduced new security flaws during the process.

The SecureAgentBench Framework

To address these shortcomings, the authors developed a comprehensive evaluation pipeline that moves beyond simple functional testing.

Overview of the SecureAgentBench framework, illustrating the flow from requirements and codebase to agent-generated patches and multi-stage evaluation.

The framework employs a three-pronged evaluation strategy:

  1. Differential Testing: Verifies if the generated code passes the project's official functional test suite.
  2. PoC Exploits: Checks if the code remains vulnerable to the original, historically reported exploit.
  3. Static Analysis (SAST): Uses tools like Semgrep to detect if the agent introduced new types of vulnerabilities (e.g., memory safety issues) not present in the original code.

Dataset Construction

The benchmark consists of 105 high-quality coding tasks derived from real-world open-source projects such as Harfbuzz, Wireshark, and OpenSSL. The selection process involved a rigorous multi-stage pipeline to ensure tasks were realistic and verifiable.

The data curation pipeline for SecureAgentBench, showing the filtering process from nearly 5,000 vulnerabilities down to 105 high-quality tasks.

The researchers utilized Vulnerability Backtracking to identify the exact commit where a human developer originally introduced a vulnerability. By resetting the repository to this state, they could test if an AI agent would repeat the same mistake when given the original development requirements. The resulting dataset covers 11 different CWE categories, with a focus on critical memory safety issues.

Key Insights and Experimental Results

The researchers evaluated three agents (SWE-agent, OpenHands, Aider) paired with leading LLMs (Claude 3.7 Sonnet, GPT-4.1, DeepSeek-V3.1).

The "Correct but Vulnerable" Trap

A major finding is that a significant portion of agent-generated code is functionally perfect—passing all unit tests—yet remains exploitable. Over 20% of functionally correct solutions were flagged by SAST tools for introducing new risks. This "security-blind" correctness poses a major threat to automated software maintenance.

Performance Benchmarks

  • Low Overall Success: The average "Correct and Secure" (C&S) rate across all agent-model combinations was only 9.2%.
  • Top Performer: SWE-agent combined with DeepSeek-V3.1 achieved the highest C&S rate at 15.2%.
  • The Prompting Paradox: Adding "security reminders" to prompts did not meaningfully improve security. Instead, it often made agents overly cautious, leading to higher rates of "No Output" or time-outs without improving the quality of the code actually produced.
  • Failure Modes: Repository-level tasks remain highly challenging; 28.9% of attempts resulted in no output, and 21.8% failed to compile.

Limitations and Future Directions

The current benchmark focuses on C/C++ projects due to the availability of high-quality vulnerability data from OSS-Fuzz. Future work should expand to memory-safe languages like Java or Python. Additionally, the reliance on SAST tools can introduce false positives, suggesting a need for more refined automated verification.

The results of SecureAgentBench underscore a pressing need for "security alignment" in LLM training. Moving forward, the community must look beyond simple prompting and focus on architectural interventions and training-time security constraints to ensure that autonomous code agents can be trusted in production environments.

Summary updated

BibTeX
@inproceedings{chen2026secureagentbench,
  author = {Junkai Chen and Huihui Huang and Yunbo Lyu and Junwen An and Jieke Shi and Chengran Yang and Ting Zhang and Haoye Tian and Yikun Li and Zhenhao Li and Xin Zhou and Xing Hu and David Lo},
  title = {{SecureAgentBench: Benchmarking Secure Code Generation under Realistic Vulnerability Scenarios}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1107},
}
Figure