mlsanityData to 7 Oct 2026

HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Data

arXiv 2409.06446 ↗First posted 10 Sep 2024cs.CR cs.AI cs.CLcited by 14

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

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  2. 2020Language Models are Few-Shot Learnerscited by 32,199
  3. 2024The Llama 3 Herd of Modelscited by 14,192
  4. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  5. 2019Parameter-Efficient Transfer Learning for NLPcited by 4,195
  6. 2022Self-Instruct: Aligning Language Models with Self-Generated Instructionscited by 2,674
  7. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  8. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
  9. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  10. 2023WizardLM: Empowering large pre-trained language models to follow complex instructionscited by 1,116
  11. 2024DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Modelcited by 1,093
  12. 2022Scaling Laws for Reward Model Overoptimizationcited by 1,056
27 more
  1. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
  2. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  3. 2023ChatGPT Outperforms Crowd-Workers for Text-Annotation Taskscited by 849
  4. 2023StarCoder: may the source be with you!cited by 790
  5. 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
  6. 2023MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Modelscited by 724
  7. 2023WizardMath: Empowering Mathematical Reasoning for Large Language Models via Reinforced Evol-Instructcited by 618
  8. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
  9. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
  10. 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
  11. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
  12. 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 325
  13. 2024LoRA Learns Less and Forgets Lesscited by 313
  14. 2024On LLMs-Driven Synthetic Data Generation, Curation, and Evaluation: A Surveycited by 240
  15. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
  16. 2022MultiPL-E: A Scalable and Extensible Approach to Benchmarking Neural Code Generationcited by 132
  17. 2023Purple Llama CyberSecEval: A Secure Coding Benchmark for Language Modelscited by 130
  18. 2024Best Practices and Lessons Learned on Synthetic Datacited by 104
  19. 2023How Secure is Code Generated by ChatGPT?cited by 77
  20. 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 63
  21. 2024Instruction Tuning for Secure Code Generationcited by 63
  22. 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 52
  23. 2022Tuning Language Models as Training Data Generators for Augmentation-Enhanced Few-Shot Learningcited by 36
  24. 2023The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verificationcited by 32
  25. 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answerscited by 12
  26. 2024A Survey of Data Synthesis Approachescited by 8
  27. 2022SimSCOOD: Systematic Analysis of Out-of-Distribution Generalization in Fine-tuned Source Code Modelscited by 5

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 7; 2026: 7.

14 papers.

Sort:

By area:

Similar, not cited

Close in wording, no citation either way

  1. 2026Improving LLM-Assisted Secure Code Generation through Retrieval-Augmented-Generation and Multi-Tool Feedback
  2. 2025Rethinking the Evaluation of Secure Code Generation
  3. 2025SOSecure: Safer Code Generation with RAG and StackOverflow Discussions
  4. 2026RealSec-bench: A Benchmark for Evaluating Secure Code Generation in Real-World Repositories
  5. 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices
  6. 2026Enhancing Reliability in LLM-Based Secure Code Generation
  7. 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
  8. 2026Persistent Human Feedback, LLMs, and Static Analyzers for Secure Code Generation and Vulnerability Detection