Fortifying LLM-Based Code Generation with Graph-Based Reasoning on Secure Coding Practices
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
The code generation capabilities of Large Language Models (LLMs) have transformed the field of software development. However, this advancement also presents significant security challenges, as LLM-generated code often contains vulnerabilities. One direction of research strengthens LLMs by injecting or refining security knowledge through curated datasets, model tuning, or static analyzers. While effective in certain settings, these methods can be resource-intensive, less adaptable to zero-day vulnerabilities, and often inapplicable to proprietary models. To address these challenges, we introduce GRASP, which explores a new direction that focuses on structured reasoning over Secure Coding Practices(SCPs) rather than additional training or external feedback. GRASP comprises two key ideas: (1) an SCP graph that organizes SCPs into a Directed Acyclic Graph (DAG) capturing dependencies and relationships, and (2) a graph-based reasoning process that systematically guides LLMs through relevant SCPs for code generation. This design enables interpretable, model-agnostic, and scalable security improvements, particularly for previously unseen vulnerabilities. Our evaluation shows that GRASP consistently achieves Security Rates (SR) exceeding 80% across multiple LLMs, and delivers up to 88% improvements over baselines on zero-day vulnerabilities.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 19 of its 60 references that are in the map. First posted on arXiv 8 Oct 2025.
Builds on
19 of 60 references.
References · 19
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,155
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 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
- 2023Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Modelscited by 550
- 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 492
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2024Graph Retrieval-Augmented Generation: A Surveycited by 320
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
7 more
- 2023How Secure is Code Generated by ChatGPT?cited by 77
- 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 63
- 2024Instruction Tuning for Secure Code Generationcited by 63
- 2024Constrained Decoding for Secure Code Generationcited by 35
- 2024Enhancing Security of AI-Based Code Synthesis with GitHub Copilot via Cheap and Efficient Prompt-Engineeringcited by 6
- 2025Can You Really Trust Code Copilots? Evaluating Large Language Models from a Code Security Perspectivecited by 6
- 2017Secure Coding Practices in Java: Challenges and Vulnerabilitiescited by 4
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2025SCGAgent: Recreating the Benefits of Reasoning Models for Secure Code Generation with Agentic Workflows
- 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
- 2026SecPI: Secure Code Generation with Reasoning Models via Security Reasoning Internalization
- 2026Poster: Rethinking Security in LLM Code Generation through Real-World Risk Scenarios
- 2026Enhancing Reliability in LLM-Based Secure Code Generation
- 2026Improving LLM-Assisted Secure Code Generation through Retrieval-Augmented-Generation and Multi-Tool Feedback
- 2025Rethinking the Evaluation of Secure Code Generation
- 2026An Empirical Evaluation of LLM-Generated Code Security Across Prompting Methods