From Solitary Directives to Interactive Encouragement! LLM Secure Code Generation by Natural Language Prompting
Shigang Liu, Bushra Sabir, Seung Ick Jang, Yuval Kansal, Yansong Gao,, Kristen Moore, Alsharif Abuadbba, and Surya Nepal

TL;DR
This paper introduces SecCode, an interactive prompting framework that significantly improves the security of code generated by large language models using only natural language prompts, through iterative vulnerability detection and fixing.
Contribution
It presents the first framework for secure code generation solely with natural language prompts, employing an innovative interactive encouragement prompting technique and multiple iterative stages.
Findings
SecCode achieves over 76% vulnerability fix success after 5 iterations.
SecCode outperforms baseline methods in generating secure code.
High vulnerability correction rates demonstrate effectiveness across multiple LLMs.
Abstract
Large Language Models (LLMs) have shown remarkable potential in code generation, making them increasingly important in the field. However, the security issues of generated code have not been fully addressed, and the usability of LLMs in code generation still requires further exploration. This work introduces SecCode, a framework that leverages an innovative interactive encouragement prompting (EP) technique for secure code generation with \textit{only NL} prompts. This approach ensures that the prompts can be easily shared and understood by general users. SecCode functions through three stages: 1) Code Generation using NL Prompts; 2) Code Vulnerability Detection and Fixing, utilising our proposed encouragement prompting; 3) Vulnerability Cross-Checking and Code Security Refinement. These stages are executed in multiple interactive iterations to progressively enhance security. By using…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsArtificial Intelligence in Law · Law, AI, and Intellectual Property
