Skip to content

The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting

Jul 2026 · arXiv.org · Vol abs/2607.23710 · 0 citations · 24 references
Computer Science

TL;DR

It is proved 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.

Abstract

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.

View source

Similar papers

Open access Jul 2026

Can Language Models Generate Secure Terraform Code? A Security-Focused Benchmark Using Static Analysis

An empirical benchmark evaluating whether LLMs and SLMs can generate security-compliant AWS Terraform configurations suggests that prompt design is a critical factor, highlighting the need for a proper pipeline for developing and validating LLM-assisted secure IaC generation.

Francis Luis Santos Vargas, R. Mansilha, Diego Kreutz · 0 citations
Conference Aug 2026

Security Rule Embedding and Static-Analysis-Guided Repair for LLM-Based Intelligent Multimedia UI Code Generation

Large language models (LLMs) can rapidly generate web user interface (UI) code for intelligent multimedia applications, but the resulting code may contain avoidable client-side security weaknesses. This paper presents a security governance framework that combines pre-generation rule embedding, ESLint-based static analysis, structured feedback, and LLM-based repair. The framework was evaluated through a controlled pilot ablation study involving 10 multimedia UI requirements, five experimental groups, and three repeated runs, producing 150 requests. Across all groups, 132 outputs passed structural and task-specific validity checks, while 18 were recorded as generation failures rather than being treated as secure code. For the Full Framework, the matched-pair end-to-end static finding reduction rate was 95.16% (SD = 4.76 percentage points), the valid output rate was 90.00%, and the static-secure valid output rate was $\mathbf{7 6. 6 7 \%}(\mathbf{S D}=$ 11.55 percentage points). Holm-adjusted paired Wilcoxon tests showed statistically significant differences, with lower observed final finding counts for the Full Framework than for Vanilla, Prompt Only, and the variant without structured static feedback. Repair-enabled configurations increased the average runtime from approximately 51 s to 79 s. These results concern static candidate findings and output validity; they do not replace server-side controls or exhaustive dynamic security testing.

Shu-Ning Ping, Guangchi Liu · 0 citations
Jul 2026

The Language of Security: How Prompt Syntax Shapes Secure Code Generation in Open LLMs

This work systematically generates syntactic variants of security-relevant code generation prompts and evaluates their impact on code security across multiple open LLMs and programming languages, identifying prompt syntax as a concrete security control surface and providing actionable guidance for reducing vulnerability risk in LLM-assisted development.

Matteo Cicalese, Antonio Della Porta, Stefano Lambiase et al. · 0 citations
Review Open access Aug 2026

Defensive Reverse Engineering of LLM Applications: A Black-Box Framework for Security Risk Scoring and Mitigation

D-RELLM is presented, a defensive reverse-engineering framework for black-box security assessment of deployed LLM applications that treats the deployed application as a socio-technical system whose risk depends on instruction hierarchy, retrieval trust, authorization, tool agency, output handling, monitoring, and operational controls.

Bhavesh B. Prajapati, Bhavya Shah · 0 citations
Preprint Aug 2026

LMSM: LLM Security Framework Inspired by Linux Security Modules

This work presents Language Model Security Modules (LMSM), a security framework that adapts the separation behind Linux Security Modules (LSM) to LLM serving and gives advances in interpretability and model-internal analysis a common path to runtime enforcement.

XiuYu Zhang, Bo-Nan Ruan, Junfeng Fang et al. · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.