Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarking
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) are increasingly used for program synthesis, yet they often generate code that is functionally plausible but insecure. Progress in secure code generation has been hindered by benchmarks that are small, non-executable, leak mitigation details, or rely on noisy analyzers and subjective judgments, making it difficult to measure whether security improves without sacrificing correctness. We address these gaps with CodeSecEval, an execution-based benchmark for secure code generation, comprising 255 Python tasks spanning 77 CWE categories. Each task provides paired insecure and secure implementations together with executable functional and vulnerability-targeted security tests, enabling precise and reproducible evaluation of secure code generation and insecure-code repair. Building on CodeSecEval, we propose SecAwareCoder, an agent-based framework that shifts code generation toward secure-by-construction synthesis. SecAwareCoder performs task-adaptive threat modeling to identify security-sensitive regions and derive task-grounded vulnerability hypotheses, uses these hypotheses to guide both constraint-aware code generation and security-aware test synthesis, and leverages execution feedback for targeted refinement. Experiments across multiple LLM backbones show that SecAwareCoder consistently improves Pass@1 and security robustness over prompting and analyzer-driven baselines, narrowing the security--correctness gap in LLM code generation.
Key facts. Cited by 26 papers in the map (data through 7 Oct 2026). Builds on 20 of its 36 references that are in the map. First posted on arXiv 2 Jul 2024.
Builds on
20 of 36 references.
References · 20
- 2023GPT-4 Technical Reportcited by 18,132
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2022DS-1000: A Natural and Reliable Benchmark for Data Science Code Generationcited by 442
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
- 2018Mapping Language to Code in Programmatic Contextcited by 104
8 more
- 2023How Secure is Code Generated by ChatGPT?cited by 77
- 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 63
- 2024Instruction Tuning for Secure Code Generationcited by 63
- 2023LLMSecEval: A Dataset of Natural Language Prompts for Security Evaluationscited by 58
- 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 52
- 2019JuICe: A Large Scale Distantly Supervised Dataset for Open Domain Context-based Code Generationcited by 49
- 2022Fault-Aware Neural Code Rankerscited by 33
- 2023Automatic Static Bug Detection for Machine Learning Libraries: Are We There Yet?cited by 1
Built on by
Citing papers per year: 2024: 2; 2025: 18; 2026: 6.
26 papers.
Sort:
By area:
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMscited by 24
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasetscited by 15
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2025Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overviewcited by 7
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2024AIGCodeSet: A New Annotated Dataset for AI Generated Code Detectioncited by 5
- 2025LLM Benchmarking with LLaMA2: Evaluating Code Development Performance Across Multiple Programming Languagescited by 5
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-benchcited by 5
- 2025Prompt to Pwn: Automated Exploit Generation for Smart Contractscited by 4
- 2026What Breaks When LLMs Code? Characterizing Operational Safety Failures of Agentic Code Assistantscited by 3
14 more
- 2025SOK: Exploring Hallucinations and Security Risks in AI-Assisted Software Development with Insights for LLM Deploymentcited by 2
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2025RA-Gen: A Controllable Code Generation Framework Using ReAct for Multi-Agent Task Executioncited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2025Program Semantic Inequivalence Game with Large Language Modelscited by 1
- 2025LLM Performance for Code Generation on Noisy Taskscited by 1
- 2025Secure Code Generation at Scale with Reflexioncited by 1
- 2026Extracting Recurring Vulnerabilities from Black-Box LLM-Generated Softwarecited by 1
- 2026Refusal Evaluation in Coding LLMs and Code Agents: A Systematic Review of Thirteen Malicious-Code Prompt Corpora (2023-2025)cited by 1
- 2025Optimizing Token Choice for Code Watermarking: An RL Approachcited by 0
- 2025GitHub's Copilot Code Review: Can AI Spot Security Flaws Before You Commit?cited by 0
- 2026Is Vibe Coding the Future? An Empirical Assessment of LLM Generated Codes for Construction Safetycited by 0
- 2026PYTHALAB-MERA: Validation-Grounded Memory, Retrieval, and Acceptance Control for Frozen-LLM Coding Agentscited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026What Breaks When LLMs Code? Characterizing Operational Safety Failures of Agentic Code Assistants29 May 2026
- 2026Refusal Evaluation in Coding LLMs and Code Agents: A Systematic Review of Thirteen Malicious-Code Prompt Corpora (2023-2025)19 May 2026
- 2026PYTHALAB-MERA: Validation-Grounded Memory, Retrieval, and Acceptance Control for Frozen-LLM Coding Agents8 May 2026
- 2026Is Vibe Coding the Future? An Empirical Assessment of LLM Generated Codes for Construction Safety14 Apr 2026
- 2026Extracting Recurring Vulnerabilities from Black-Box LLM-Generated Software2 Feb 2026
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025Secure Code Generation at Scale with Reflexion5 Nov 2025
- 2025RA-Gen: A Controllable Code Generation Framework Using ReAct for Multi-Agent Task Execution9 Oct 2025
- 2025GitHub's Copilot Code Review: Can AI Spot Security Flaws Before You Commit?17 Sep 2025
- 2025Optimizing Token Choice for Code Watermarking: An RL Approach16 Aug 2025
- 2025Prompt to Pwn: Automated Exploit Generation for Smart Contracts2 Aug 2025
14 more
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-bench30 Jun 2025
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMs6 Jun 2025
- 2025LLM Performance for Code Generation on Noisy Tasks29 May 2025
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025Program Semantic Inequivalence Game with Large Language Models2 May 2025
- 2025LLM Benchmarking with LLaMA2: Evaluating Code Development Performance Across Multiple Programming Languages24 Mar 2025
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasets21 Mar 2025
- 2025Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overview13 Mar 2025
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applications3 Mar 2025
- 2025SOK: Exploring Hallucinations and Security Risks in AI-Assisted Software Development with Insights for LLM Deployment31 Jan 2025
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representations22 Jan 2025
- 2024AIGCodeSet: A New Annotated Dataset for AI Generated Code Detection21 Dec 2024
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities2 Sep 2024
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-benchcited by 5
- 2026What Breaks When LLMs Code? Characterizing Operational Safety Failures of Agentic Code Assistantscited by 3
- 2025RA-Gen: A Controllable Code Generation Framework Using ReAct for Multi-Agent Task Executioncited by 2
- 2026Refusal Evaluation in Coding LLMs and Code Agents: A Systematic Review of Thirteen Malicious-Code Prompt Corpora (2023-2025)cited by 1
- 2026PYTHALAB-MERA: Validation-Grounded Memory, Retrieval, and Acceptance Control for Frozen-LLM Coding Agentscited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026What Breaks When LLMs Code? Characterizing Operational Safety Failures of Agentic Code Assistants29 May 2026
- 2026Refusal Evaluation in Coding LLMs and Code Agents: A Systematic Review of Thirteen Malicious-Code Prompt Corpora (2023-2025)19 May 2026
- 2026PYTHALAB-MERA: Validation-Grounded Memory, Retrieval, and Acceptance Control for Frozen-LLM Coding Agents8 May 2026
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025RA-Gen: A Controllable Code Generation Framework Using ReAct for Multi-Agent Task Execution9 Oct 2025
- 2025How Safe Are AI-Generated Patches? A Large-scale Study on Security Risks in LLM and Agentic Automated Program Repair on SWE-bench30 Jun 2025
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMscited by 24
- 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasetscited by 15
- 2025Vulnerability Detection: From Formal Verification to Large Language Models and Hybrid Approaches: A Comprehensive Overviewcited by 7
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMscited by 6
- 2024AIGCodeSet: A New Annotated Dataset for AI Generated Code Detectioncited by 5
- 2025LLM Benchmarking with LLaMA2: Evaluating Code Development Performance Across Multiple Programming Languagescited by 5
- 2025Prompt to Pwn: Automated Exploit Generation for Smart Contractscited by 4
- 2025SOK: Exploring Hallucinations and Security Risks in AI-Assisted Software Development with Insights for LLM Deploymentcited by 2
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarioscited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
12 most cited of 18 All 18 (JSON)
- 2026Is Vibe Coding the Future? An Empirical Assessment of LLM Generated Codes for Construction Safety14 Apr 2026
- 2026Extracting Recurring Vulnerabilities from Black-Box LLM-Generated Software2 Feb 2026
- 2025Secure Code Generation at Scale with Reflexion5 Nov 2025
- 2025GitHub's Copilot Code Review: Can AI Spot Security Flaws Before You Commit?17 Sep 2025
- 2025Prompt to Pwn: Automated Exploit Generation for Smart Contracts2 Aug 2025
- 2025MultiAIGCD: A Comprehensive dataset for AI Generated Code Detection Covering Multiple Languages, Models,Prompts, and Scenarios29 Jul 2025
- 2025The Scales of Justitia: A Comprehensive Survey on Safety Evaluation of LLMs6 Jun 2025
- 2025LLM Performance for Code Generation on Noisy Tasks29 May 2025
- 2025CodeMirage: A Multi-Lingual Benchmark for Detecting AI-Generated and Paraphrased Source Code from Production-Level LLMs27 May 2025
- 2025Program Semantic Inequivalence Game with Large Language Models2 May 2025
- 2025LLM Benchmarking with LLaMA2: Evaluating Code Development Performance Across Multiple Programming Languages24 Mar 2025
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasets21 Mar 2025
12 newest of 18 All 18 (JSON)