Skip to main navigation Skip to search Skip to main content

Security Weaknesses of Code Generated by Generative AI

  • Saurabh Suresh
  • , Chuadhry Mujeeb Ahmed
  • , Naveed ul Hassan
  • , Mohamed Amine Ferrag
  • , Merouane Abdelkader Debbah
    • Newcastle University
    • Lahore University of Management Sciences

    Research output: Chapter in Book/Report/Conference proceedingChapterpeer-review

    Abstract

    In this work, we investigate the security vulnerabilities in code snippets generated by Generative AI, specifically analyzing six diverse applications. The study aims to uncover potential risks and weaknesses that may need to be noticed by beginner programmers who utilize such AI-driven tools. The selected programs are examined for vulnerabilities like hardcoded credentials, insecure file uploads, code injection, and other related flaws. A comparative analysis was conducted between two well-known generative models, OpenAI’s ChatGPT and Google’s Bard. The findings reveal critical insights into the nature of common vulnerabilities and the necessity for improved security practices. Recommendations are made to enhance the generated code’s robustness and equip beginner programmers with knowledge and tools to mitigate potential risks. The research contributes new knowledge to the field of AI-generated code security and emphasizes the importance of security education and awareness among novice developers who are dependent on generative AI for code generation.

    Original languageBritish English
    Title of host publicationAdversarial Example Detection and Mitigation Using Machine Learning
    PublisherSpringer Nature
    Pages79-98
    Number of pages20
    ISBN (Electronic)9783031994470
    ISBN (Print)9783031994463
    DOIs
    StatePublished - 1 Jan 2026

    Keywords

    • Code security
    • Generative AI

    Fingerprint

    Dive into the research topics of 'Security Weaknesses of Code Generated by Generative AI'. Together they form a unique fingerprint.

    Cite this