mlsanityData to 7 Oct 2026

Instruction Tuning for Secure Code Generation

arXiv 2402.09497 ↗First posted 14 Feb 2024cs.CR cs.AI cs.LGcited by 63

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

  1. 2020Language Models are Few-Shot Learnerscited by 32,199
  2. 2023GPT-4 Technical Reportcited by 18,132
  3. 2022Training language models to follow instructions with human feedbackcited by 15,712
  4. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  6. 2020Measuring Massive Multitask Language Understandingcited by 7,768
  7. 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,878
  8. 2021Program Synthesis with Large Language Modelscited by 3,509
  9. 2023Mistral 7Bcited by 3,065
  10. 2022Scaling Instruction-Finetuned Language Modelscited by 2,997
  11. 2022Constitutional AI: Harmlessness from AI Feedbackcited by 2,950
  12. 2021TruthfulQA: Measuring How Models Mimic Human Falsehoodscited by 2,919
17 more
  1. 2022Self-Instruct: Aligning Language Models with Self-Generated Instructionscited by 2,674
  2. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  3. 2021Multitask Prompted Training Enables Zero-Shot Task Generalizationcited by 1,462
  4. 2022Competition-Level Code Generation with AlphaCodecited by 1,427
  5. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  6. 2023StarCoder: may the source be with you!cited by 790
  7. 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
  8. 2019Neural Text Generation with Unlikelihood Trainingcited by 489
  9. 2023LMSYS-Chat-1M: A Large-Scale Real-World LLM Conversation Datasetcited by 449
  10. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  11. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
  12. 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
  13. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
  14. 2023How Secure is Code Generated by ChatGPT?cited by 77
  15. 2023Data Quality for Software Vulnerability Datasetscited by 49
  16. 2022VUDENC: Vulnerability Detection with Deep Learning on a Natural Codebase for Pythoncited by 17
  17. 2020SourceFinder: Finding Malware Source-Code from Publicly Available Repositoriescited by 14

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 13; 2025: 26; 2026: 24.

63 papers.

Sort:

By area:

  1. 2024When LLMs Meet Cybersecurity: A Systematic Literature Reviewcited by 70
  2. 2024Exploiting LLM Quantizationcited by 61
  3. 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 55
  4. 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 38
  5. 2026SWE-chat: Coding Agent Interactions From Real Users in the Wildcited by 36
  6. 2024Constrained Decoding for Secure Code Generationcited by 35
  7. 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 26
  8. 2025AI Agentic Programming: A Survey of Techniques, Challenges, and Opportunitiescited by 26
  9. 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 25
  10. 2024ProSec: Fortifying Code LLMs with Proactive Security Alignmentcited by 24
  11. 2025PurpCode: Reasoning for Safer Code Generationcited by 17
  12. 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Datacited by 14
38 more
  1. 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 13
  2. 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
  3. 2025Co-PatcheR: Collaborative Software Patching with Component(s)-specific Small Reasoning Modelscited by 12
  4. 2025Training Language Models to Generate Quality Code with Program Analysis Feedbackcited by 11
  5. 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 11
  6. 2025Rethinking the Evaluation of Secure Code Generationcited by 10
  7. 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferencescited by 10
  8. 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Securitycited by 9
  9. 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulnesscited by 7
  10. 2025The Art of Repair: Optimizing Iterative Program Repair with Instruction-Tuned Modelscited by 7
  11. 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
  12. 2024Helping LLMs Improve Code Generation Using Feedback from Testing and Static Analysiscited by 6
  13. 2025CoQuIR: A Comprehensive Benchmark for Code Quality-Aware Information Retrievalcited by 6
  14. 2024SeCodePLT: A Unified Platform for Evaluating the Security of Code GenAIcited by 4
  15. 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
  16. 2025Less Data, More Security: Advancing Cybersecurity LLMs Specialization via Resource-Efficient Domain-Adaptive Continuous Pre-training with Minimal Tokenscited by 4
  17. 2025A Mixture of Linear Corrections Generates Secure Codecited by 4
  18. 2025RefleXGen:The unexamined code is not worth usingcited by 4
  19. 2025AutoBaxBuilder: Bootstrapping Code Security Benchmarkingcited by 4
  20. 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Modelcited by 4
  21. 2024Generative transformations and patterns in LLM-native approaches for software verification and falsificationcited by 2
  22. 2026Learning to Generate Secure Code via Token-Level Rewardscited by 2
  23. 2026DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregationcited by 2
  24. 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learningcited by 1
  25. 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practicescited by 1
  26. 2025DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agentscited by 1
  27. 2026Adaptive Hierarchical Evaluation of LLMs and SAST tools for CWE Prediction in Pythoncited by 1
  28. 2026Autoregressive, Yet Revisable: In Decoding Revision for Secure Code Generationcited by 1
  29. 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versionscited by 1
  30. 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
  31. 2025QoS-Efficient Serving of Multiple Mixture-of-Expert LLMs Using Partial Runtime Reconfigurationcited by 0
  32. 2025Amazon Nova AI Challenge -- Trusted AI: Advancing secure, AI-assisted software developmentcited by 0
  33. 2025TypePilot: Leveraging the Scala Type System for Secure LLM-generated Codecited by 0
  34. 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 0
  35. 2025When Forgetting Builds Reliability: LLM Unlearning for Reliable Hardware Code Generationcited by 0
  36. 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanismscited by 0
  37. 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Codecited by 0
  38. 2026Adversarial Arena: Crowdsourcing Data Generation through Interactive Competitioncited by 0

50 most cited of 63 All 63 (JSON)