Exploring the Security Threats of Retriever Backdoors in Retrieval-Augmented Code Generation
On the map: Retrieval-augmented generation → Privacy and security of RAG
also in 1 more
Abstract (arXiv)
Retrieval-Augmented Code Generation (RACG) is increasingly adopted to enhance Large Language Models for software development, yet its security implications remain dangerously underexplored. This paper conducts the first systematic exploration of a critical and stealthy threat: backdoor attacks targeting the retriever component, which represents a significant supply-chain vulnerability. It is infeasible to assess this threat realistically, as existing attack methods are either too ineffective to pose a real danger or are easily detected by state-of-the-art defense mechanisms spanning both latent-space analysis and token-level inspection, which achieve consistently high detection rates. To overcome this barrier and enable a realistic analysis, we first developed VenomRACG, a new class of potent and stealthy attack that serves as a vehicle for our investigation. Its design makes poisoned samples statistically indistinguishable from benign code, allowing the attack to consistently maintain low detectability across all evaluated defense mechanisms. Armed with this capability, our exploration reveals a severe vulnerability: by injecting vulnerable code equivalent to only 0.05% of the entire knowledge base size, an attacker can successfully manipulate the backdoored retriever to rank the vulnerable code in its top-5 results in 51.29% of cases. This translates to severe downstream harm, causing models like GPT-4o to generate vulnerable code in over 40% of targeted scenarios, while leaving the system's general performance intact. Our findings establish that retriever backdooring is not a theoretical concern but a practical threat to the software development ecosystem that current defenses are blind to, highlighting the urgent need for robust security measures.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Privacy and security of RAG, one of 15 directions in Retrieval-augmented generation. Builds on 34 of its 49 references that are in the map. First posted on arXiv 25 Dec 2025.
Builds on
34 of 49 references.
Closest ancestors · 2
Same direction, newest first
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection23 Apr
- 2025Exploring the Security Threats of Knowledge Base Poisoning in Retrieval-Augmented Code Generation5 Feb
Other references · 32
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,777
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,824
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injectioncited by 1,443
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2022When Not to Trust Language Models: Investigating Effectiveness of Parametric and Non-Parametric Memoriescited by 1,128
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
20 more
- 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
- 2018Spectral Signatures in Backdoor Attackscited by 484
- 2018Detecting Backdoor Attacks on Deep Neural Networks by Activation Clusteringcited by 456
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
- 2021CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Taskscited by 200
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?cited by 91
- 2024Enhancing LLM Factual Accuracy with RAG to Counter Hallucinations: A Case Study on Domain-Specific Queries in Private Knowledge-Basescited by 77
- 2023A Survey on Large Language Models for Software Engineeringcited by 59
- 2022Taxonomy of Attacks on Open-Source Software Supply Chainscited by 58
- 2023RAP-Gen: Retrieval-Augmented Patch Generation with CodeT5 for Automatic Program Repaircited by 44
- 2024A Survey on Evaluating Large Language Models in Code Generation Taskscited by 44
- 2024HumanEval Pro and MBPP Pro: Evaluating Large Language Models on Self-invoking Code Generationcited by 39
- 2024ReposVul: A Repository-Level High-Quality Vulnerability Datasetcited by 36
- 2023Refactoring Programs Using Large Language Models with Few-Shot Examplescited by 28
- 2024RMCBench: Benchmarking Large Language Models' Resistance to Malicious Codecited by 28
- 2022Poison Attack and Defense on Deep Source Code Processing Modelscited by 11
- 2024Preference-Guided Refactored Tuning for Retrieval Augmented Code Generationcited by 10
- 2025Show Me Your Code! Kill Code Poisoning: A Lightweight Method Based on Code Naturalnesscited by 8
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2025ImportSnare: Directed "Code Manual" Hijacking in Retrieval-Augmented Code Generation
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation
- 2024Backdoored Retrievers for Prompt Injection Attacks on Retrieval Augmented Generation of Large Language Models
- 2026Detecting RAG Extraction Attack via Dual-Path Runtime Integrity Game
- 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detection
- 2026Retrieved But Not Reliable: A Survey on Attacks, and Defenses in Retrieval-Augmented Generation
- 2025RAG-Pull: Turning Retrieval into a Code-Injection Channel via Invisible Unicode Perturbations
- 2026Beware What You Autocomplete: Forensic Attribution of Backdoored Code Completions