The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting
Not on the map. Why?
Abstract (arXiv)
Large Language Models (LLMs) are increasingly integrated into software development workflows, yet their ability to autonomously generate secure authentication code remains uncertain. This paper evaluates the security architecture of authentication systems generated by five prominent AI coding assistants through a bi-modal assessment framework combining static code analysis and dynamic penetration testing, mapped to NIST SP 800-63B guidelines. The study examines model behavior across four prompting strategies Basic, Secure, NIST-Based, and Reprompting to reflect varying levels of developer guidance. Empirical results demonstrate that code generated from functional or generically secure prompts consistently omits critical protections, particularly concerning brute-force resistance, session management, and robust password handling. While providing explicit, single-shot NIST context significantly improves compliance, the findings reveal that this remains structurally inadequate. Instead, iterative Reprompting: forcing models into a contextual self-auditing loop is strictly required to achieve a comprehensive, defense-in-depth security architecture. Ultimately, this study proves that current AI coding assistants do not produce secure-by-default applications, dictating that enterprise deployments must transition from single-shot prompt engineering to continuous, standards-driven verification pipelines.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 16 of its 24 references that are in the map. First posted on arXiv 26 Jul 2026.
Builds on
16 of 24 references.
References · 16
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2023Security Weaknesses of Copilot-Generated Code in GitHub Projects: An Empirical Studycited by 36
- 2024AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testingcited by 34
- 2024Prompting Techniques for Secure Code Generation: A Systematic Investigationcited by 33
- 2024PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)cited by 17
- 2024Security Attacks on LLM-based Code Completion Toolscited by 15
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Modelscited by 12
- 2025Rethinking the Evaluation of Secure Code Generationcited by 10
- 2025Security Degradation in Iterative AI Code Generation -- A Systematic Analysis of the Paradoxcited by 10
- 2025Do LLMs Consider Security? An Empirical Study on Responses to Programming Questionscited by 8
- 2025The Hidden Risks of LLM-Generated Web Application Code: A Security-Centric Evaluation of Code Generation Capabilities in Large Language Modelscited by 7
4 more
- 2025Can You Really Trust Code Copilots? Evaluating Large Language Models from a Code Security Perspectivecited by 6
- 2024From Solitary Directives to Interactive Encouragement! LLM Secure Code Generation by Natural Language Promptingcited by 3
- 2025Secure coding for web applications: Frameworks, challenges, and the role of LLMscited by 3
- 2025Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practicescited by 1
Built on by
Not cited yet.