Instruction Tuning for Secure Code Generation
Not on the map. Why?
Abstract (arXiv)
Modern language models (LMs) have gained widespread acceptance in everyday and professional contexts, particularly in programming. An essential procedure enabling this adoption is instruction tuning, which substantially enhances LMs' practical utility by training them to follow user instructions and human preferences. However, existing instruction tuning schemes overlook a crucial aspect: the security of generated code. As a result, even the state-of-the-art instruction-tuned LMs frequently produce unsafe code, posing significant security risks. In this work, we introduce SafeCoder to address this gap. SafeCoder performs security-centric fine-tuning using a diverse and high-quality dataset that we collected using an automated pipeline. We integrate the security fine-tuning with standard instruction tuning, to facilitate a joint optimization of both security and utility. Despite its simplicity, we show that SafeCoder is effective across a variety of popular LMs and datasets. It is able to drastically improve security (by about 30%), while preserving utility.
Key facts. Cited by 63 papers in the map (data through 7 Oct 2026). Builds on 29 of its 43 references that are in the map. First posted on arXiv 14 Feb 2024.
Builds on
29 of 43 references.
References · 29
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023GPT-4 Technical Reportcited by 18,132
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,878
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Mistral 7Bcited by 3,065
- 2022Scaling Instruction-Finetuned Language Modelscited by 2,997
- 2022Constitutional AI: Harmlessness from AI Feedbackcited by 2,950
- 2021TruthfulQA: Measuring How Models Mimic Human Falsehoodscited by 2,919
17 more
- 2022Self-Instruct: Aligning Language Models with Self-Generated Instructionscited by 2,674
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2021Multitask Prompted Training Enables Zero-Shot Task Generalizationcited by 1,462
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023StarCoder: may the source be with you!cited by 790
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2019Neural Text Generation with Unlikelihood Trainingcited by 489
- 2023LMSYS-Chat-1M: A Large-Scale Real-World LLM Conversation Datasetcited by 449
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
- 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2023How Secure is Code Generated by ChatGPT?cited by 77
- 2023Data Quality for Software Vulnerability Datasetscited by 49
- 2022VUDENC: Vulnerability Detection with Deep Learning on a Natural Codebase for Pythoncited by 17
- 2020SourceFinder: Finding Malware Source-Code from Publicly Available Repositoriescited by 14
Built on by
Citing papers per year: 2024: 13; 2025: 26; 2026: 24.
63 papers.
Sort:
By area:
- 2024When LLMs Meet Cybersecurity: A Systematic Literature Reviewcited by 70
- 2024Exploiting LLM Quantizationcited by 61
- 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 55
- 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 38
- 2026SWE-chat: Coding Agent Interactions From Real Users in the Wildcited by 36
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 26
- 2025AI Agentic Programming: A Survey of Techniques, Challenges, and Opportunitiescited by 26
- 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 25
- 2024ProSec: Fortifying Code LLMs with Proactive Security Alignmentcited by 24
- 2025PurpCode: Reasoning for Safer Code Generationcited by 17
- 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Datacited by 14
38 more
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 13
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2025Co-PatcheR: Collaborative Software Patching with Component(s)-specific Small Reasoning Modelscited by 12
- 2025Training Language Models to Generate Quality Code with Program Analysis Feedbackcited by 11
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 11
- 2025Rethinking the Evaluation of Secure Code Generationcited by 10
- 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferencescited by 10
- 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Securitycited by 9
- 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulnesscited by 7
- 2025The Art of Repair: Optimizing Iterative Program Repair with Instruction-Tuned Modelscited by 7
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2024Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysiscited by 6
- 2025CoQuIR: A Comprehensive Benchmark for Code Quality-Aware Information Retrievalcited by 6
- 2024SeCodePLT: A Unified Platform for Evaluating the Security of Code GenAIcited by 4
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
- 2025Less Data, More Security: Advancing Cybersecurity LLMs Specialization via Resource-Efficient Domain-Adaptive Continuous Pre-training with Minimal Tokenscited by 4
- 2025A Mixture of Linear Corrections Generates Secure Codecited by 4
- 2025RefleXGen:The unexamined code is not worth usingcited by 4
- 2025AutoBaxBuilder: Bootstrapping Code Security Benchmarkingcited by 4
- 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Modelcited by 4
- 2024Generative transformations and patterns in LLM-native approaches for software verification and falsificationcited by 2
- 2026Learning to Generate Secure Code via Token-Level Rewardscited by 2
- 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregationcited by 2
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learningcited by 1
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practicescited by 1
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agentscited by 1
- 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Pythoncited by 1
- 2026Autoregressive, Yet Revisable: In Decoding Revision for Secure Code Generationcited by 1
- 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versionscited by 1
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
- 2025QoS-Efficient Serving of Multiple Mixture-of-Expert LLMs Using Partial Runtime Reconfigurationcited by 0
- 2025Amazon Nova AI Challenge -- Trusted AI: Advancing secure, AI-assisted software developmentcited by 0
- 2025TypePilot: Leveraging the Scala Type System for Secure LLM-generated Codecited by 0
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 0
- 2025When Forgetting Builds Reliability: LLM Unlearning for Reliable Hardware Code Generationcited by 0
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanismscited by 0
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Codecited by 0
- 2026Adversarial Arena: Crowdsourcing Data Generation through Interactive Competitioncited by 0
50 most cited of 63 All 63 (JSON)
- 2026SecureVibe: Making Vibe Coding More Secure29 Sep 2026
- 2026JevVibe: Efficient Classification-Guided Secure Code Generation28 Sep 2026
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation2 Sep 2026
- 2026Interpreting and Steering for Safe and Correct Code Generation30 Aug 2026
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026Do Uncertainty Signals Help? A Systematic Study of Uncertainty-Aware Decoding with Rollback Mechanisms31 Jul 2026
- 2026From Evaluation to Optimisation: Hierarchy-Aware Training Signals for CWE Prediction in Python23 Jul 2026
- 2026Leveraging Instruction Tuning and Merging for Reasoning Model Adaptation16 Jul 2026
- 2026Functional and Secure Code Generation with Task Vectors8 Jul 2026
- 2026Helpful or Harmful? Evaluating LLM-Assisted Vulnerability Patching via a Human Study24 Jun 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026Activating Latent Security Knowledge through LLM-Guided Risk Analysis for Secure Code Generation15 Jun 2026
38 more
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMs2 Jun 2026
- 2026SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimization8 May 2026
- 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versions7 May 2026
- 2026SWE-chat: Coding Agent Interactions From Real Users in the Wild22 Apr 2026
- 2026Adversarial Arena: Crowdsourcing Data Generation through Interactive Competition20 Apr 2026
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Code14 Apr 2026
- 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregation10 Apr 2026
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms11 Mar 2026
- 2026Learning to Generate Secure Code via Token-Level Rewards26 Feb 2026
- 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model7 Feb 2026
- 2026Autoregressive, Yet Revisable: In Decoding Revision for Secure Code Generation1 Feb 2026
- 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Python4 Jan 2026
- 2025AutoBaxBuilder: Bootstrapping Code Security Benchmarking24 Dec 2025
- 2025When Forgetting Builds Reliability: LLM Unlearning for Reliable Hardware Code Generation5 Dec 2025
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents24 Nov 2025
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Prompts19 Nov 2025
- 2025RefleXGen:The unexamined code is not worth using27 Oct 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025TypePilot: Leveraging the Scala Type System for Secure LLM-generated Code13 Oct 2025
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices8 Oct 2025
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarios26 Sep 2025
- 2025AI Agentic Programming: A Survey of Techniques, Challenges, and Opportunities15 Aug 2025
- 2025Amazon Nova AI Challenge -- Trusted AI: Advancing secure, AI-assisted software development13 Aug 2025
- 2025PurpCode: Reasoning for Safer Code Generation25 Jul 2025
- 2025A Mixture of Linear Corrections Generates Secure Code13 Jul 2025
- 2025Less Data, More Security: Advancing Cybersecurity LLMs Specialization via Resource-Efficient Domain-Adaptive Continuous Pre-training with Minimal Tokens30 Jun 2025
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows8 Jun 2025
- 2025CoQuIR: A Comprehensive Benchmark for Code Quality-Aware Information Retrieval31 May 2025
- 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferences31 May 2025
- 2025Training Language Models to Generate Quality Code with Program Analysis Feedback28 May 2025
- 2025Co-PatcheR: Collaborative Software Patching with Component(s)-specific Small Reasoning Models25 May 2025
- 2025QoS-Efficient Serving of Multiple Mixture-of-Expert LLMs Using Partial Runtime Reconfiguration10 May 2025
- 2025The Art of Repair: Optimizing Iterative Program Repair with Instruction-Tuned Models5 May 2025
- 2025Rethinking the Evaluation of Secure Code Generation18 Mar 2025
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learning12 Mar 2025
- 2025BaxBench: Can LLMs Generate Correct and Secure Backends?17 Feb 2025
- 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generation14 Jan 2025
50 newest of 63 All 63 (JSON)
- 2026SWE-chat: Coding Agent Interactions From Real Users in the Wildcited by 36
- 2025AI Agentic Programming: A Survey of Techniques, Challenges, and Opportunitiescited by 26
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 11
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agentscited by 1
- 2026SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimizationcited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaborationcited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026SecureForge: Finding and Preventing Vulnerabilities in LLM-Generated Code via Prompt Optimization8 May 2026
- 2026SWE-chat: Coding Agent Interactions From Real Users in the Wild22 Apr 2026
- 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents24 Nov 2025
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarios26 Sep 2025
- 2025AI Agentic Programming: A Survey of Techniques, Challenges, and Opportunities15 Aug 2025
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows8 Jun 2025
- 2025PurpCode: Reasoning for Safer Code Generationcited by 17
- 2025Co-PatcheR: Collaborative Software Patching with Component(s)-specific Small Reasoning Modelscited by 12
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practicescited by 1
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Codecited by 0
- 2026Leveraging Instruction Tuning and Merging for Reasoning Model Adaptationcited by 0
- 2026Leveraging Instruction Tuning and Merging for Reasoning Model Adaptation16 Jul 2026
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Code14 Apr 2026
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices8 Oct 2025
- 2025PurpCode: Reasoning for Safer Code Generation25 Jul 2025
- 2025Co-PatcheR: Collaborative Software Patching with Component(s)-specific Small Reasoning Models25 May 2025
- 2024When LLMs Meet Cybersecurity: A Systematic Literature Reviewcited by 70
- 2024Exploiting LLM Quantizationcited by 61
- 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 55
- 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 38
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 26
- 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 25
- 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Datacited by 14
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 13
- 2025Training Language Models to Generate Quality Code with Program Analysis Feedbackcited by 11
- 2025Rethinking the Evaluation of Secure Code Generationcited by 10
- 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Securitycited by 9
12 most cited of 39 All 39 (JSON)
- 2026SecureVibe: Making Vibe Coding More Secure29 Sep 2026
- 2026JevVibe: Efficient Classification-Guided Secure Code Generation28 Sep 2026
- 2026Interpreting and Steering for Safe and Correct Code Generation30 Aug 2026
- 2026Do Uncertainty Signals Help? A Systematic Study of Uncertainty-Aware Decoding with Rollback Mechanisms31 Jul 2026
- 2026From Evaluation to Optimisation: Hierarchy-Aware Training Signals for CWE Prediction in Python23 Jul 2026
- 2026Functional and Secure Code Generation with Task Vectors8 Jul 2026
- 2026Helpful or Harmful? Evaluating LLM-Assisted Vulnerability Patching via a Human Study24 Jun 2026
- 2026Activating Latent Security Knowledge through LLM-Guided Risk Analysis for Secure Code Generation15 Jun 2026
- 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versions7 May 2026
- 2026Adversarial Arena: Crowdsourcing Data Generation through Interactive Competition20 Apr 2026
- 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregation10 Apr 2026
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms11 Mar 2026
12 newest of 39 All 39 (JSON)