RefleXGen:The unexamined code is not worth using
Not on the map. Why?
Abstract (arXiv)
Security in code generation remains a pivotal challenge when applying large language models (LLMs). This paper introduces RefleXGen, an innovative method that significantly enhances code security by integrating Retrieval-Augmented Generation (RAG) techniques with guided self-reflection mechanisms inherent in LLMs. Unlike traditional approaches that rely on fine-tuning LLMs or developing specialized secure code datasets - processes that can be resource-intensive - RefleXGen iteratively optimizes the code generation process through self-assessment and reflection without the need for extensive resources. Within this framework, the model continuously accumulates and refines its knowledge base, thereby progressively improving the security of the generated code. Experimental results demonstrate that RefleXGen substantially enhances code security across multiple models, achieving a 13.6% improvement with GPT-3.5 Turbo, a 6.7% improvement with GPT-4o, a 4.5% improvement with CodeQwen, and a 5.8% improvement with Gemini. Our findings highlight that improving the quality of model self-reflection constitutes an effective and practical strategy for strengthening the security of AI-generated code.
Key facts. Cited by 4 papers in the map (data through 14 Oct 2026). Builds on 16 of its 21 references that are in the map. First posted on arXiv 27 Oct 2025.
Builds on
16 of 21 references.
References · 16
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 155
- 2016Latent Predictor Networks for Code Generationcited by 73
- 2024Instruction Tuning for Secure Code Generationcited by 68
- 2019TreeGen: A Tree-Based Transformer Architecture for Code Generationcited by 58
- 2020ERNIE-GEN: An Enhanced Multi-Flow Pre-training and Fine-tuning Framework for Natural Language Generationcited by 40
4 more
- 2022Fault-Aware Neural Code Rankerscited by 33
- 2023Think Outside the Code: Brainstorming Boosts Large Language Models in Code Generationcited by 19
- 2023Enhancing Large Language Models for Secure Code Generation: A Dataset-driven Study on Vulnerability Mitigationcited by 15
- 2023Incrementalizing Production CodeQL Analysescited by 2
Built on by
Citing papers per year: 2025: 2; 2026: 2.
4 papers.
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Softwarecited by 4
- 2025Argus: A Multi-Agent Sensitive Information Leakage Detection Framework Based on Hierarchical Reference Relationshipscited by 0
- 2026OMEGA: Optimizing Machine Learning by Evaluating Generated Algorithmscited by 0
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMscited by 0
- 2026Learn from Your Mistakes: Tree-like Self-Play for Secure Code LLMs2 Jun 2026
- 2026OMEGA: Optimizing Machine Learning by Evaluating Generated Algorithms29 Apr 2026
- 2025AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software21 Dec 2025
- 2025Argus: A Multi-Agent Sensitive Information Leakage Detection Framework Based on Hierarchical Reference Relationships9 Dec 2025
Similar, not cited
Close in wording, no citation either way
- 2025SOSecure: Safer Code Generation with RAG and StackOverflow Discussions
- 2025RESCUE: Retrieval Augmented Secure Code Generation
- 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injection
- 2026Improving LLM-Assisted Secure Code Generation through Retrieval-Augmented-Generation and Multi-Tool Feedback
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
- 2026Security-by-Design for LLM-Based Code Generation: Leveraging Internal Representations for Concept-Driven Steering Mechanisms
- 2025Rethinking the Evaluation of Secure Code Generation
- 2023SelfEvolve: A Code Evolution Framework via Large Language Models