Prompting Techniques for Secure Code Generation: A Systematic Investigation
Catherine Tony, Nicol\'as E. D\'iaz Ferreyra, Markus Mutas, Salem, Dhiff, Riccardo Scandariato

TL;DR
This paper systematically investigates how different prompting techniques influence the security of code generated by large language models, revealing that certain strategies, especially Recursive Criticism and Improvement, can reduce security vulnerabilities.
Contribution
It classifies prompting techniques for code generation, evaluates their impact on security, and demonstrates that specific methods improve the security of LLM-generated code.
Findings
Recursive Criticism and Improvement reduces security weaknesses
Prompting techniques significantly influence code security
Evaluation on GPT-3, GPT-3.5, and GPT-4 models
Abstract
Large Language Models (LLMs) are gaining momentum in software development with prompt-driven programming enabling developers to create code from natural language (NL) instructions. However, studies have questioned their ability to produce secure code and, thereby, the quality of prompt-generated software. Alongside, various prompting techniques that carefully tailor prompts have emerged to elicit optimal responses from LLMs. Still, the interplay between such prompting strategies and secure code generation remains under-explored and calls for further investigations. OBJECTIVE: In this study, we investigate the impact of different prompting techniques on the security of code generated from NL instructions by LLMs. METHOD: First we perform a systematic literature review to identify the existing prompting techniques that can be used for code generation tasks. A subset of these techniques…
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
TopicsCryptographic Implementations and Security · Advanced Malware Detection Techniques · Software Testing and Debugging Techniques
MethodsRefunds@Expedia|||How do I get a full refund from Expedia? · {Dispute@FaQ-s}How to file a dispute with Expedia? · 15 Ways to Contact How can i speak to someone at Delta Airlines · Linear Layer · Label Smoothing · Adam · Dropout · Dense Connections · Weight Decay · Absolute Position Encodings
