mlsanityData to 14 Oct 2026

Prompting Techniques for Secure Code Generation: A Systematic Investigation

arXiv 2407.07064 ↗First posted 9 Jul 2024cs.SE cs.AI cs.CRcited by 34

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

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  2. 2020Language Models are Few-Shot Learnerscited by 32,419
  3. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  4. 2021Training Verifiers to Solve Math Word Problemscited by 10,109
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  6. 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
  7. 2021Measuring Mathematical Problem Solving With the MATH Datasetcited by 5,371
  8. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
  9. 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
  10. 2021Program Synthesis with Large Language Modelscited by 3,637
  11. 2022Constitutional AI: Harmlessness from AI Feedbackcited by 3,050
  12. 2017TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehensioncited by 2,955
38 more
  1. 2019PIQA: Reasoning about Physical Commonsense in Natural Languagecited by 2,883
  2. 2022Do As I Can, Not As I Say: Grounding Language in Robotic Affordancescited by 2,348
  3. 2015Character-level Convolutional Networks for Text Classificationcited by 2,330
  4. 2018Can a Suit of Armor Conduct Electricity? A New Dataset for Open Book Question Answeringcited by 2,164
  5. 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,998
  6. 2018CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledgecited by 1,822
  7. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
  8. 2019SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systemscited by 1,729
  9. 2018Know What You Don't Know: Unanswerable Questions for SQuADcited by 1,554
  10. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
  11. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  12. 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,045
  13. 2016The LAMBADA dataset: Word prediction requiring a broad discourse contextcited by 992
  14. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  15. 2019DROP: A Reading Comprehension Benchmark Requiring Discrete Reasoning Over Paragraphscited by 903
  16. 2021Measuring Coding Challenge Competence With APPScited by 902
  17. 2017RACE: Large-scale ReAding Comprehension Dataset From Examinationscited by 861
  18. 2019Adversarial NLI: A New Benchmark for Natural Language Understandingcited by 807
  19. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
  20. 2021Did Aristotle Use a Laptop? A Question Answering Benchmark with Implicit Reasoning Strategiescited by 743
  21. 2022GPT-NeoX-20B: An Open-Source Autoregressive Language Modelcited by 713
  22. 2018CoQA: A Conversational Question Answering Challengecited by 683
  23. 2017Program Induction by Rationale Generation : Learning to Solve and Explain Algebraic Word Problemscited by 650
  24. 2023A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPTcited by 619
  25. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
  26. 2021Prompt Programming for Large Language Models: Beyond the Few-Shot Paradigmcited by 606
  27. 2022Towards Reasoning in Large Language Models: A Surveycited by 596
  28. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
  29. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
  30. 2022Complexity-Based Prompting for Multi-Step Reasoningcited by 388
  31. 2018QuAC : Question Answering in Contextcited by 381
  32. 2022Self-critiquing models for assisting human evaluatorscited by 380
  33. 2023Language Models can Solve Computer Taskscited by 372
  34. 2021Unified Pre-training for Program Understanding and Generationcited by 366
  35. 2022RLPrompt: Optimizing Discrete Text Prompts with Reinforcement Learningcited by 366
  36. 2022A Systematic Evaluation of Large Language Models of Codecited by 363
  37. 2016Solving General Arithmetic Word Problemscited by 360
  38. 2022Black-Box Tuning for Language-Model-as-a-Servicecited by 256

50 most cited of 75 All 75 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 7; 2025: 9; 2026: 18.

34 papers.

Sort:

By area:

  1. 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
  2. 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injectioncited by 16
  3. 2024A Study on Prompt Injection Attack Against LLM-Integrated Mobile Robotic Systemscited by 15
  4. 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarioscited by 13
  5. 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Modelscited by 12
  6. 2025Beyond Synthetic Benchmarks: Evaluating LLM Performance on Real-World Class-Level Code Generationcited by 8
  7. 2024Think Thrice Before You Act: Progressive Thought Refinement in Large Language Modelscited by 7
  8. 2024Understanding the Fundamental Design Decisions of Retrieval-Augmented Generation Systemscited by 7
  9. 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
  10. 2026Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Modelcited by 6
  11. 2024ChatGPT's Potential in Cryptography Misuse Detection: A Comparative Analysis with Static Analysis Toolscited by 4
  12. 2024The Prompt Canvas: A Literature-Based Practitioner Guide for Creating Effective Prompts in Large Language Modelscited by 4
22 more
  1. 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflowscited by 4
  2. 2026Enhancing Reliability in LLM-Based Secure Code Generationcited by 2
  3. 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learningcited by 1
  4. 2025PD3F: A Pluggable and Dynamic DoS-Defense Framework Against Resource Consumption Attacks Targeting Large Language Modelscited by 1
  5. 2026Surgical Repair of Insecure Code Generation in LLMscited by 1
  6. 2026Constrained Code Generation with Discrete Diffusioncited by 1
  7. 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methodscited by 1
  8. 2026The Invisible Lottery: How Subtle Cues Steer Algorithm Choice in LLM Code Generationcited by 1
  9. 2024Selection of Prompt Engineering Techniques for Code Generation through Predicting Code Complexitycited by 0
  10. 2024Test-driven Software Experimentation with LASSO: an LLM Prompt Benchmarking Examplecited by 0
  11. 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanismscited by 0
  12. 2026A Quasi-Experimental Developer Study of Security Training in LLM-Assisted Web Application Developmentcited by 0
  13. 2026A Tertiary Review of Large Language Model-Based Code Generating Tasks: Trends, Challenges, and Future Directionscited by 0
  14. 2026Can Open-Source LLM Agents Replace Static Application Security Testing Tools? An Empirical Assessmentcited by 0
  15. 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
  16. 2026Prompt Coach: An Empirical Evaluation of an Agentic Tutor for Learning Prompt Engineering in Software Developmentcited by 0
  17. 2026The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Repromptingcited by 0
  18. 2026Do Influence Tactics Matter? Investigating Prompt Framing Effects in LLM Code Generationcited by 0
  19. 2026Vibe Coding and Web Application Security: A Twin-Prompt Studycited by 0
  20. 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaborationcited by 0
  21. 2026A Study of the Reliability of Agentic AI-Generated Programscited by 0
  22. 2026SEEK: Agentic Knowledge Graph Retrieval for Secure Code Generationcited by 0