DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructions
Not on the map. Why?
Abstract (arXiv)
With the advancement of Large Language Models (LLMs), significant progress has been made in code generation, enabling LLMs to transform natural language into programming code. These Code LLMs have been widely accepted by massive users and organizations. However, a dangerous nature is hidden in the code, which is the existence of fatal vulnerabilities. While some LLM providers have attempted to address these issues by aligning with human guidance, these efforts fall short of making Code LLMs practical and robust. Without a deep understanding of the performance of the LLMs under the practical worst cases, it would be concerning to apply them to various real-world applications. In this paper, we answer the critical issue: Are existing Code LLMs immune to generating vulnerable code? If not, what is the possible maximum severity of this issue in practical deployment scenarios? In this paper, we introduce DeceptPrompt, a novel algorithm that can generate adversarial natural language instructions that drive the Code LLMs to generate functionality correct code with vulnerabilities. DeceptPrompt is achieved through a systematic evolution-based algorithm with a fine grain loss design. The unique advantage of DeceptPrompt enables us to find natural prefix/suffix with totally benign and non-directional semantic meaning, meanwhile, having great power in inducing the Code LLMs to generate vulnerable code. This feature can enable us to conduct the almost-worstcase red-teaming on these LLMs in a real scenario, where users are using natural language. Our extensive experiments and analyses on DeceptPrompt not only validate the effectiveness of our approach but also shed light on the huge weakness of LLMs in the code generation task. When applying the optimized prefix/suffix, the attack success rate (ASR) will improve by average 50% compared with no prefix/suffix applying.
Key facts. Cited by 31 papers in the map (data through 7 Oct 2026). Builds on 31 of its 59 references that are in the map. First posted on arXiv 7 Dec 2023.
Builds on
31 of 59 references.
References · 31
- 2023GPT-4 Technical Reportcited by 18,132
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2017Towards Deep Learning Models Resistant to Adversarial Attackscited by 6,326
- 2019The Curious Case of Neural Text Degenerationcited by 2,881
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2023StarCoder: may the source be with you!cited by 790
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023Baseline Defenses for Adversarial Attacks Against Aligned Language Modelscited by 608
19 more
- 2018Threat of Adversarial Attacks on Deep Learning in Computer Vision: A Surveycited by 459
- 2021MetaICL: Learning to Learn In Contextcited by 450
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2018QuAC : Question Answering in Contextcited by 379
- 2017Adversarial Attacks on Neural Network Policiescited by 314
- 2023Mathematical Capabilities of ChatGPTcited by 263
- 2020IntelliCode Compose: Code Generation Using Transformercited by 225
- 2015Visualizing and Understanding Neural Models in NLPcited by 199
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
- 2023Adversarial Demonstration Attacks on Large Language Modelscited by 58
- 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 48
- 2023TrojanPuzzle: Covertly Poisoning Code-Suggestion Modelscited by 47
- 2021Perfection Not Required? Human-AI Partnerships in Code Translationcited by 42
- 2023Evaluation of ChatGPT Model for Vulnerability Detectioncited by 33
- 2023An Independent Evaluation of ChatGPT on Mathematical Word Problems (MWP)cited by 31
- 2023Vulnerabilities in AI Code Generators: Exploring Targeted Data Poisoning Attackscited by 29
- 2021Adversarial Robustness of Deep Code Comment Generationcited by 22
- 2023AI Insights into Theoretical Physics and the Swampland Program: A Journey Through the Cosmos with ChatGPTcited by 10
- 2023A Preliminary Analysis on the Code Generation Capabilities of GPT-3.5 and Bard AI Models for Java Functionscited by 8
Built on by
Citing papers per year: 2024: 13; 2025: 12; 2026: 6.
31 papers.
Sort:
By area:
- 2024Attacks, Defenses and Evaluations for LLM Conversation Safety: A Surveycited by 124
- 2024Evolutionary Computation in the Era of Large Language Model: Survey and Roadmapcited by 89
- 2024Red-Teaming for Generative AI: Silver Bullet or Security Theater?cited by 81
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024IRCoder: Intermediate Representations Make Language Models Robust Multilingual Code Generatorscited by 21
- 2025NeuroStrike: Neuron-Level Attacks on Aligned LLMscited by 18
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasetscited by 15
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challengescited by 14
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 13
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answerscited by 12
- 2024Automated Progressive Red Teamingcited by 12
19 more
- 2025When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task Descriptionscited by 8
- 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMscited by 8
- 2024MaPPing Your Model: Assessing the Impact of Adversarial Attacks on LLM-based Programming Assistantscited by 5
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?cited by 5
- 2026Fragile Thoughts: How Large Language Models Handle Chain-of-Thought Perturbationscited by 5
- 2024SeCodePLT: A Unified Platform for Evaluating the Security of Code GenAIcited by 4
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistantscited by 4
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generationcited by 4
- 2025RAG-Pull: Turning Retrieval into a Code-Injection Channel via Invisible Unicode Perturbationscited by 4
- 2025A First Look at the Security Issues in the Model Context Protocol Ecosystemcited by 3
- 2025When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?cited by 2
- 2026NeST: Neuron Selective Tuning for LLM Safetycited by 2
- 2026Sleeper Cell: Injecting Latent Malice Temporal Backdoors into Tool-Using LLMscited by 2
- 2024Psychological Profiling in Cybersecurity: A Look at LLMs and Psycholinguistic Featurescited by 1
- 2026Surgical Repair of Insecure Code Generation in LLMscited by 1
- 2026IssueTrojanBench: Benchmarking AI Coding Agents Against Malicious Issue Requestscited by 1
- 2024Automated Creation of Source Code Variants of a Cryptographic Hash Function Implementation Using Generative Pre-Trained Transformer Modelscited by 0
- 2025AKD : Adversarial Knowledge Distillation For Large Language Models Alignment on Coding taskscited by 0
- 2026CS-Guard: Benchmarking LLM Guardrails for Code Generation Securitycited by 0
- 2026CS-Guard: Benchmarking LLM Guardrails for Code Generation Security9 Sep 2026
- 2026IssueTrojanBench: Benchmarking AI Coding Agents Against Malicious Issue Requests22 Jul 2026
- 2026Surgical Repair of Insecure Code Generation in LLMs17 Apr 2026
- 2026Sleeper Cell: Injecting Latent Malice Temporal Backdoors into Tool-Using LLMs2 Mar 2026
- 2026NeST: Neuron Selective Tuning for LLM Safety18 Feb 2026
- 2026Fragile Thoughts: How Large Language Models Handle Chain-of-Thought Perturbations11 Feb 2026
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025A First Look at the Security Issues in the Model Context Protocol Ecosystem18 Oct 2025
- 2025When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?15 Oct 2025
- 2025RAG-Pull: Turning Retrieval into a Code-Injection Channel via Invisible Unicode Perturbations13 Oct 2025
- 2025NeuroStrike: Neuron-Level Attacks on Aligned LLMs15 Sep 2025
- 2025When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task Descriptions27 Jul 2025
19 more
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?25 Jul 2025
- 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMs25 Jun 2025
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generation8 Jun 2025
- 2025AKD : Adversarial Knowledge Distillation For Large Language Models Alignment on Coding tasks5 May 2025
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasets21 Mar 2025
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants18 Mar 2025
- 2024SeCodePLT: A Unified Platform for Evaluating the Security of Code GenAI14 Oct 2024
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challenges30 Sep 2024
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completion5 Aug 2024
- 2024MaPPing Your Model: Assessing the Impact of Adversarial Attacks on LLM-based Programming Assistants12 Jul 2024
- 2024Automated Progressive Red Teaming4 Jul 2024
- 2024Psychological Profiling in Cybersecurity: A Look at LLMs and Psycholinguistic Features26 Jun 2024
- 2024Constrained Decoding for Secure Code Generation30 Apr 2024
- 2024Automated Creation of Source Code Variants of a Cryptographic Hash Function Implementation Using Generative Pre-Trained Transformer Models24 Apr 2024
- 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answers22 Mar 2024
- 2024IRCoder: Intermediate Representations Make Language Models Robust Multilingual Code Generators6 Mar 2024
- 2024Attacks, Defenses and Evaluations for LLM Conversation Safety: A Survey14 Feb 2024
- 2024Red-Teaming for Generative AI: Silver Bullet or Security Theater?29 Jan 2024
- 2024Evolutionary Computation in the Era of Large Language Model: Survey and Roadmap18 Jan 2024
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2025A First Look at the Security Issues in the Model Context Protocol Ecosystemcited by 3
- 2025When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?cited by 2
- 2026Sleeper Cell: Injecting Latent Malice Temporal Backdoors into Tool-Using LLMscited by 2
- 2026IssueTrojanBench: Benchmarking AI Coding Agents Against Malicious Issue Requestscited by 1
- 2026IssueTrojanBench: Benchmarking AI Coding Agents Against Malicious Issue Requests22 Jul 2026
- 2026Sleeper Cell: Injecting Latent Malice Temporal Backdoors into Tool-Using LLMs2 Mar 2026
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025A First Look at the Security Issues in the Model Context Protocol Ecosystem18 Oct 2025
- 2025When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?15 Oct 2025
- 2024Red-Teaming for Generative AI: Silver Bullet or Security Theater?cited by 81
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challengescited by 14
- 2024Automated Progressive Red Teamingcited by 12
- 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMscited by 8
- 2026CS-Guard: Benchmarking LLM Guardrails for Code Generation Securitycited by 0
- 2026CS-Guard: Benchmarking LLM Guardrails for Code Generation Security9 Sep 2026
- 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMs25 Jun 2025
- 2024Mitigating Backdoor Threats to Large Language Models: Advancement and Challenges30 Sep 2024
- 2024Automated Progressive Red Teaming4 Jul 2024
- 2024Red-Teaming for Generative AI: Silver Bullet or Security Theater?29 Jan 2024
- 2025NeuroStrike: Neuron-Level Attacks on Aligned LLMscited by 18
- 2026NeST: Neuron Selective Tuning for LLM Safetycited by 2
- 2026NeST: Neuron Selective Tuning for LLM Safety18 Feb 2026
- 2025NeuroStrike: Neuron-Level Attacks on Aligned LLMs15 Sep 2025
- 2024Attacks, Defenses and Evaluations for LLM Conversation Safety: A Surveycited by 124
- 2024Evolutionary Computation in the Era of Large Language Model: Survey and Roadmapcited by 89
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024IRCoder: Intermediate Representations Make Language Models Robust Multilingual Code Generatorscited by 21
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasetscited by 15
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 13
- 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answerscited by 12
- 2025When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task Descriptionscited by 8
- 2024MaPPing Your Model: Assessing the Impact of Adversarial Attacks on LLM-based Programming Assistantscited by 5
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?cited by 5
- 2024SeCodePLT: A Unified Platform for Evaluating the Security of Code GenAIcited by 4
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistantscited by 4
12 most cited of 16 All 16 (JSON)
- 2026Surgical Repair of Insecure Code Generation in LLMs17 Apr 2026
- 2025When Prompts Go Wrong: Evaluating Code Model Robustness to Ambiguous, Contradictory, and Incomplete Task Descriptions27 Jul 2025
- 2025MOCHA: Are Code Language Models Robust Against Multi-Turn Malicious Coding Prompts?25 Jul 2025
- 2025AKD : Adversarial Knowledge Distillation For Large Language Models Alignment on Coding tasks5 May 2025
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasets21 Mar 2025
- 2025XOXO: Stealthy Cross-Origin Context Poisoning Attacks against AI Coding Assistants18 Mar 2025
- 2024SeCodePLT: A Unified Platform for Evaluating the Security of Code GenAI14 Oct 2024
- 2024Black-Box Adversarial Attacks on LLM-Based Code Completion5 Aug 2024
- 2024MaPPing Your Model: Assessing the Impact of Adversarial Attacks on LLM-based Programming Assistants12 Jul 2024
- 2024Psychological Profiling in Cybersecurity: A Look at LLMs and Psycholinguistic Features26 Jun 2024
- 2024Constrained Decoding for Secure Code Generation30 Apr 2024
- 2024Automated Creation of Source Code Variants of a Cryptographic Hash Function Implementation Using Generative Pre-Trained Transformer Models24 Apr 2024
12 newest of 16 All 16 (JSON)