Enhancing Large Language Models for Secure Code Generation: A Dataset-driven Study on Vulnerability Mitigation
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have brought significant advancements to code generation, benefiting both novice and experienced developers. However, their training using unsanitized data from open-source repositories, like GitHub, introduces the risk of inadvertently propagating security vulnerabilities. To effectively mitigate this concern, this paper presents a comprehensive study focused on evaluating and enhancing code LLMs from a software security perspective. We introduce SecuCoGenfootnoteSecuCoGen has been uploaded as supplemental material and will be made publicly available after publication., a meticulously curated dataset targeting 21 critical vulnerability types. SecuCoGen comprises 180 samples and serves as the foundation for conducting experiments on three crucial code-related tasks: code generation, code repair and vulnerability classification, with a strong emphasis on security. Our experimental results reveal that existing models often overlook security concerns during code generation, leading to the generation of vulnerable code. To address this, we propose effective approaches to mitigate the security vulnerabilities and enhance the overall robustness of code generated by LLMs. Moreover, our study identifies weaknesses in existing models' ability to repair vulnerable code, even when provided with vulnerability information. Additionally, certain vulnerability types pose challenges for the models, hindering their performance in vulnerability classification. Based on these findings, we believe our study will have a positive impact on the software engineering community, inspiring the development of improved methods for training and utilizing LLMs, thereby leading to safer and more trustworthy model deployment.
Key facts. Cited by 14 papers in the map (data through 7 Oct 2026). Builds on 24 of its 47 references that are in the map. First posted on arXiv 25 Oct 2023.
Builds on
24 of 47 references.
References · 24
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 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
- 2022A Systematic Evaluation of Large Language Models of Codecited by 360
12 more
- 2021Generating Datasets with Pretrained Language Modelscited by 192
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 117
- 2018Mapping Language to Code in Programmatic Contextcited by 104
- 2022CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generationcited by 87
- 2022Experiences from Using Code Explanations Generated by Large Language Models in a Web Software Development E-Bookcited by 84
- 2023InPars-v2: Large Language Models as Efficient Dataset Generators for Information Retrievalcited by 73
- 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 63
- 2019JuICe: A Large Scale Distantly Supervised Dataset for Open Domain Context-based Code Generationcited by 49
- 2022CodeFill: Multi-token Code Completion by Jointly Learning from Structure and Naming Sequencescited by 49
- 2021Neural Transfer Learning for Repairing Security Vulnerabilities in C Codecited by 36
- 2019A Manually-Curated Dataset of Fixes to Vulnerabilities of Open-Source Softwarecited by 28
Built on by
Citing papers per year: 2024: 3; 2025: 9; 2026: 2.
14 papers.
Sort:
By area:
- 2024Securing Large Language Models: Threats, Vulnerabilities and Responsible Practicescited by 36
- 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositoriescited by 14
- 2025Rethinking the Evaluation of Secure Code Generationcited by 10
- 2025Can You Really Trust Code Copilots? Evaluating Large Language Models from a Code Security Perspectivecited by 6
- 2025RefleXGen:The unexamined code is not worth usingcited by 4
- 2025Secure-Instruct: An Automated Pipeline for Synthesizing Instruction-Tuning Datasets Using LLMs for Secure Code Generationcited by 2
- 2025Attention Distance: A Novel Metric for Directed Fuzzing with Large Language Modelscited by 2
- 2026Learning to Generate Secure Code via Token-Level Rewardscited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Modelscited by 1
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agentscited by 1
- 2024Ocassionally Secure: A Comparative Analysis of Code Generation Assistantscited by 0
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision2 Mar 2026
- 2026Learning to Generate Secure Code via Token-Level Rewards26 Feb 2026
- 2025Attention Distance: A Novel Metric for Directed Fuzzing with Large Language Models19 Dec 2025
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents24 Nov 2025
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Models24 Nov 2025
- 2025RefleXGen:The unexamined code is not worth using27 Oct 2025
- 2025From Specification to Service: Accelerating API-First Development Using Multi-Agent Systems22 Oct 2025
- 2025Secure-Instruct: An Automated Pipeline for Synthesizing Instruction-Tuning Datasets Using LLMs for Secure Code Generation8 Oct 2025
- 2025Can You Really Trust Code Copilots? Evaluating Large Language Models from a Code Security Perspective15 May 2025
- 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositories29 Apr 2025
- 2025Rethinking the Evaluation of Secure Code Generation18 Mar 2025
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities2 Sep 2024
- 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositoriescited by 14
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agentscited by 1
- 2025From Specification to Service: Accelerating API-First Development Using Multi-Agent Systemscited by 0
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents24 Nov 2025
- 2025From Specification to Service: Accelerating API-First Development Using Multi-Agent Systems22 Oct 2025
- 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositories29 Apr 2025
- 2024Securing Large Language Models: Threats, Vulnerabilities and Responsible Practicescited by 36
- 2025Rethinking the Evaluation of Secure Code Generationcited by 10
- 2025Can You Really Trust Code Copilots? Evaluating Large Language Models from a Code Security Perspectivecited by 6
- 2025RefleXGen:The unexamined code is not worth usingcited by 4
- 2025Attention Distance: A Novel Metric for Directed Fuzzing with Large Language Modelscited by 2
- 2026Learning to Generate Secure Code via Token-Level Rewardscited by 2
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularitiescited by 1
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Modelscited by 1
- 2024Ocassionally Secure: A Comparative Analysis of Code Generation Assistantscited by 0
- 2026Learning to Generate Secure Code via Token-Level Rewards26 Feb 2026
- 2025Attention Distance: A Novel Metric for Directed Fuzzing with Large Language Models19 Dec 2025
- 2025LLM-CSEC: Empirical Evaluation of Security in C/C++ Code Generated by Large Language Models24 Nov 2025
- 2025RefleXGen:The unexamined code is not worth using27 Oct 2025
- 2025Can You Really Trust Code Copilots? Evaluating Large Language Models from a Code Security Perspective15 May 2025
- 2025Rethinking the Evaluation of Secure Code Generation18 Mar 2025
- 2024Automatic Detection of LLM-Generated Code: A Comparative Case Study of Contemporary Models Across Function and Class Granularities2 Sep 2024
- 2024Securing Large Language Models: Threats, Vulnerabilities and Responsible Practices19 Mar 2024
- 2024Ocassionally Secure: A Comparative Analysis of Code Generation Assistants1 Feb 2024