Prompting Techniques for Secure Code Generation: A Systematic Investigation
Not on the map. Why?
Abstract (arXiv)
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 are evaluated on GPT-3, GPT-3.5, and GPT-4 models for secure code generation. For this, we used an existing dataset consisting of 150 NL security-relevant code-generation prompts. RESULTS: Our work (i) classifies potential prompting techniques for code generation (ii) adapts and evaluates a subset of the identified techniques for secure code generation tasks and (iii) observes a reduction in security weaknesses across the tested LLMs, especially after using an existing technique called Recursive Criticism and Improvement (RCI), contributing valuable insights to the ongoing discourse on LLM-generated code security.
Key facts. Cited by 34 papers in the map (data through 14 Oct 2026). Builds on 75 of its 116 references that are in the map. First posted on arXiv 9 Jul 2024.
Builds on
75 of 116 references.
References · 75
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2021Training Verifiers to Solve Math Word Problemscited by 10,109
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,371
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2022Constitutional AI: Harmlessness from AI Feedbackcited by 3,050
- 2017TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehensioncited by 2,955
38 more
- 2019PIQA: Reasoning about Physical Commonsense in Natural Languagecited by 2,883
- 2022Do As I Can, Not As I Say: Grounding Language in Robotic Affordancescited by 2,348
- 2015Character-level Convolutional Networks for Text Classificationcited by 2,330
- 2018Can a Suit of Armor Conduct Electricity? A New Dataset for Open Book Question Answeringcited by 2,164
- 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,998
- 2018CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledgecited by 1,822
- 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
- 2019SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systemscited by 1,729
- 2018Know What You Don't Know: Unanswerable Questions for SQuADcited by 1,554
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,045
- 2016The LAMBADA dataset: Word prediction requiring a broad discourse contextcited by 992
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2019DROP: A Reading Comprehension Benchmark Requiring Discrete Reasoning Over Paragraphscited by 903
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2017RACE: Large-scale ReAding Comprehension Dataset From Examinationscited by 861
- 2019Adversarial NLI: A New Benchmark for Natural Language Understandingcited by 807
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
- 2021Did Aristotle Use a Laptop? A Question Answering Benchmark with Implicit Reasoning Strategiescited by 743
- 2022GPT-NeoX-20B: An Open-Source Autoregressive Language Modelcited by 713
- 2018CoQA: A Conversational Question Answering Challengecited by 683
- 2017Program Induction by Rationale Generation : Learning to Solve and Explain Algebraic Word Problemscited by 650
- 2023A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPTcited by 619
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
- 2021Prompt Programming for Large Language Models: Beyond the Few-Shot Paradigmcited by 606
- 2022Towards Reasoning in Large Language Models: A Surveycited by 596
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2022Complexity-Based Prompting for Multi-Step Reasoningcited by 388
- 2018QuAC : Question Answering in Contextcited by 381
- 2022Self-critiquing models for assisting human evaluatorscited by 380
- 2023Language Models can Solve Computer Taskscited by 372
- 2021Unified Pre-training for Program Understanding and Generationcited by 366
- 2022RLPrompt: Optimizing Discrete Text Prompts with Reinforcement Learningcited by 366
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2016Solving General Arithmetic Word Problemscited by 360
- 2022Black-Box Tuning for Language-Model-as-a-Servicecited by 256
50 most cited of 75 All 75 (JSON)
Built on by
Citing papers per year: 2024: 7; 2025: 9; 2026: 18.
34 papers.
Sort:
By area:
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injectioncited by 16
- 2024A Study on Prompt Injection Attack Against LLM-Integrated Mobile Robotic Systemscited by 15
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 13
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Modelscited by 12
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generationcited by 8
- 2024Think Thrice Before You Act: Progressive Thought Refinement in Large Language Modelscited by 7
- 2024Understanding the Fundamental Design Decisions of Retrieval-Augmented Generation Systemscited by 7
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Modelcited by 6
- 2024ChatGPT's Potential in Cryptography Misuse Detection: A Comparative Analysis with Static Analysis Toolscited by 4
- 2024The Prompt Canvas: A Literature-Based Practitioner Guide for Creating Effective Prompts in Large Language Modelscited by 4
22 more
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
- 2026Enhancing Reliability in LLM-Based Secure Code Generationcited by 2
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learningcited by 1
- 2025PD3F: A Pluggable and Dynamic DoS-Defense Framework Against Resource Consumption Attacks Targeting Large Language Modelscited by 1
- 2026Surgical Repair of Insecure Code Generation in LLMscited by 1
- 2026Constrained Code Generation with Discrete Diffusioncited by 1
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methodscited by 1
- 2026The Invisible Lottery: How Subtle Cues Steer Algorithm Choice in LLM Code Generationcited by 1
- 2024Selection of Prompt Engineering Techniques for Code Generation through Predicting Code Complexitycited by 0
- 2024Test-driven Software Experimentation with LASSO: an LLM Prompt Benchmarking Examplecited by 0
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanismscited by 0
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Developmentcited by 0
- 2026A Tertiary Review of Large Language Model-Based Code Generating Tasks: Trends, Challenges, and Future Directionscited by 0
- 2026Can Open-Source LLM Agents Replace Static Application Security Testing Tools? An Empirical Assessmentcited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026Prompt Coach: An Empirical Evaluation of an Agentic Tutor for Learning Prompt Engineering in Software Developmentcited by 0
- 2026The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Repromptingcited by 0
- 2026Do Influence Tactics Matter? Investigating Prompt Framing Effects in LLM Code Generationcited by 0
- 2026Vibe Coding and Web Application Security: A Twin-Prompt Studycited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaborationcited by 0
- 2026A Study of the Reliability of Agentic AI-Generated Programscited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generationcited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generation10 Oct 2026
- 2026A Study of the Reliability of Agentic AI-Generated Programs16 Sep 2026
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026Vibe Coding and Web Application Security: A Twin-Prompt Study21 Aug 2026
- 2026Do Influence Tactics Matter? Investigating Prompt Framing Effects in LLM Code Generation11 Aug 2026
- 2026The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting26 Jul 2026
- 2026Prompt Coach: An Empirical Evaluation of an Agentic Tutor for Learning Prompt Engineering in Software Development7 Jul 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026Can Open-Source LLM Agents Replace Static Application Security Testing Tools? An Empirical Assessment10 Jun 2026
- 2026The Invisible Lottery: How Subtle Cues Steer Algorithm Choice in LLM Code Generation2 Jun 2026
- 2026A Tertiary Review of Large Language Model-Based Code Generating Tasks: Trends, Challenges, and Future Directions25 May 2026
- 2026Enhancing Reliability in LLM-Based Secure Code Generation22 May 2026
22 more
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods22 May 2026
- 2026Constrained Code Generation with Discrete Diffusion16 May 2026
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2026Surgical Repair of Insecure Code Generation in LLMs17 Apr 2026
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms11 Mar 2026
- 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model7 Feb 2026
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation30 Oct 2025
- 2025RESCUE: Retrieval Augmented Secure Code Generation21 Oct 2025
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarios26 Sep 2025
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows8 Jun 2025
- 2025PD3F: A Pluggable and Dynamic DoS-Defense Framework Against Resource Consumption Attacks Targeting Large Language Models24 May 2025
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection23 Apr 2025
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learning12 Mar 2025
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applications3 Mar 2025
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Models9 Feb 2025
- 2024The Prompt Canvas: A Literature-Based Practitioner Guide for Creating Effective Prompts in Large Language Models6 Dec 2024
- 2024Understanding the Fundamental Design Decisions of Retrieval-Augmented Generation Systems29 Nov 2024
- 2024Think Thrice Before You Act: Progressive Thought Refinement in Large Language Models17 Oct 2024
- 2024Test-driven Software Experimentation with LASSO: an LLM Prompt Benchmarking Example11 Oct 2024
- 2024Selection of Prompt Engineering Techniques for Code Generation through Predicting Code Complexity24 Sep 2024
- 2024ChatGPT's Potential in Cryptography Misuse Detection: A Comparative Analysis with Static Analysis Tools10 Sep 2024
- 2024A Study on Prompt Injection Attack Against LLM-Integrated Mobile Robotic Systems7 Aug 2024
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 13
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
- 2026Can Open-Source LLM Agents Replace Static Application Security Testing Tools? An Empirical Assessmentcited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026Prompt Coach: An Empirical Evaluation of an Agentic Tutor for Learning Prompt Engineering in Software Developmentcited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaborationcited by 0
- 2026A Study of the Reliability of Agentic AI-Generated Programscited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generationcited by 0
- 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generation10 Oct 2026
- 2026A Study of the Reliability of Agentic AI-Generated Programs16 Sep 2026
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026Prompt Coach: An Empirical Evaluation of an Agentic Tutor for Learning Prompt Engineering in Software Development7 Jul 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026Can Open-Source LLM Agents Replace Static Application Security Testing Tools? An Empirical Assessment10 Jun 2026
- 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarios26 Sep 2025
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows8 Jun 2025
- 2026Constrained Code Generation with Discrete Diffusioncited by 1
- 2026Constrained Code Generation with Discrete Diffusion16 May 2026
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generationcited by 8
- 2024ChatGPT's Potential in Cryptography Misuse Detection: A Comparative Analysis with Static Analysis Toolscited by 4
- 2024The Prompt Canvas: A Literature-Based Practitioner Guide for Creating Effective Prompts in Large Language Modelscited by 4
- 2026Enhancing Reliability in LLM-Based Secure Code Generationcited by 2
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learningcited by 1
- 2025PD3F: A Pluggable and Dynamic DoS-Defense Framework Against Resource Consumption Attacks Targeting Large Language Modelscited by 1
- 2026Surgical Repair of Insecure Code Generation in LLMscited by 1
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methodscited by 1
- 2026The Invisible Lottery: How Subtle Cues Steer Algorithm Choice in LLM Code Generationcited by 1
- 2024Selection of Prompt Engineering Techniques for Code Generation through Predicting Code Complexitycited by 0
- 2024Test-driven Software Experimentation with LASSO: an LLM Prompt Benchmarking Examplecited by 0
12 most cited of 18 All 18 (JSON)
- 2026Vibe Coding and Web Application Security: A Twin-Prompt Study21 Aug 2026
- 2026Do Influence Tactics Matter? Investigating Prompt Framing Effects in LLM Code Generation11 Aug 2026
- 2026The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting26 Jul 2026
- 2026The Invisible Lottery: How Subtle Cues Steer Algorithm Choice in LLM Code Generation2 Jun 2026
- 2026A Tertiary Review of Large Language Model-Based Code Generating Tasks: Trends, Challenges, and Future Directions25 May 2026
- 2026Enhancing Reliability in LLM-Based Secure Code Generation22 May 2026
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods22 May 2026
- 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Development20 Apr 2026
- 2026Surgical Repair of Insecure Code Generation in LLMs17 Apr 2026
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms11 Mar 2026
- 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generation30 Oct 2025
- 2025PD3F: A Pluggable and Dynamic DoS-Defense Framework Against Resource Consumption Attacks Targeting Large Language Models24 May 2025
12 newest of 18 All 18 (JSON)