ACL Findings2026
RealSec-bench: A Benchmark for Evaluating Secure Code Generation in Real-World Repositories
Yanlin Wang, Ziyao Zhang, Chong Wang, Xinyi Xu, Mingwei Liu, Yong Wang, Jiachi Chen, Zibin Zheng
Abstract
Large Language Models (LLMs) have demonstrated remarkable capabilities in code generation, but their proficiency in producing secure code remains a critical, under-explored area. Existing benchmarks often fall short by relying on synthetic vulnerabilities or evaluating functional correctness in isolation, failing to capture the complex interplay between functionality and security found in real-world software. To address this gap, we introduce RealSec-bench, a new benchmark for secure code generation meticulously constructed from real-world, highrisk Java repositories. Our methodology employs a multi-stage pipeline that combines systematic SAST scanning with CodeQL, LLMbased false positive elimination, and rigorous human expert validation. The resulting benchmark contains 105 instances grounded in realword repository contexts, spanning 19 Common Weakness Enumeration (CWE) types and exhibiting a wide diversity of data flow complexities, including vulnerabilities with up to 34-hop inter-procedural dependencies. Using RealSec-bench, we conduct an extensive empirical study on 5 popular LLMs. We introduce a novel composite metric, SecurePass@k, to assess both functional correctness and security simultaneously. We find that while Retrieval-Augmented Generation (RAG) techniques can improve functional correctness, they provide negligible benefits to security. Furthermore, explicitly prompting models with general security guidelines often leads to compilation failures, harming functional correctness without reliably preventing vulnerabilities. Our work highlights the gap between functional and secure code generation in current LLMs. Our code and data are available at https://github.com/DeepS oftwareAnalytics/Realsec-code-Bench.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
1 top-tier paper has cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models cites SWE-bench: Can Language Models Resolve Real-world Github Issues?
- RepoReasoner: Evaluating Repository-Level Code Reasoning Ability of Long-Context Language Models cites RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation
- Large Language Models for Code: Security Hardening and Adversarial Testing cites CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
- RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation cites CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
Cited by top-tier papers1
Builds on11
- SWE-bench: Can Language Models Resolve Real-world Github Issues?Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao et al.ICLR 2024 · 2,082 citations
- CodeGen: An Open Large Language Model for Code with Multi-Turn Program SynthesisErik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu et al.ICLR 2023 · 234 citations
- RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and GenerationFengji Zhang, Bei Chen, Yue Zhang, Jacky Keung et al.EMNLP 2023 · 110 citations
- Large Language Models for Code: Security Hardening and Adversarial TestingJingxuan He, Martin T. VechevCCS 2023 · 98 citations
- Reentrancy Vulnerability Detection and Localization: A Deep Learning Based Two-phase ApproachZhuo Zhang, Yan Lei, Meng Yan, Yue Yu et al.ASE 2022 · 56 citations
Related papers
- RESCUE: Retrieval Augmented Secure Code GenerationJiahao Shi, Tianyi ZhangICLR 2026 · 15 citations
- A.S.E: A Repository-Level Benchmark for Evaluating Security in AI-Generated CodeKeke Lian, Wang Bin, Lei Zhang, Libo Chen et al.ACL Findings 2026 · 3 citations
- Rethinking the Evaluation of Secure Code GenerationShih-Chieh Dai, Jun Xu, Guanhong TaoICSE 2026 · 1 citation
- AutoSUIT Bench - Automated Security UnIt Test Benchmark for LLM CodingSamuel Osebe, Fan Yang, Junyi Li, Yue Gu et al.ACL Findings 2026
- SEC-bench: Automated Benchmarking of LLM Agents on Real-World Software Security TasksHwiwon Lee, Ziqi Zhang, Hanxiao Lu, Lingming ZhangNeurIPS 2025 · 86 citations
