mlsanityData to 7 Oct 2026

VulInstruct: Teaching LLMs Root-Cause Reasoning for Vulnerability Detection via Security Specifications

arXiv 2511.04014 ↗First posted 6 Nov 2025cs.SE cs.CRcited by 4

On the map: LLM reasoning → Reasoning for agents, planning and code

Abstract (arXiv)

Large language models (LLMs) have achieved remarkable progress in code understanding tasks. However, they demonstrate limited performance in vulnerability detection and struggle to distinguish vulnerable code from patched code. We argue that LLMs lack understanding of security specifications -- the expectations about how code should behave to remain safe. When code behavior differs from these expectations, it becomes a potential vulnerability. However, such knowledge is rarely explicit in training data, leaving models unable to reason about security flaws. We propose VulInstruct, a specification-guided approach that systematically extracts security specifications from historical vulnerabilities to detect new ones. VulInstruct constructs a specification knowledge base from two perspectives: (i) General specifications from high-quality patches across projects, capturing fundamental safe behaviors; and (ii) Domain-specific specifications from repeated violations in particular repositories relevant to the target code. VulInstruct retrieves relevant past cases and specifications, enabling LLMs to reason about expected safe behaviors rather than relying on surface patterns. We evaluate VulInstruct under strict criteria requiring both correct predictions and valid reasoning. On PrimeVul, VulInstruct achieves 45.0% F1-score (32.7% improvement) and 37.7% recall (50.8% improvement) compared to baselines, while uniquely detecting 24.3% of vulnerabilities -- 2.4x more than any baseline. In pair-wise evaluation, VulInstruct achieves 32.3% relative improvement. VulInstruct also discovered a previously unknown high-severity vulnerability (CVE-2025-56538) in production code, demonstrating practical value for real-world vulnerability discovery. All code and supplementary materials are available at https://github.com/zhuhaopku/VulInstruct-temp.

Key facts. Cited by 4 papers 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 25 of its 42 references that are in the map. First posted on arXiv 6 Nov 2025.

Builds on

25 of 42 references.

Closest ancestors · 2

Same direction, newest first

  1. 2025R2Vul: Learning to Reason about Software Vulnerabilities with Reinforcement Learning and Structured Reasoning Distillation7 Apr
  2. 2024LLM4Vuln: A Unified Evaluation Framework for Decoupling and Enhancing LLMs' Vulnerability Reasoning29 Jan

Other references · 23

  1. 2025A Survey on Code Generation with LLM-based Agentscited by 104
  2. 2024IRIS: LLM-Assisted Static Analysis for Detecting Security Vulnerabilitiescited by 100
  3. 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
  4. 2024Vul-RAG: Enhancing LLM-based Vulnerability Detection via Knowledge-level RAGcited by 67
  5. 2023Prompt-Enhanced Software Vulnerability Detection Using ChatGPTcited by 51
  6. 2024Large Language Model for Vulnerability Detection: Emerging Results and Future Directionscited by 44
  7. 2023ToolCoder: Teach Code Generation Models to use API search toolscited by 37
  8. 2024Chain-of-Thought Prompting of Large Language Models for Discovering and Fixing Software Vulnerabilitiescited by 31
  9. 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuningcited by 30
  10. 2025Benchmarking LLMs and LLM-based Agents in Practical Vulnerability Detection for Code Repositoriescited by 29
  11. 2025Let the Trial Begin: A Mock-Court Approach to Vulnerability Detection using LLM-Based Agentscited by 20
  12. 2024VulEval: Towards Repository-Level Evaluation of Software Vulnerability Detectioncited by 18
11 more
  1. 2025Everything You Wanted to Know About LLM-based Vulnerability Detection But Were Afraid to Askcited by 15
  2. 2023ChatCoder: Chat-based Refine Requirement Improves LLMs' Code Generationcited by 13
  3. 2025aiXcoder-7B-v2: Training LLMs to Fully Utilize the Long Context in Repository-level Code Completioncited by 8
  4. 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Modelscited by 8
  5. 2025Context-Enhanced Vulnerability Detection Based on Large Language Modelcited by 6
  6. 2025BugScope: Learn to Find Bugs Like Humancited by 5
  7. 2024Beyond ChatGPT: Enhancing Software Quality Assurance Tasks with Diverse LLMs and Validation Techniquescited by 4
  8. 2024Exploring Data-Efficient Adaptation of Large Language Models for Code Generationcited by 3
  9. 2024If LLMs Would Just Look: Simple Line-by-line Checking Improves Vulnerability Localizationcited by 2
  10. 2025LAMeD: LLM-generated Annotations for Memory Leak Detectioncited by 2
  11. 2025CognixShield: PoV-Guided Vulnerable API Usage Detection in Large Codebases via LLMscited by 1

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 4.

4 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2026VulTriage: Triple-Path Context Augmentation for LLM-Based Vulnerability Detection
  2. 2026VulWeaver: Weaving Broken Semantics for Grounded Vulnerability Detection
  3. 2026Representation Matters: An Empirical Study of Program Representations for LLM Vulnerability Reasoning
  4. 2025SV-TrustEval-C: Evaluating Structure and Semantic Reasoning in Large Language Models for Source Code Vulnerability Analysis
  5. 2025Boosting Vulnerability Detection of LLMs via Curriculum Preference Optimization with Synthetic Reasoning Data
  6. 2025Reasoning with LLMs for Zero-Shot Vulnerability Detection
  7. 2026Inference-Time Safety For Code LLMs Via Retrieval-Augmented Revision
  8. 2026Do Fine-Tuned LLMs Understand Vulnerabilities? An Investigation into the Semantic Trap