A Multi-class Classification Method for Smart Contract Vulnerabilities Based on Hierarchical Deep Learning
(1.Computer Academy of Guangdong, Guangzhou 510033, China; 2.School of Information Science and Technology, Guangdong University of Foreign Studies, Guangzhou 510006, China; 3.Guangzhou Doctor Information Technology Research Institute Co., Ltd., Guangzhou 510663, China; 4.School of Computer Science and Technology, Guangdong University of Technology, Guangzhou 510006, China)
Abstract
Smart contracts, as the core execution units in blockchain systems, are widely used in decentralized finance, digital asset trading and other application scenarios. However, once deployed, smart contracts are difficult to modify, and vulnerabilities in their code can be easily exploited by attackers, resulting in serious security risks and economic losses. Existing vulnerability detection methods mostly rely on manually designed rules, static analysis or symbolic execution; although these methods have certain detection capabilities for specific vulnerabilities, they generally suffer from strong feature dependence, insufficient semantic modeling and limited generalization ability in multi-class classification tasks. To address these problems, this study proposes a hierarchical deep learning method for the multi-class classification of smart contract vulnerabilities. Based on the hierarchical structure of smart contracts, a three-level semantic modeling framework at the token, function and contract levels is constructed. First, a self-attention mechanism is employed to learn the contextual representations of code tokens and extract local semantic features; second, the statement representations within functions are aggregated and encoded to learn function-level behavioral patterns; finally, multiple function representations are fused at the contract level to capture global semantic dependencies and predict vulnerability classes. The proposed method is entirely based on an end-to-end neural network and does not rely on manually designed vulnerability rules or expert features. Experimental results show that the proposed method achieves good detection performance in the multi-class classification of smart contract vulnerabilities, verifying the effectiveness of hierarchical semantic modeling in improving vulnerability identification performance.
Keywords
smart contract; vulnerability detection; multi-class classification; hierarchical modeling; Deep Learning
References
- [1] Liu Zhexu, Li Leixiao, Liu Dongjiang, etc A review of research on vulnerability detection and repair of smart contracts [J]. Computer Science and Exploration, 2025, 19 (4): 854-876
- [2] Li Fang, Li Zhuoran, Zhao He Research on the Progress of Cross chain Technology in Blockchain [J]. Journal of Software, 2019, 30 (6): 1649-1660
- [3] Zhao Bo, Shangguan Chenhan, Peng Xiaoyan, etc A smart contract bytecode vulnerability detection method based on semantic aware graph neural network [J]. Engineering Science and Technology, 2022, 54 (2): 49-55
- [4] Atzei N,Bartoletti M,Cimoli T. A Survey of Attacks on Ethereum Smart Contracts (SoK) [C]//Principles of Security and Trust,2017:164-186.
- [5] Luu L,Chu D H,Olickel H,et al. Making Smart Contracts Smarter [C]//Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security,2016:254-269.
- [6] Eskandari S,Moosavi S,Clark J. SoK: Transparent Dishonesty: Front-Running Attacks on Blockchain [C]//Financial Cryptography and Data Security,2020:170-189.
- [7] Rodler M,Li W T,Karame G O,et al. Sereum: Protecting Existing Smart Contracts Against Re-Entrancy Attacks [C]//Proceedings of the 26th Annual Network and Distributed System Security Symposium (NDSS 2019),2019:1-15.
- [8] Tikhomirov S,Voskresenskaya E,Ivanitskiy I,et al. SmartCheck: Static Analysis of Ethereum Smart Contracts [C]//Proceedings of the 1st IEEE/ACM International Workshop on Emerging Trends in Software Engineering for Blockchain,2018:9-16.
- [9] Jiang B,Liu Y,Chan W K. ContractFuzzer: Fuzzing Smart Contracts for Vulnerability Detection [C]//Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering,2018:259-269.
- [10] HajiHosseinKhani S,Habibi Lashkari A,Mizani Oskui A. Unveiling Smart Contract Vulnerabilities: Toward Profiling Smart Contract Vulnerabilities Using Enhanced Genetic Algorithm and Generating Benchmark Dataset [J/OL].Blockchain: Research and Applications,2025,6(2):100253.https://doi.org/10.1016/j.bcra.2024.100253.
- [11] Ince P,Luo X P,Yu J S,et al. Detect Llama - Finding Vulnerabilities in Smart Contracts Using Large Language Models [C]//Information Security and Privacy,2024:424-443.
- [12] Zaazaa O,El Bakkali H. SmartLLMSentry: A Comprehensive LLM Based Smart Contract Vulnerability Detection Framework [J].Journal of Metaverse,2024,4(2):126-137.
- [13] Ding H,Liu Y Z,Piao X F,et al. SmartGuard: An LLM-Enhanced Framework for Smart Contract Vulnerability Detection [J/OL].Expert Systems with Applications,2025,269:126479.https://doi.org/10.1016/j.eswa.2025.126479.
- [14] Sun H X,Yu X A,Li J L,et al. Smart Contract Vulnerability Detection Based on Symbolic Execution and Graph Neural Networks [J].Computers, Materials & Continua,2026,86(2):1-15.
- [15] Xia S H,He M T,Shao S,et al. SymGPT: Auditing Smart Contracts via Combining Symbolic Execution with Large Language Models [J].Proceedings of the ACM on Programming Languages,2026,10(OOPSLA1):482-512.
- [16] Susan Ș C,Arusoaie A,Lucanu D. Validating Solidity Code Defects Using Symbolic and Concrete Execution Powered by Large Language Models [J].Electronic Proceedings in Theoretical Computer Science,2025,427:98-116.
- [17] Chang S Y,Geng C,Huang H P,et al. CodeSpeak: Improving Smart Contract Vulnerability Detection via LLM-Assisted Code Analysis [J/OL].Journal of Systems and Software,2026,231:112635.https://doi.org/10.1016/j.jss.2025.112635.
- [18] Wei Z Y,Sun J,Zhang Z J,et al. LLM-SmartAudit: Advanced Smart Contract Vulnerability Detection [PP/OL].(2024-10-12).https://arxiv.org/abs/2410.09381.
- [19] Xu C,Xu H Y,Zhu L H,et al. Enhanced Smart Contract Vulnerability Detection via Graph Neural Networks: Achieving High Accuracy and Efficiency [J].IEEE Transactions on Software Engineering,2025,51(6):1854-1865.
- [20] Mandana E,Vlahavas G,Vakali A. EVuLLM: Ethereum Smart Contract Vulnerability Detection Using Large Language Models [J/OL].Electronics,2025,14(16):3226.https://doi.org/10.3390/electronics14163226.
- [21] Luo F,Luo R J,Chen T,et al. SCVHunter: Smart Contract Vulnerability Detection Based on Heterogeneous Graph Attention Network [C]//Proceedings of the IEEE/ACM 46th International Conference on Software Engineering,2024:1-13.
- [22] Tereshchenko O,Komleva N. Vulnerability Detection of Smart Contracts Based on Bidirectional GRU and Attention Mechanism [C]//Information and Communication Technologies in Education, Research, and Industrial Applications,2023:276-287.
- [23] Li Y A,Guo R,Wang G P,et al. An Efficient Detection Model for Smart Contract Reentrancy Vulnerabilities [C]//Smart Computing and Communication,2023:350-359.
- [24] Wu H J,Zhang Z,Wang S W,et al. Peculiar: Smart Contract Vulnerability Detection Based on Crucial Data Flow Graph and Pre-Training Techniques [C]//2021 IEEE 32nd International Symposium on Software Reliability Engineering (ISSRE),2021:378-389.
- [25] Chen Y Z,Sun Z Y,Gong Z H,et al. Improving Smart Contract Security with Contrastive Learning-Based Vulnerability Detection [C]//Proceedings of the IEEE/ACM 46th International Conference on Software Engineering,2024:1-11.
Funding
Basic and Applied Basic Research Project of Guangzhou Science and Technology Bureau (202102020637); Open Project of Guangdong Engineering Research Center on Data Security Governance and Privacy Computing (DSGPC20250202)
About the authors
Yang Xiai (1983-), female, Han ethnicity, from Chaozhou, Guangdong, senior engineer, bachelor's degree, research interests include science and technology management, commercialization of research outcomes and digital asset transaction security; Li Shilong (May 2000-), male, Han ethnicity, from Liaocheng, Shandong, master's student, research interests include blockchain security; Xing Yong (March 1981-), male, Han ethnicity, from Jiangsu, vice president of Boshi Technology (Group), general manager of the Ecosystem Cooperation Center, concurrently deputy secretary-general of the Guangdong Doctoral Innovation Development Promotion Association, vice chairman of the Guangdong Jiangsu Chamber of Commerce, master's student, research interests include industrial ecosystem collaboration and commercialization of scientific and technological achievements; Hu Yu (February 1995-), male, Han ethnicity, from Deyang, Sichuan, university-appointed associate professor, doctoral student, research interests include unsupervised machine learning, high-dimensional data mining, graph neural networks, domain adaptation and bioinformatics data analysis; Corresponding author: Jiang Siyu (April 1992-), female, Manchu ethnicity, from Guangzhou, Guangdong, associate professor, master's supervisor, doctoral student, research interests include transfer learning, machine learning, intelligent software engineering and software defect prediction.