HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Data
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have shown great potential for automatic code generation and form the basis for various tools such as GitHub Copilot. However, recent studies highlight that many LLM-generated code contains serious security vulnerabilities. While previous work tries to address this by training models that generate secure code, these attempts remain constrained by limited access to training data and labor-intensive data preparation. In this paper, we introduce HexaCoder, a novel approach to enhance the ability of LLMs to generate secure codes by automatically synthesizing secure codes, which reduces the effort of finding suitable training data. HexaCoder comprises two key components: an oracle-guided data synthesis pipeline and a two-step process for secure code generation. The data synthesis pipeline generates pairs of vulnerable and fixed codes for specific Common Weakness Enumeration (CWE) types by utilizing a state-of-the-art LLM for repairing vulnerable code. A security oracle identifies vulnerabilities, and a state-of-the-art LLM repairs them by extending and/or editing the codes, creating data pairs for fine-tuning using the Low-Rank Adaptation (LoRA) method. Each example of our fine-tuning dataset includes the necessary security-related libraries and code that form the basis of our novel two-step generation approach. This allows the model to integrate security-relevant libraries before generating the main code, significantly reducing the number of generated vulnerable codes by up to 85% compared to the baseline methods. We perform extensive evaluations on three different benchmarks for four LLMs, demonstrating that HexaCoder not only improves the security of the generated code but also maintains a high level of functional correctness.
Key facts. Cited by 14 papers in the map (data through 7 Oct 2026). Builds on 39 of its 63 references that are in the map. First posted on arXiv 10 Sep 2024.
Builds on
39 of 63 references.
References · 39
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2024The Llama 3 Herd of Modelscited by 14,192
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2019Parameter-Efficient Transfer Learning for NLPcited by 4,195
- 2022Self-Instruct: Aligning Language Models with Self-Generated Instructionscited by 2,674
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2023WizardLM: Empowering large pre-trained language models to follow complex instructionscited by 1,116
- 2024DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Modelcited by 1,093
- 2022Scaling Laws for Reward Model Overoptimizationcited by 1,056
27 more
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023ChatGPT Outperforms Crowd-Workers for Text-Annotation Taskscited by 849
- 2023StarCoder: may the source be with you!cited by 790
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Modelscited by 724
- 2023WizardMath: Empowering Mathematical Reasoning for Large Language Models via Reinforced Evol-Instructcited by 618
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 325
- 2024LoRA Learns Less and Forgets Lesscited by 313
- 2024On LLMs-Driven Synthetic Data Generation, Curation, and Evaluation: A Surveycited by 240
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2022MultiPL-E: A Scalable and Extensible Approach to Benchmarking Neural Code Generationcited by 132
- 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
- 2024Best Practices and Lessons Learned on Synthetic Datacited by 104
- 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
- 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 52
- 2022Tuning Language Models as Training Data Generators for Augmentation-Enhanced Few-Shot Learningcited by 36
- 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 32
- 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answerscited by 12
- 2024A Survey of Data Synthesis Approachescited by 8
- 2022SimSCOOD: Systematic Analysis of Out-of-Distribution Generalization in Fine-tuned Source Code Modelscited by 5
Built on by
Citing papers per year: 2025: 7; 2026: 7.
14 papers.
Sort:
By area:
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugscited by 22
- 2025PurpCode: Reasoning for Safer Code Generationcited by 17
- 2025Co-PatcheR: Collaborative Software Patching with Component(s)-specific Small Reasoning Modelscited by 12
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 11
- 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferencescited by 10
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Modelcited by 4
- 2025Secure-Instruct: An Automated Pipeline for Synthesizing Instruction-Tuning Datasets Using LLMs for Secure Code Generationcited by 2
- 2026Learning to Generate Secure Code via Token-Level Rewardscited by 2
- 2026SecPI: Secure Code Generation with Reasoning Models via Security Reasoning Internalizationcited by 1
- 2026LLMs + Security = Troublecited by 0
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMscited by 0
2 more
- 2026JevVibe: Efficient Classification-Guided Secure Code Generation28 Sep 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMs2 Jun 2026
- 2026SecPI: Secure Code Generation with Reasoning Models via Security Reasoning Internalization4 Apr 2026
- 2026Learning to Generate Secure Code via Token-Level Rewards26 Feb 2026
- 2026LLMs + Security = Trouble9 Feb 2026
- 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model7 Feb 2026
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025Secure-Instruct: An Automated Pipeline for Synthesizing Instruction-Tuning Datasets Using LLMs for Secure Code Generation8 Oct 2025
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarios26 Sep 2025
- 2025PurpCode: Reasoning for Safer Code Generation25 Jul 2025
- 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferences31 May 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugscited by 22
- 2026Learning to Generate Secure Code via Token-Level Rewardscited by 2
- 2026LLMs + Security = Troublecited by 0
- 2026JevVibe: Efficient Classification-Guided Secure Code Generationcited by 0
- 2026JevVibe: Efficient Classification-Guided Secure Code Generation28 Sep 2026
- 2026Learning to Generate Secure Code via Token-Level Rewards26 Feb 2026
- 2026LLMs + Security = Trouble9 Feb 2026
- 2025SWE-Synth: Synthesizing Verifiable Bug-Fix Data to Enable Large Language Models in Resolving Real-World Bugs20 Apr 2025
Similar, not cited
Close in wording, no citation either way
- 2026Improving LLM-Assisted Secure Code Generation through Retrieval-Augmented-Generation and Multi-Tool Feedback
- 2025Rethinking the Evaluation of Secure Code Generation
- 2025SOSecure: Safer Code Generation with RAG and StackOverflow Discussions
- 2026RealSec-bench: A Benchmark for Evaluating Secure Code Generation in Real-World Repositories
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices
- 2026Enhancing Reliability in LLM-Based Secure Code Generation
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
- 2026Persistent Human Feedback, LLMs, and Static Analyzers for Secure Code Generation and Vulnerability Detection