Research Article

SecureCoder: A Framework for Mitigating Vulnerabilities in Automated Code Generation Using Large Language Models

Ruichen Zhu*
Berkshire School, MA, USA

* Corresponding author: [email protected]

Abstract

In recent years, the proliferation of code generation models based on large language models such as GitHub Copilot and ChatGPT allows automated source code generation to meet the needs of developers and helps increase coding efficiency. However, a recent study revealed security concerns in generated code, leading the code to be vulnerable to attacks. My research introduces a framework aimed at mitigating the risk of code generation models generating vulnerable code specific to data leakage issues. The ranker is developed to use VUDENC, a deep learning model for vulnerability detection, along with CodeQL and Bandit, two Python code analyzers, to evaluate and rank generated code based on security metrics. By generating multiple code candidates and utilizing the ranker to select the most secure option, it ensures the generation of more secure code. The framework is evaluated on an aggregated SecurityEval and LLMSecEval dataset on relevant scenarios, which shows the framework has newfound advantages compared to the gpt3.5-turbo model. With its proven effectiveness, the framework could be expanding its applicability beyond data leakage issues, adapting to mitigate a comprehensive range of vulnerabilities.

Keywords: SecureCoder; LLM-based Code Generation; Data Leakage Mitigation; Vulnerability Detection Ranker; Cybersecurity
Published: December 19, 2024
DOI: 10.54254/2755-2721/2025.20425
Volume: ACE Vol.116
pp. 128-136
Download PDF

References

  1. Mario Rodriguez. Research: Quantifying GitHub Copilot’s impact on code quality. Oct. 10, 2023. url:github.blog/2023-10-10-research-quantifying-github-copilots-impact-on-code-quality/.
  2. OpenAI et al. GPT-4 Technical Report. 2023. arXiv: 2303.08774 [cs.CL].
  3. Vision Research Reports. Generative AI In Coding Market. https://www.visionresearchreports.com/generative-ai-in-coding-market/40820.2023.
  4. Thomas Dohmke. The economic impact of the AI-powered developer lifecycle and lessons from GitHub Copilot. url:https://github.blog/2023-06-27-the-economic-impact-of-the-ai-powered-developer-lifecycle-and-lessons-from-github-copilot/.
  5. Identity Theft Resource Center. 2023 Data Breach Report. https://www.idtheftcenter.org/wp-content/uploads/2024/01/ITRC_2023-Annual-Data- Breach-Report.pdf.
  6. Verizon. 2023 data breach investigations report. https://www.verizon.com/business/resources/T739/reports/2023-data-breach-investigations-report-dbir.pdf.2023.
  7. Hammond Pearce et al. Asleep at the Keyboard? Assessing the Security of GitHub Copilot’s Code Contributions. 2021. arXiv: 2108.09293 [cs.CR].
  8. Mohammed Latif Siddiq and Joanna C. S. Santos. “SecurityEval Dataset: Mining Vulnerability Examples to Evaluate Machine Learning-Based Code Generation Tech- niques” . In: Proceedings of the 1st International Workshop on Mining Software Repos- itories Applications for Privacy and Security (MSR4PS22) . 2022. doi:10.1145/3549035.3561184.
  9. Ansong Ni et al. “Lever: Learning to verify language-to-code generation with exe- cution” . In: Proceedings of the 40th International Conference on Machine Learning (ICML’23). 2023.
  10. Mark Chen et al. Evaluating Large Language Models Trained on Code. 2021. arXiv:2107.03374 [cs.LG].
  11. Mohammed Latif Siddiq, Beatrice Casey, and Joanna C. S. Santos. A Lightweight Framework for High-Quality Code Generation. 2023. arXiv: 2307.08220 [cs.SE].
  12. Catherine Tony et al. LLMSecEval: A Dataset of Natural Language Prompts for Security Evaluations. 2023. arXiv: 2303.09384 [cs.SE].
  13. Laura Wartschinski et al. “VUDENC: Vulnerability Detection with Deep Learning on a Natural Codebase for Python” . In: Information and Software Technology 144 (Apr. 2022), p. 106809. issn:0950-5849. doi:10.1016/j.infsof.2021.106809. url:http://dx.doi.org/10.1016/j.infsof.2021.106809.