Towards Compositional Generalization in LLMs for Smart Contract Security: A Case Study on Reentrancy Vulnerabilities

📅 2026-01-11
🏛️ arXiv.org
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the limited generalization capability of large language models (LLMs) in detecting reentrancy vulnerabilities in smart contracts, where they often underperform compared to traditional static analysis tools. To overcome this limitation, the authors propose a post-training approach based on atomic task decomposition and fusion. Specifically, reentrancy detection is decomposed into four linearly independent atomic tasks, and the model is fine-tuned using synthetic data, LoRA-based low-rank adapters, and structural information from control-flow and data-flow graphs extracted by Slither. A low-rank normalization fusion strategy is further introduced to enhance compositional generalization. This method achieves 98.2% accuracy in reentrancy detection and demonstrates a 20% higher recall than conventional static analysis tools across 31 real-world smart contracts, marking the first successful application of compositional generalization with LLMs in smart contract security.

Technology Category

Application Category

📝 Abstract
Large language models (LLMs) demonstrate remarkable capabilities in natural language understanding and generation. Despite being trained on large-scale, high-quality data, LLMs still fail to outperform traditional static analysis tools in specialized domains like smart contract vulnerability detection. To address this issue, this paper proposes a post-training algorithm based on atomic task decomposition and fusion. This algorithm aims to achieve combinatorial generalization under limited data by decomposing complex reasoning tasks. Specifically, we decompose the reentrancy vulnerability detection task into four linearly independent atomic tasks: identifying external calls, identifying state updates, identifying data dependencies between external calls and state updates, and determining their data flow order. These tasks form the core components of our approach. By training on synthetic datasets, we generate three compiler-verified datasets. We then employ the Slither tool to extract structural information from the control flow graph and data flow graph, which is used to fine-tune the LLM's adapter. Experimental results demonstrate that low-rank normalization fusion with the LoRA adapter improves the LLM's reentrancy vulnerability detection accuracy to 98.2%, surpassing state-of-the-art methods. On 31 real-world contracts, the algorithm achieves a 20% higher recall than traditional analysis tools.
Problem

Research questions and friction points this paper is trying to address.

compositional generalization
large language models
smart contract security
reentrancy vulnerabilities
vulnerability detection
Innovation

Methods, ideas, or system contributions that make the work stand out.

compositional generalization
atomic task decomposition
LoRA adapter
reentrancy vulnerability
smart contract security
🔎 Similar Papers
No similar papers found.
Y
Ying Zhou
School of Artificial Intelligence, Beijing, China; Beijing Advanced Innovation Center for Future Blockchain and Privacy Computing, Beijing, China
J
Jiacheng Wei
School of Artificial Intelligence, Beijing, China; Beijing Advanced Innovation Center for Future Blockchain and Privacy Computing, Beijing, China
Y
Yu Qi
School of Artificial Intelligence, Beijing, China; Beijing Advanced Innovation Center for Future Blockchain and Privacy Computing, Beijing, China
F
Faguo Wu
School of Artificial Intelligence, Beijing, China; Beijing Advanced Innovation Center for Future Blockchain and Privacy Computing, Beijing, China
X
Xiao Zhang
School of Artificial Intelligence, Beijing, China; Beijing Advanced Innovation Center for Future Blockchain and Privacy Computing, Beijing, China