Tool-Guided Retrieval-Augmented Repair for Securing LLM-Generated C Code
Not on the map. Why?
Abstract (arXiv)
Large language models can generate C code from natural-language descriptions, but resulting programs often contain security vulnerabilities and compilation errors, posing risks for embedded and resource-constrained systems. This work investigates how feedback and retrieval improve reliability of LLM-generated C code. We present an analysis-and-repair workflow that combines compilation diagnostics, CodeQL static analysis, and KLEE symbolic execution with retrieval of prior repair patterns for iterative refinement. Evaluated on 5,000 C programming tasks exercising embedded relevant vulnerabilities, baseline models show substantial reliability gaps, with compilation failure rates up to 46% and security defect rates up to 49%. Our approach improves both metrics. For CodeLlama 7B, security defect rates decrease from 49% to 19% and total CodeQL errors drop from 15,088 to 2,463 (83.7%). For DeepSeek Coder 1.3B, compilation failures are reduced from 42% to 22% and security defects from 35% to 15%. These results show that integrating lightweight analysis tools can improve the safety of LLM-generated code for embedded development.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 5 of its 8 references that are in the map. First posted on arXiv 21 Jul 2026.
Builds on
5 of 8 references.
References · 5
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2025Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generationcited by 12
- 2025RESCUE: Retrieval Augmented Secure Code Generationcited by 7
- 2025SecureFixAgent: A Hybrid LLM Agent for Automated Python Static Vulnerability Repaircited by 3
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2026Improving LLM-Assisted Secure Code Generation through Retrieval-Augmented-Generation and Multi-Tool Feedback
- 2025Automated Repair of C Programs Using Large Language Models
- 2024A Case Study of LLM for Automated Vulnerability Repair: Assessing Impact of Reasoning and Patch Validation Feedback
- 2026Persistent Human Feedback, LLMs, and Static Analyzers for Secure Code Generation and Vulnerability Detection
- 2025Rethinking the Evaluation of Secure Code Generation
- 2026Guiding Symbolic Execution with Static Analysis and LLMs for Vulnerability Discovery
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
- 2026Revisiting Vul-RAG: Reproducibility and Replicability of RAG-based Vulnerability Detection with Open-Weight Models