RESCUE: Retrieval Augmented Secure Code Generation
On the map: Retrieval-augmented generation → Privacy and security of RAG
Abstract (arXiv)
Despite recent advances, Large Language Models (LLMs) still generate vulnerable code. Retrieval-Augmented Generation (RAG) has the potential to enhance LLMs for secure code generation by incorporating external security knowledge. However, the conventional RAG design struggles with the noise of raw security-related documents, and existing retrieval methods overlook the significant security semantics implicitly embedded in task descriptions. To address these issues, we propose textscRescue, a new RAG framework for secure code generation with two key innovations. First, we propose a hybrid knowledge base construction method that combines LLM-assisted cluster-then-summarize distillation with program slicing, producing both high-level security guidelines and concise, security-focused code examples. Second, we design a hierarchical multi-faceted retrieval that traverses the constructed knowledge base from top to bottom and integrates multiple security-critical facts at each hierarchical level, ensuring comprehensive and accurate retrieval. We evaluated textscRescue on four benchmarks and compared it with five state-of-the-art secure code generation methods on six LLMs. The results demonstrate that textscRescue improves the SecurePass@1 metric by an average of 4.8 points, establishing a new state-of-the-art performance for security. Furthermore, we performed in-depth analysis and ablation studies to rigorously validate the effectiveness of individual components in textscRescue. Our code is available at https://github.com/steven1518/RESCUE.
Key facts. Cited by 7 papers 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 37 of its 61 references that are in the map. First posted on arXiv 21 Oct 2025.
Builds on
37 of 61 references.
Closest ancestors · 1
Same direction, newest first
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection23 Apr
Other references · 36
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,944
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2024BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructionscited by 546
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 399
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
- 2023The Impact of AI on Developer Productivity: Evidence from GitHub Copilotcited by 274
24 more
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 155
- 2022DocPrompting: Generating Code by Retrieving the Docscited by 153
- 2021Retrieval Augmented Code Generation and Summarizationcited by 149
- 2022ReACC: A Retrieval-Augmented Code Completion Frameworkcited by 119
- 2024Instruction Tuning for Secure Code Generationcited by 68
- 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 59
- 2024Repoformer: Selective Retrieval for Repository-Level Code Completioncited by 55
- 2022When Language Model Meets Private Librarycited by 54
- 2024Constrained Decoding for Secure Code Generationcited by 37
- 2024Prompting Techniques for Secure Code Generation: A Systematic Investigationcited by 34
- 2023Assessing the Security of GitHub Copilot Generated Code -- A Targeted Replication Studycited by 26
- 2024ProSec: Fortifying Code LLMs with Proactive Security Alignmentcited by 25
- 2025What to Retrieve for Effective Retrieval-Augmented Code Generation? An Empirical Study and Beyondcited by 22
- 2024How much does AI impact development speed? An enterprise-based randomized controlled trialcited by 20
- 2024PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)cited by 19
- 2025An Empirical Study of Retrieval-Augmented Code Generation: Challenges and Opportunitiescited by 18
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generationcited by 16
- 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Datacited by 16
- 2024SecCoder: Towards Generalizable and Robust Secure Code Generationcited by 14
- 2024Preference-Guided Refactored Tuning for Retrieval Augmented Code Generationcited by 10
- 2024An Exploratory Study on Fine-Tuning Large Language Models for Secure Code Generationcited by 9
- 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulnesscited by 8
- 2025SOSecure: Safer Code Generation with RAG and StackOverflow Discussionscited by 5
- 2024Codexity: Secure AI-assisted Code Generationcited by 2
Built on by
Citing papers per year: 2026: 7.
7 papers.
- 2026HardSecBench: Benchmarking the Security Awareness of LLMs for Hardware Code Generationcited by 5
- 2026Enhancing Reliability in LLM-Based Secure Code Generationcited by 2
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generationcited by 1
- 2026LLMs + Security = Troublecited by 0
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forwardcited by 0
- 2026Tool-Guided Retrieval-Augmented Repair for Securing LLM-Generated C Codecited by 0
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaborationcited by 0
- 2026CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation2 Sep 2026
- 2026MACGen: Toward Functionally Correct and Secure Code Generation via Multi-Agent Collaboration26 Aug 2026
- 2026Tool-Guided Retrieval-Augmented Repair for Securing LLM-Generated C Code21 Jul 2026
- 2026SoK: AI Secure Code Generation: Progress, Pitfalls, and Paths Forward23 Jun 2026
- 2026Enhancing Reliability in LLM-Based Secure Code Generation22 May 2026
- 2026LLMs + Security = Trouble9 Feb 2026
- 2026HardSecBench: Benchmarking the Security Awareness of LLMs for Hardware Code Generation20 Jan 2026
Similar, not cited
Close in wording, no citation either way
- 2026Improving LLM-Assisted Secure Code Generation through Retrieval-Augmented-Generation and Multi-Tool Feedback
- 2026Securing Retrieval-Augmented Generation: A Taxonomy of Attacks, Defenses, and Future Directions
- 2025SafeRAG: Benchmarking Security in Retrieval-Augmented Generation of Large Language Model
- 2025Secure Multifaceted-RAG for Enterprise: Hybrid Knowledge Retrieval with Security Filtering
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
- 2025ImportSnare: Directed "Code Manual" Hijacking in Retrieval-Augmented Code Generation
- 2025Privacy-Aware RAG: Secure and Isolated Knowledge Retrieval
- 2025RefleXGen:The unexamined code is not worth using