Article Details
  • Published Online:
    February  2025
  • Product Name:
    The IUP Journal of Telecommunications
  • Product Type:
    Article
  • Product Code:
    IJTC040225
  • DOI:
    10.71329/IUPJTC/2025.17.1.75-95
  • Author Name:
    Kaushik Bar
  • Availability:
    YES
  • Subject/Domain:
    Engineering
  • Download Format:
    PDF
  • Pages:
    75-95
Volume 17, issue 1, February 2025
Secure Code Generation with LLMs: Risk Assessment and Mitigation Strategies
Abstract

Artificial intelligence (AI)-powered code generation tools, such as GitHub Copilot and OpenAI Codex, have revolutionized software development by automating code synthesis. However, concerns remain about the security of AI-generated code and its susceptibility to vulnerabilities. This study investigates whether AI-generated code can match or surpass human-written code in security, using a systematic evaluation framework. It analyzes AIgenerated code samples from state-of-the-art large language models (LLMs) and compares them against human-written code using static and dynamic security analysis tools. Additionally, adversarial testing was done to assess the robustness of LLMs against insecure code suggestions. The findings reveal that while AI-generated code can achieve functional correctness, it frequently introduces security vulnerabilities, such as injection flaws, insecure cryptographic practices, and improper input validation. To mitigate these risks, securityaware training methods and reinforcement learning techniques were explored to enhance the security of AI-generated code. The results highlight the key challenges in AI-driven software development and propose guidelines for integrating AI-assisted programming safely in real-world applications. This paper provides critical insights into the intersection of AI and cybersecurity, paving the way for more secured AI-driven code synthesis models.

Introduction

The rapid advancements in artificial intelligence (AI) have led to the emergence of large language models (LLMs) capable of generating high-quality sourced code. Tools such as OpenAI Codex (Chen et al., 2021), GitHub Copilot (GitHub Documentation, 2021) and CodeBERT (Feng et al., 2020) have significantly improved developer productivity by automating code synthesis, assisting in debugging, and suggesting optimized programming patterns. However, alongside these benefits, concerns about the security of AI-generated code have emerged. Unlike human developers, AI models lack an intrinsic understanding of secure coding practices and may introduce vulnerabilities that could be exploited in real-world applications (Pearce et al., 2021).