Large Language Model based Smart Contract Auditing with LLMBugScanner

Yining Yuan, Yifei Wang, Yichang Xu, Zachary Yahn, Sihao Hu, Ling LiuarXiv 2025 · DOI

Abstract

Smart contracts are the foundational layer of decentralized finance (DeFi), yet their immutable nature makes them vulnerable to catastrophic financial exploits. While Large Language Models (LLMs) offer advanced reasoning for code auditing, individual models often suffer from high false-positive rates and limited generalization. This paper introduces LLMBugScanner, a framework that combines domain-specific fine-tuning with ensemble learning to aggregate the "collective wisdom" of multiple LLMs. LLMBugScanner achieves a 60% top-5 detection accuracy on real-world vulnerabilities, outperforming single-model baselines by 19%.

Introduction

The "code is law" paradigm in blockchain means a single bug can lead to permanent loss, as seen in the $60 million DAO exploit. Traditional static and dynamic analysis tools often struggle with complex business logic and intent, leading to high false-positive rates. While LLMs show promise, they are not a panacea; a model might excel at catching reentrancy bugs but fail at access control. Furthermore, fine-tuning a single model often leads to overfitting. LLMBugScanner addresses these challenges through a multi-stage adaptation and ensemble strategy.

Methods: The LLMBugScanner Framework

The framework employs a two-stage approach to transform general-purpose LLMs into specialized security auditors.

Figure 5: The LLMBugScanner architecture, illustrating the flow from dataset preparation through domain knowledge adaptation to the final model ensemble.
  1. Domain Knowledge Adaptation: Using LoRA (Low-Rank Adaptation), five open-source LLMs (including CodeLlama, DeepSeek, and CodeGemma) undergo sequential training. First, "foundational" tuning on a broad Ethereum dataset improves general code interpretation. This is followed by "instructional" tuning on high-quality, labeled vulnerability data to hone bug-detection skills.
  2. LLM-Ensemble: Multiple fine-tuned models run in parallel to provide diverse perspectives on the same code snippet.
  3. Consensus-Based Conflict Resolution: To resolve disagreements among models, the framework utilizes Weighted Majority Voting (prioritizing historically accurate models) and Permutation-Optimized Tie-Breaking.

Datasets

The study leverages three distinct data sources:

  • Ethereum Smart Contract Dataset: 775 Solidity files for foundational tuning.
  • CVE Solidity Subset: 28 high-quality, annotated files for instructional tuning.
  • Evaluation Benchmark: 108 real-world vulnerable contracts labeled with CVEs, serving as the final performance metric.

Key Insights and Results

The experimental results highlight several critical advantages of the ensemble approach:

  • Sequential Tuning Efficacy: Models trained first on general language nuances before specific vulnerabilities showed faster convergence and lower initial loss.
  • Diversity as Robustness: While individual models may hallucinate, they rarely fail in identical ways. A consensus of 4–5 models serves as a highly reliable indicator of a true vulnerability.
  • Confusion Matrix Cleanup: Fine-tuning significantly reduced inter-class confusion. Before adaptation, models frequently misclassified "Access Control" issues as "Integer Overflows"; post-adaptation, these categories became distinct.
Figure 2: Comparison of vulnerability confusion matrices before and after fine-tuning, showing a significant reduction in misclassifications.
  • Performance Gains: LLMBugScanner achieved a 60% top-5 accuracy, a 19% improvement over individual fine-tuned baselines.

Limitations and Future Work

Despite its success, LLMBugScanner faces challenges:

  • Hallucination: A ~10% hallucination rate persists, where models identify non-existent bugs.
  • Data Scarcity: Performance on rare vulnerability types remains lower than on common ones like Integer Overflow.
  • Future Directions: Future research will explore Meta-Classifiers to learn which LLMs to trust for specific code patterns, and Symbolic Integration to verify LLM reasoning with formal methods.

Summary updated

BibTeX
@misc{yuan2025large,
  author = {Yining Yuan and Yifei Wang and Yichang Xu and Zachary Yahn and Sihao Hu and Ling Liu},
  title = {{Large Language Model based Smart Contract Auditing with LLMBugScanner}},
  year = {2025},
  eprint = {2512.02069},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.02069},
}
Figure