Is Your Prompt Poisoning Code? Defect Induction Rates and Security Mitigation Strategies
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) have become indispensable for automated code generation, yet the quality and security of their outputs remain a critical concern. Existing studies predominantly concentrate on adversarial attacks or inherent flaws within the models. However, a more prevalent yet underexplored issue concerns how the quality of a benign but poorly formulated prompt affects the security of the generated code. To investigate this, we first propose an evaluation framework for prompt quality encompassing three key dimensions: goal clarity, information completeness, and logical consistency. Based on this framework, we construct and publicly release CWE-BENCH-PYTHON, a large-scale benchmark dataset containing tasks with prompts categorized into four distinct levels of normativity (L0-L3). Extensive experiments on multiple state-of-the-art LLMs reveal a clear correlation: as prompt normativity decreases, the likelihood of generating insecure code consistently and markedly increases. Furthermore, we demonstrate that advanced prompting techniques, such as Chain-of-Thought and Self-Correction, effectively mitigate the security risks introduced by low-quality prompts, substantially improving code safety. Our findings highlight that enhancing the quality of user prompts constitutes a critical and effective strategy for strengthening the security of AI-generated code.
Key facts. Cited by 3 papers in the map (data through 7 Oct 2026). Builds on 30 of its 46 references that are in the map. First posted on arXiv 27 Oct 2025.
Builds on
30 of 46 references.
References · 30
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,160
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2022Survey of Hallucination in Natural Language Generationcited by 2,056
- 2020Shortcut Learning in Deep Neural Networkscited by 1,928
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injectioncited by 1,339
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2023Large Language Models for Software Engineering: Survey and Open Problemscited by 178
18 more
- 2024Optimization-based Prompt Injection Attack to LLM-as-a-Judgecited by 123
- 2023An Analysis of the Automatic Bug Fixing Performance of ChatGPTcited by 108
- 2021Examining Zero-Shot Vulnerability Repair with Large Language Modelscited by 105
- 2024IRIS: LLM-Assisted Static Analysis for Detecting Security Vulnerabilitiescited by 100
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?cited by 89
- 2023Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issuescited by 78
- 2023How Secure is Code Generated by ChatGPT?cited by 77
- 2023LLMSecEval: A Dataset of Natural Language Prompts for Security Evaluationscited by 58
- 2023CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Modelscited by 52
- 2023Large Language Models Are Not Strong Abstract Reasonerscited by 52
- 2023WaveCoder: Widespread And Versatile Enhancement For Code Large Language Models By Instruction Tuningcited by 42
- 2023Security Weaknesses of Copilot-Generated Code in GitHub Projects: An Empirical Studycited by 36
- 2025Multi-Agent-as-Judge: Aligning LLM-Agent-Based Automated Evaluation with Multi-Dimensional Human Evaluationcited by 26
- 2023Assessing the Security of GitHub Copilot Generated Code -- A Targeted Replication Studycited by 24
- 2025A.S.E: A Repository-Level Benchmark for Evaluating Security in AI-Generated Codecited by 12
- 2024An Investigation into Misuse of Java Security APIs by Large Language Modelscited by 11
- 2024How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?cited by 7
- 2023Automating the Correctness Assessment of AI-generated Code for Security Contextscited by 6
Built on by
Citing papers per year: 2025: 1; 2026: 2.
3 papers.
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Softwarecited by 4
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMscited by 0
- 2026The Substrate Collapse: AI Code Generation Invalidates Authorship-Based Knowledge Metricscited by 0
- 2026The Substrate Collapse: AI Code Generation Invalidates Authorship-Based Knowledge Metrics18 Jun 2026
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMs2 Jun 2026
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software21 Dec 2025
Similar, not cited
Close in wording, no citation either way
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods
- 2026Enhancing Reliability in LLM-Based Secure Code Generation
- 2025Benchmarking Prompt Engineering Techniques for Secure Code Generation with GPT Models
- 2025System Prompt Poisoning: Persistent Attacks on Large Language Models Beyond User Injection
- 2024Understanding Defects in Generated Codes by Language Models
- 2025Do Prompt Patterns Affect Code Quality? A First Empirical Assessment of ChatGPT-Generated Code
- 2026Poster: Rethinking Security in LLM Code Generation through Real-World Risk Scenarios
- 2024The Impact of Prompt Programming on Function-Level Code Generation