Submitted:
29 December 2023
Posted:
03 January 2024
You are already at the latest version
Abstract
Keywords:
1. Introduction
- We present a Vulnerability Syntax-driven Slice (VSS) method, which simplifies the contract code by removing statements unrelated to vulnerability characteristics and preserving the data and control dependencies in statements.
- We propose a novel Multi-scale Encoder Vulnerability Detection (MEVD) approach to detect vulnerabilities in smart contracts, global structure and local detail features are captured by multi-scale encoders, respectively, to compensate for the lack of feature extraction capability of a single model.
- We have compared MEVD with state-of-the-art vulnerability detection methods. Experimental results show that the proposed MEVD outperforms existing methods for detecting Reentrancy, Timestamp Dependency, and Infinite Loop vulnerabilities.
2. Background
2.1. Smart Contract Basics
2.2. Smart Contract Vulnerabilities
3. Related Work
4. Method
4.1. Overview
4.2. Data Preprocessing
4.2.1. Code Slice Criteria
4.2.2. Code Slice Generation
4.3. MEVD Model
4.3.1. Surface Feature Encoder
4.3.2. Dual-Branch Encoder
- a.
- Base Transformer Encoder (BTE)
- b.
- Detail CNN Encoder (DCE)
4.3.3. Deep Residual Shrinkage Network
4.4. Vulnerability Detection
5. Experiments
5.1. Datasets
5.2. Experimental Settings
5.3. Evaluation Metrics
5.4. Results Analysis
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Alharby, M.; Moorsel, A.V. Blockchain Based Smart Contracts: A Systematic Mapping Study. In Proceedings of the Computer Science & Information Technology (CS & IT); Academy & Industry Research Collaboration Center (AIRCC), August 26 2017; pp. 125–140. [Google Scholar] [CrossRef]
- Gupta, R.; Tanwar, S.; Al-Turjman, F.; Italiya, P.; Nauman, A.; Kim, S.W. Smart Contract Privacy Protection Using AI in Cyber-Physical Systems: Tools, Techniques and Challenges. IEEE Access 2020, 8, 24746–24772. [Google Scholar] [CrossRef]
- Wang, S.; Ouyang, L.; Yuan, Y.; Ni, X.; Han, X.; Wang, F.-Y. Blockchain-Enabled Smart Contracts: Architecture, Applications, and Future Trends. IEEE Trans. Syst. Man Cybern, Syst. 2019, 49, 2266–2277. [Google Scholar] [CrossRef]
- Khan, S.N.; Loukil, F.; Ghedira-Guegan, C.; Benkhelifa, E.; Bani-Hani, A. Blockchain Smart Contracts: Applications, Challenges, and Future Trends. Peer-to-Peer Netw. Appl. 2021, 14, 2901–2925. [Google Scholar] [CrossRef] [PubMed]
- Wu, H.; Dong, H.; He, Y.; Duan, Q. Smart Contract Vulnerability Detection Based on Hybrid Attention Mechanism Model. Applied Sciences 2023, 13, 770. [Google Scholar] [CrossRef]
- Mehar, M.I.; Shier, C.L.; Giambattista, A.; Gong, E.; Fletcher, G.; Sanayhie, R.; Kim, H.M.; Laskowski, M. Understanding a Revolutionary and Flawed Grand Experiment in Blockchain: The DAO Attack. Journal of Cases on Information Technology (JCIT) 2019, 21, 19–32. [Google Scholar] [CrossRef]
- Almakhour, M.; Sliman, L.; Samhat, A.E.; Mellouk, A. Verification of Smart Contracts: A Survey. Pervasive and Mobile Computing 2020, 67, 101227. [Google Scholar] [CrossRef]
- He, D.; Deng, Z.; Zhang, Y.; Chan, S.; Cheng, Y.; Guizani, N. Smart Contract Vulnerability Analysis and Security Audit. IEEE Network 2020, 34, 276–282. [Google Scholar] [CrossRef]
- Chu, H.; Zhang, P.; Dong, H.; Xiao, Y.; Ji, S.; Li, W. A Survey on Smart Contract Vulnerabilities: Data Sources, Detection and Repair. Information and Software Technology 2023, 159, 107221. [Google Scholar] [CrossRef]
- Qian, P.; Liu, Z.; He, Q.; Zimmermann, R.; Wang, X. Towards Automated Reentrancy Detection for Smart Contracts Based on Sequential Models. IEEE Access 2020, 8, 19685–19695. [Google Scholar] [CrossRef]
- Cai, J.; Li, B.; Zhang, J.; Sun, X.; Chen, B. Combine Sliced Joint Graph with Graph Neural Networks for Smart Contract Vulnerability Detection. Journal of Systems and Software 2023, 195, 111550. [Google Scholar] [CrossRef]
- Zhang, L.; Chen, W.; Wang, W.; Jin, Z.; Zhao, C.; Cai, Z.; Chen, H. CBGRU: A Detection Method of Smart Contract Vulnerability Based on a Hybrid Model. Sensors 2022, 22, 3577. [Google Scholar] [CrossRef] [PubMed]
- Wu, H.; Zhang, Z.; Wang, S.; Lei, Y.; Lin, B.; Qin, Y.; Zhang, H.; Mao, X. Peculiar: Smart Contract Vulnerability Detection Based on Crucial Data Flow Graph and Pre-Training Techniques. In Proceedings of the 2021 IEEE 32nd International Symposium on Software Reliability Engineering (ISSRE); IEEE: Wuhan, China, October 2021; pp. 378–389. [Google Scholar] [CrossRef]
- Li, M.; Ren, X.; Fu, H.; Li, Z.; Sun, J. ConvMHSA-SCVD: Enhancing Smart Contract Vulnerability Detection through a Knowledge-Driven and Data-Driven Framework. In Proceedings of the 2023 IEEE 34th International Symposium on Software Reliability Engineering (ISSRE); IEEE: Florence, Italy, 9 October 2023; pp. 578–589. [Google Scholar] [CrossRef]
- Yu, L.; Lu, J.; Liu, X.; Yang, L.; Zhang, F.; Ma, J. PSCVFinder: A Prompt-Tuning Based Framework for Smart Contract Vulnerability Detection. In Proceedings of the 2023 IEEE 34th International Symposium on Software Reliability Engineering (ISSRE); IEEE: Florence, Italy, 9 October 2023; pp. 556–567. [Google Scholar] [CrossRef]
- Atzei, N.; Bartoletti, M.; Cimoli, T. A Survey of Attacks on Ethereum Smart Contracts (Sok). In Proceedings of the Principles of Security and Trust: 6th International Conference, POST 2017, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2017, Uppsala, Sweden, April 22-29, 2017, Proceedings 6; Springer, 2017; pp. 164–186. [CrossRef]
- Liu, Z.; Qian, P.; Wang, X.; Zhuang, Y.; Qiu, L.; Wang, X. Combining Graph Neural Networks with Expert Knowledge for Smart Contract Vulnerability Detection. IEEE Trans. Knowl. Data Eng. 2021, 1–1. [Google Scholar] [CrossRef]
- Jiang, B.; Liu, Y.; Chan, W.K. Contractfuzzer: Fuzzing Smart Contracts for Vulnerability Detection. In Proceedings of the Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering; 2018; pp. 259–269. [CrossRef]
- Tsankov, P.; Dan, A.; Drachsler-Cohen, D.; Gervais, A.; Buenzli, F.; Vechev, M. Securify: Practical Security Analysis of Smart Contracts. In Proceedings of the Proceedings of the 2018 ACM SIGSAC conference on computer and communications security; 2018; pp. 67–82. [CrossRef]
- Luu, L.; Chu, D.-H.; Olickel, H.; Saxena, P.; Hobor, A. Making Smart Contracts Smarter. In Proceedings of the Proceedings of the 2016 ACM SIGSAC conference on computer and communications security; 2016; pp. 254–269. [CrossRef]
- Prechtel, D.; Groß, T.; Müller, T. Evaluating Spread of ‘Gasless Send’in Ethereum Smart Contracts. In Proceedings of the 2019 10th IFIP international conference on new technologies, mobility and security (NTMS); IEEE, 2019; pp. 1–6. [CrossRef]
- Feist, J.; Grieco, G.; Groce, A. Slither: A Static Analysis Framework for Smart Contracts. In Proceedings of the 2019 IEEE/ACM 2nd International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB); IEEE, 2019; pp. 8–15. [CrossRef]
- Yu, X.; Zhao, H.; Hou, B.; Ying, Z.; Wu, B. DeeSCVHunter: A Deep Learning-Based Framework for Smart Contract Vulnerability Detection. In Proceedings of the 2021 International Joint Conference on Neural Networks (IJCNN); IEEE: Shenzhen, China, July 18 2021; pp. 1–8. [CrossRef]
- Liu, Z.; Qian, P.; Wang, X.; Zhu, L.; He, Q.; Ji, S. Smart Contract Vulnerability Detection: From Pure Neural Network to Interpretable Graph Feature and Expert Pattern Fusion. arXiv 2021, arXiv:2106.09282. [Google Scholar] [CrossRef]
- Duy, P.T.; Khoa, N.H.; Quyen, N.H.; Trinh, L.C.; Kien, V.T.; Hoang, T.M.; Pham, V.-H. VulnSense: Efficient Vulnerability Detection in Ethereum Smart Contracts by Multimodal Learning with Graph Neural Network and Language Model. arXiv 2023, arXiv:2309.08474. [Google Scholar]
- Sak, H.; Senior, A.W.; Beaufays, F. Long Short-Term Memory Recurrent Neural Network Architectures for Large Scale Acoustic Modeling. 2014.
- Kipf, T.N.; Welling, M. Semi-Supervised Classification with Graph Convolutional Networks. arXiv 2016, arXiv:1609.02907. [Google Scholar]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, \Lukasz; Polosukhin, I. Attention Is All You Need. Advances in neural information processing systems 2017, 30.
- Zamir, S.W.; Arora, A.; Khan, S.; Hayat, M.; Khan, F.S.; Yang, M.-H. Restormer: Efficient Transformer for High-Resolution Image Restoration. In Proceedings of the 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: New Orleans, LA, USA, June 2022; pp. 5718–5729.
- Ding, X.; Zhang, X.; Ma, N.; Han, J.; Ding, G.; Sun, J. RepVGG: Making VGG-Style ConvNets Great Again. In Proceedings of the 2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: Nashville, TN, USA, June 2021; pp. 13728–13737.
- Zhao, M.; Zhong, S.; Fu, X.; Tang, B.; Pecht, M. Deep Residual Shrinkage Networks for Fault Diagnosis. IEEE Transactions on Industrial Informatics 2019, 16, 4681–4690. [Google Scholar] [CrossRef]
- Zhao, Z.; Bai, H.; Zhang, J.; Zhang, Y.; Xu, S.; Lin, Z.; Timofte, R.; Van Gool, L. CDDFuse: Correlation-Driven Dual-Branch Feature Decomposition for Multi-Modality Image Fusion. In Proceedings of the 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR); IEEE: Vancouver, BC, Canada, June 2023; pp. 5906–5916.
- Mikolov, T.; Sutskever, I.; Chen, K.; Corrado, G.S.; Dean, J. Distributed Representations of Words and Phrases and Their Compositionality. Advances in neural information processing systems 2013, 26. [Google Scholar]
- Zhang, L.; Li, Y.; Jin, T.; Wang, W.; Jin, Z.; Zhao, C.; Cai, Z.; Chen, H. SPCBIG-EC: A Robust Serial Hybrid Model for Smart Contract Vulnerability Detection. Sensors 2022, 22, 4621. [Google Scholar] [CrossRef] [PubMed]
- Durieux, T.; Ferreira, J.F.; Abreu, R.; Cruz, P. Empirical Review of Automated Analysis Tools on 47,587 Ethereum Smart Contracts. In Proceedings of the Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering; June 27 2020; pp. 530–541. [CrossRef]
- Zhuang, Y.; Liu, Z.; Qian, P.; Liu, Q.; Wang, X.; He, Q. Smart Contract Vulnerability Detection Using Graph Neural Network. In Proceedings of the Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence; International Joint Conferences on Artificial Intelligence Organization: Yokohama, Japan, July 2020; pp. 3283–3290.






| Vulnerability | Slice Criteria |
|---|---|
| Reentrancy |
fallback () call.value() a function involving call.value variable: correspond to user balance |
| Timestamp Dependency |
block.timestamp block.number now |
| Infinite Loop |
for while loop self-call function |
| Model parameter | Value |
|---|---|
| Optimizer | Adam |
| Learning rate | [0.0001, 0.005] |
| Dropout rate | 0.5 |
| Batch size | 8 |
| Epochs | 50 |
| Vulnerability | Method | Acc (%) | Pre (%) | Rec (%) | F1 (%) |
|---|---|---|---|---|---|
| Reentrancy | ReChecker | 74.65 | 69.47 | 76.93 | 75.62 |
| DR-GCN | 82.58 | 75.39 | 80.83 | 79.57 | |
| TMP | 86.28 | 78.25 | 84.96 | 80.28 | |
| CGE | 88.32 | 84.15 | 86.77 | 85.64 | |
| MEVD | 92.13 | 89.49 | 90.15 | 89.28 | |
| Timestamp Dependency | ReChecker | 72.68 | 70.86 | 69.24 | 73.21 |
| DR-GCN | 80.21 | 76.54 | 78.86 | 79.04 | |
| TMP | 84.37 | 85.21 | 80.79 | 83.08 | |
| CGE | 87.76 | 86.15 | 82.77 | 84.56 | |
| MEVD | 90.85 | 89.17 | 92.98 | 91.04 | |
| Infinite Loop | ReChecker | 68.79 | 71.63 | 69.41 | 71.33 |
| DR-GCN | 76.55 | 72.25 | 74.21 | 78.62 | |
| TMP | 80.86 | 78.05 | 84.86 | 81.77 | |
| CGE | 85.89 | 82.62 | 83.19 | 83.25 | |
| MEVD | 86.94 | 84.15 | 85.63 | 86.21 |
| Dataset | Acc (%) | Pre (%) | Rec (%) | F1 (%) |
|---|---|---|---|---|
| Reentrancy | 86.32 | 82.94 | 85.61 | 84.49 |
| Timestamp Dependency | 85.21 | 81.54 | 83.86 | 86.24 |
| Infinite Loop | 83.05 | 77.63 | 78.67 | 81.09 |
| VSS +Reentrancy | 92.13 | 89.49 | 90.15 | 89.28 |
| VSS +Timestamp Dependency | 90.85 | 89.17 | 92.98 | 91.04 |
| VSS +Infinite Loop | 86.94 | 84.15 | 85.63 | 86.21 |
| Method | Vulnerability | Acc (%) | Pre (%) | Rec (%) | F1 (%) |
|---|---|---|---|---|---|
|
MEVD-S |
Reentrancy | 88.71 | 84.41 | 83.59 | 85.94 |
| Timestamp Dependency | 85.52 | 83.01 | 89.32 | 86.04 | |
| Infinite Loop | 82.15 | 80.37 | 81.86 | 82.18 | |
|
MEVD-T |
Reentrancy | 84.31 | 81.93 | 82.29 | 80.07 |
| Timestamp Dependency | 82.24 | 80.46 | 85.17 | 82.75 | |
| Infinite Loop | 76.18 | 75.42 | 78.25 | 77.92 | |
|
MEVD-D |
Reentrancy | 89.31 | 86.24 | 85.13 | 84.27 |
| Timestamp Dependency | 85.34 | 83.82 | 87.58 | 85.67 | |
| Infinite Loop | 81.28 | 78.32 | 83.53 | 82.30 | |
|
MEVD |
Reentrancy | 92.13 | 89.49 | 90.15 | 89.28 |
| Timestamp Dependency | 90.85 | 89.17 | 92.98 | 91.04 | |
| Infinite Loop | 86.94 | 84.15 | 85.63 | 86.21 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).