EDSCVD: Enhanced Dual-Channel Smart Contract Vulnerability Detection Method
Abstract
:1. Introduction
- Pre-training enhancement: We use BERT to replace the traditional Word2vec pre-trained model to improve the performance and adaptability of the pre-processing of contract source code.
- Symmetry sample enhancement: We utilized the adversarial training method FGM (Fast Gradient Method) in the field of smart contract vulnerability detection. By utilizing FGM on word embeddings to generate symmetric adversarial samples, the model can better resist the attack of adversarial samples and enhance robustness and defense capabilities.
- Feature extraction enhancement: We propose a dual-channel model that optimizes the traditional downstream BiLSTM network model by adding CNN in parallel, which cannot only extract the local features of the contract source code but also retain its temporal information.
- We conducted experimental comparisons of EDSCVD with three traditional methods and two deep learning methods on the self-built SYSCD dataset. The experimental results show that our method with three enhancements exhibits outstanding detection performance in detecting reentrancy vulnerabilities, timestamp dependencies, and integer overflow vulnerabilities, with F1 scores of 96.06%, 95.97%, and 79.44%, respectively. These results surpass those achieved by existing methods.
2. Related Work
2.1. Smart Contract Security Vulnerabilities
2.1.1. Reentrancy
2.1.2. Timestamp Dependency
2.1.3. Integer Overflow
2.2. Traditional Methods
2.3. The Integration and Application of Deep Learning Networks
3. Our Method
3.1. Pre-Training Enhancement
3.1.1. Smart Contract Fragment Representation
3.1.2. BERT
3.2. Symmetric Sample Enhancement
Algorithm 1 Adversarial Training Methods FGM |
|
3.3. Feature Extraction Enhancement
3.3.1. Dual-Channel Network Architecture
Algorithm 2 Dual-Channel Network Architecture |
|
3.3.2. Multi-Head Attention Mechanisms
3.4. Final Detection
4. Experimental Analysis
4.1. Datasets
4.2. Experimental Settings
4.3. Evaluation Metrics
4.4. Comparative Experiments
4.4.1. Comparison of Reentrancy Vulnerability Detection
4.4.2. Comparison of Timestamp Dependency Vulnerability Detection
4.4.3. Comparison of Integer Overflow Vulnerability Detection
4.5. Ablation Experiments
5. Future Prospects and Suggestions
- 1.
- Build authoritative datasets. Future work can be dedicated to collecting more data on unknown vulnerabilities to build a comprehensive and unified form of dataset. This can be accomplished by expanding on existing datasets to help better train and evaluate deep learning models.
- 2.
- Establish a community platform. In the future, communication and sharing can be carried out through the smart contract vulnerability detection community platform. This will encourage researchers to share vulnerability samples, attack scenarios and detection experience. We can better discover and understand unknown vulnerabilities.
- 3.
- Explore advanced methods. We can utilize more advanced graph neural networks or large models for vulnerability detection. These models can process longer input sequences but also possess stronger representation learning capabilities, allowing for a deeper capture of semantic information in contract codes.
- 4.
- Research vulnerability remediation strategies. Currently, relevant research is still mainly focused on the detection of contract vulnerabilities. In the future, security research can be conducted on vulnerability contracts to help relevant researchers understand the logic behind contract vulnerabilities.
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
EDSCVD | An enhanced dual-channel smart contract vulnerability detection method |
BERT | Bidirectional Encoder Representations from Transformers |
FGM | Fast Gradient Method |
BiLSTM | Bi-directional Long Short-Term Memory |
CNN | Convolutional Neural Networks |
NLP | Natural Language Processing |
References
- Nakamoto, S. Bitcoin: A peer-to-peer electronic cash system. Satoshi Nakamoto 2008, 1, 21260. [Google Scholar]
- Guo, H.; Yu, X. A survey on blockchain technology and its security. Blockchain Res. Appl. 2022, 3, 100067. [Google Scholar] [CrossRef]
- Rahman, M.S.; Chamikara, M.; Khalil, I.; Bouras, A. Blockchain-of-blockchains: An interoperable blockchain platform for ensuring IoT data integrity in smart city. J. Ind. Inf. Integr. 2022, 30, 100408. [Google Scholar] [CrossRef]
- Szabo, N. Smart contracts: Building blocks for digital markets. Extropy J. Transhumanist Thought 1996, 18, 28. [Google Scholar]
- Zou, W.; Lo, D.; Kochhar, P.S.; Le, X.B.D.; Xia, X.; Feng, Y.; Chen, Z.; Xu, B. Smart contract development: Challenges and opportunities. IEEE Trans. Softw. Eng. 2019, 47, 2084–2106. [Google Scholar] [CrossRef]
- Zheng, Z.; Xie, S.; Dai, H.N.; Chen, W.; Chen, X.; Weng, J.; Imran, M. An overview on smart contracts: Challenges, advances and platforms. Future Gener. Comput. Syst. 2020, 105, 475–491. [Google Scholar] [CrossRef]
- Chang, V.; Baudier, P.; Zhang, H.; Xu, Q.; Zhang, J.; Arami, M. How Blockchain can impact financial services—The overview, challenges and recommendations from expert interviewees. Technol. Forecast. Soc. Chang. 2020, 158, 120166. [Google Scholar] [CrossRef]
- Javaid, M.; Haleem, A.; Singh, R.P.; Suman, R.; Khan, S. A review of Blockchain Technology applications for financial services. Benchcouncil Trans. Benchmarks Stand. Eval. 2022, 2, 100073. [Google Scholar] [CrossRef]
- Queiroz, M.M.; Telles, R.; Bonilla, S.H. Blockchain and supply chain management integration: A systematic review of the literature. Supply Chain. Manag. Int. J. 2020, 25, 241–254. [Google Scholar] [CrossRef]
- Esmaeilian, B.; Sarkis, J.; Lewis, K.; Behdad, S. Blockchain for the future of sustainable supply chain management in Industry 4.0. Resour. Conserv. Recycl. 2020, 163, 105064. [Google Scholar] [CrossRef]
- De Giovanni, P. Blockchain and smart contracts in supply chain management: A game theoretic model. Int. J. Prod. Econ. 2020, 228, 107855. [Google Scholar] [CrossRef]
- Huo, R.; Zeng, S.; Wang, Z.; Shang, J.; Chen, W.; Huang, T.; Wang, S.; Yu, F.R.; Liu, Y. A comprehensive survey on blockchain in industrial internet of things: Motivations, research progresses, and future challenges. IEEE Commun. Surv. Tutor. 2022, 24, 88–122. [Google Scholar] [CrossRef]
- Ferrag, M.A.; Shu, L. The performance evaluation of blockchain-based security and privacy systems for the Internet of Things: A tutorial. IEEE Internet Things J. 2021, 8, 17236–17260. [Google Scholar] [CrossRef]
- Khan, A.A.; Laghari, A.A.; Shaikh, Z.A.; Dacko-Pikiewicz, Z.; Kot, S. Internet of Things (IoT) security with blockchain technology: A state-of-the-art review. IEEE Access 2022, 10, 122679–122695. [Google Scholar] [CrossRef]
- Yaqoob, I.; Salah, K.; Jayaraman, R.; Al-Hammadi, Y. Blockchain for healthcare data management: Opportunities, challenges, and future recommendations. Neural Comput. Appl. 2022, 34, 11475–11490. [Google Scholar] [CrossRef]
- Sookhak, M.; Jabbarpour, M.R.; Safa, N.S.; Yu, F.R. Blockchain and smart contract for access control in healthcare: A survey, issues and challenges, and open issues. J. Netw. Comput. Appl. 2021, 178, 102950. [Google Scholar] [CrossRef]
- Hussien, H.M.; Yasin, S.M.; Udzir, N.I.; Ninggal, M.I.H.; Salman, S. Blockchain technology in the healthcare industry: Trends and opportunities. J. Ind. Inf. Integr. 2021, 22, 100217. [Google Scholar] [CrossRef]
- Baghani, A.S.; Rahimpour, S.; Khabbazian, M. The DAO induction attack: Analysis and countermeasure. IEEE Internet Things J. 2021, 9, 4875–4887. [Google Scholar] [CrossRef]
- Homoliak, I.; Perešíni, M. SoK: Cryptocurrency wallets—A security review and classification based on authentication factors. In Proceedings of the 2024 IEEE International Conference on Blockchain and Cryptocurrency (ICBC), Dublin, Ireland, 27–31 May 2024; pp. 1–8. [Google Scholar]
- He, D.; Ding, K.; Chan, S.; Guizani, M. Unknown threats detection methods of smart contracts. IEEE Internet Things J. 2023, 11, 4430–4441. [Google Scholar] [CrossRef]
- Prasad, B.; Ramachandram, S. Prevention and detection mechanisms for re-entrancy attack and king of ether throne attack for ethereum smart contracts. Ing. Syst. D’Inform. 2022, 27, 725. [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]
- Zhuang, Y.; Liu, Z.; Qian, P.; Liu, Q.; Wang, X.; He, Q. Smart contract vulnerability detection using graph neural networks. In Proceedings of the Twenty-Ninth International Conference on International Joint Conferences on Artificial Intelligence, Yokohama, Japan, 7–15 January 2021; pp. 3283–3290. [Google Scholar]
- Tang, X.; Du, Y.; Lai, A.; Zhang, Z.; Shi, L. Deep learning-based solution for smart contract vulnerabilities detection. Sci. Rep. 2023, 13, 20106. [Google Scholar] [CrossRef]
- Li, B.; Pan, Z.; Hu, T. Redefender: Detecting reentrancy vulnerabilities in smart contracts automatically. IEEE Trans. Reliab. 2022, 71, 984–999. [Google Scholar] [CrossRef]
- He, D.; Wu, R.; Li, X.; Chan, S.; Guizani, M. Detection of vulnerabilities of blockchain smart contracts. IEEE Internet Things J. 2023, 10, 12178–12185. [Google Scholar] [CrossRef]
- Sun, J.; Huang, S.; Zheng, C.; Wang, T.; Zong, C.; Hui, Z. Mutation testing for integer overflow in ethereum smart contracts. Tsinghua Sci. Technol. 2021, 27, 27–40. [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. Inf. Softw. Technol. 2023, 159, 107221. [Google Scholar] [CrossRef]
- Kim, H.M.; Bock, G.W.; Lee, G. Predicting Ethereum prices with machine learning based on Blockchain information. Expert Syst. Appl. 2021, 184, 115480. [Google Scholar] [CrossRef]
- Zhang, H.; Wang, S.; Li, H.; Chen, T.H.; Hassan, A.E. A study of c/c++ code weaknesses on stack overflow. IEEE Trans. Softw. Eng. 2021, 48, 2359–2375. [Google Scholar] [CrossRef]
- Baldoni, R.; Coppa, E.; D’elia, D.C.; Demetrescu, C.; Finocchi, I. A survey of symbolic execution techniques. ACM Comput. Surv. (CSUR) 2018, 51, 1–39. [Google Scholar] [CrossRef]
- Luu, L.; Chu, D.H.; Olickel, H.; Saxena, P.; Hobor, A. Making smart contracts smarter. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security; ACM: New York, NY, USA, 2016; pp. 254–269. [Google Scholar]
- 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 ACM/IEEE 42nd International Conference on Software Engineering, Seoul, Republic of Korea, 5–11 October 2020; pp. 530–541. [Google Scholar]
- Tsankov, P.; Dan, A.; Drachsler-Cohen, D.; Gervais, A.; Buenzli, F.; Vechev, M. Securify: Practical security analysis of smart contracts. In Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security, Toronto, ON, Canada, 15–19 October 2018; pp. 67–82. [Google Scholar]
- Nam, W.; Kil, H. Formal verification of blockchain smart contracts via atl model checking. IEEE Access 2022, 10, 8151–8162. [Google Scholar] [CrossRef]
- Kalra, S.; Goel, S.; Dhawan, M.; Sharma, S. Zeus: Analyzing safety of smart contracts. In Proceedings of the Ndss, San Diego, CA, USA, 18–21 February 2018; pp. 1–12. [Google Scholar]
- Permenev, A.; Dimitrov, D.; Tsankov, P.; Drachsler-Cohen, D.; Vechev, M. Verx: Safety verification of smart contracts. In Proceedings of the 2020 IEEE Symposium on Security and Privacy (SP), Francisco, CA, USA, 18–20 May 2020; pp. 1661–1677. [Google Scholar]
- Hildenbrandt, E.; Saxena, M.; Rodrigues, N.; Zhu, X.; Daian, P.; Guth, D.; Moore, B.; Park, D.; Zhang, Y.; Stefanescu, A.; et al. Kevm: A complete formal semantics of the ethereum virtual machine. In Proceedings of the 2018 IEEE 31st Computer Security Foundations Symposium (CSF), Oxford, UK, 9–12 July 2018; pp. 204–217. [Google Scholar]
- Liao, J.W.; Tsai, T.T.; He, C.K.; Tien, C.W. Soliaudit: Smart contract vulnerability assessment based on machine learning and fuzz testing. In Proceedings of the 2019 Sixth International Conference on Internet of Things: Systems, Management and Security (IOTSMS), Granada, Spain, 22–25 October 2019; pp. 458–465. [Google Scholar]
- Jiang, B.; Liu, Y.; Chan, W.K. Contractfuzzer: Fuzzing smart contracts for vulnerability detection. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, Montpellier, France, 3–7 September 2018; pp. 259–269. [Google Scholar]
- He, J.; Balunović, M.; Ambroladze, N.; Tsankov, P.; Vechev, M. Learning to fuzz from symbolic execution with application to smart contracts. In Proceedings of the 2019 ACM SIGSAC Conference on Computer and Communications Security, London, UK, 11–15 November 2019; pp. 531–548. [Google Scholar]
- Fei, J.; Chen, X.; Zhao, X. MSmart: Smart contract vulnerability analysis and improved strategies based on smartcheck. Appl. Sci. 2023, 13, 1733. [Google Scholar] [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), Montreal, QC, Canada, 27 May 2019; pp. 8–15. [Google Scholar]
- Lin, G.; Wen, S.; Han, Q.L.; Zhang, J.; Xiang, Y. Software vulnerability detection using deep neural networks: A survey. Proc. IEEE 2020, 108, 1825–1848. [Google Scholar] [CrossRef]
- Tang, W.; Tang, M.; Ban, M.; Zhao, Z.; Feng, M. CSGVD: A deep learning approach combining sequence and graph embedding for source code vulnerability detection. J. Syst. Softw. 2023, 199, 111623. [Google Scholar] [CrossRef]
- 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]
- Zhen, Z.; Zhao, X.; Zhang, J.; Wang, Y.; Chen, H. DA-GNN: A smart contract vulnerability detection method based on Dual Attention Graph Neural Network. Comput. Netw. 2024, 242, 110238. [Google Scholar] [CrossRef]
- Acheampong, F.A.; Nunoo-Mensah, H.; Chen, W. Transformer models for text-based emotion detection: A review of BERT-based approaches. Artif. Intell. Rev. 2021, 54, 5789–5829. [Google Scholar] [CrossRef]
- Kumar, P.; Raman, B. A BERT based dual-channel explainable text emotion recognition system. Neural Netw. 2022, 150, 392–407. [Google Scholar] [CrossRef]
- Miyato, T.; Dai, A.M.; Goodfellow, I. Adversarial training methods for semi-supervised text classification. arXiv 2016, arXiv:1605.07725. [Google Scholar]
Methods | Years | Advantages | Disadvantages | Literature |
---|---|---|---|---|
BiLSTM-att | 2020 | simple structure, easy to understand | poor feature extraction, poor generalizability | [22] |
GNNs | 2020 | novelty, automation | poor feature extraction, hard understand | [23] |
SPCBIG-EC | 2022 | novelty, rich feature extraction | model complexity, low deployment efficiency | [46] |
DA-GNN | 2024 | novelty, good generalization | model complexity, hard understand | [47] |
Lightning Cat | 2023 | automation, easy to understand | low deployment efficiency, limited scalability | [24] |
Vulnerability | Vulnerability Characteristics |
---|---|
Reentrancy | call.value(), fallback() |
Timestamp Dependency | block.number, now, or block.timestamp |
Integer Overflow | integer variables |
Vulnerability | Methods | Performance Index | |||
---|---|---|---|---|---|
Pre (%) | Rec (%) | F1 (%) | Acc (%) | ||
Reentrancy | Oyente | 63.16 | 58.90 | 51.81 | 55.14 |
SmartCheck | 54.21 | 41.05 | 55.71 | 47.27 | |
Mythril | 51.58 | 42.25 | 37.04 | 39.48 | |
BiLSTM-Att | 91.05 | 87.84 | 89.04 | 88.76 | |
SPCBIG-EC | 92.63 | 89.19 | 91.66 | 90.05 | |
EDSCVD | 96.85 | 96.05 | 96.05 | 96.05 | |
Timestamp Dependency | Oyente | 59.75 | 45.99 | 34.43 | 39.38 |
SmartCheck | 58.09 | 46.97 | 31.96 | 38.04 | |
Mythril | 53.94 | 40.27 | 31.09 | 35.09 | |
BiLSTM-Att | 92.32 | 96.92 | 88.00 | 92.24 | |
SPCBIG-EC | 93.15 | 95.74 | 90.72 | 93.16 | |
EDSCVD | 96.06 | 98.39 | 93.34 | 95.97 | |
Integer Overflow | Oyente | 56.63 | 35.48 | 49.11 | 41.20 |
SmartCheck | 44.75 | 46.88 | 31.25 | 37.50 | |
Mythril | 49.72 | 58.33 | 34.65 | 43.47 | |
BiLSTM-Att | 83.43 | 82.35 | 66.67 | 73.68 | |
SPCBIG-EC | 83.98 | 84.62 | 67.69 | 75.21 | |
EDSCVD | 87.85 | 92.39 | 69.67 | 79.44 |
Vulnerability | Methods | Performance Index | |||
---|---|---|---|---|---|
Pre (%) | Rec (%) | F1 (%) | Acc (%) | ||
Reentrancy | BERT | 94.21 | 95.77 | 89.47 | 92.53 |
BBMA | 94.74 | 94.60 | 92.11 | 93.34 | |
BDCMA | 95.26 | 93.51 | 94.74 | 94.21 | |
EDSCVD | 96.85 | 96.05 | 96.05 | 96.05 | |
Timestamp Dependency | BERT | 93.98 | 98.19 | 89.26 | 93.74 |
BBMA | 93.78 | 98.18 | 89.26 | 93.51 | |
BDCMA | 94.81 | 98.62 | 90.91 | 94.62 | |
EDSCVD | 96.06 | 98.39 | 93.34 | 95.97 | |
Integer Overflow | BERT | 84.25 | 89.16 | 60.66 | 72.20 |
BBMA | 85.36 | 87.10 | 66.40 | 75.35 | |
BDCMA | 86.74 | 89.36 | 68.85 | 77.77 | |
EDSCVD | 87.85 | 92.39 | 69.67 | 79.44 |
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 (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Wu, H.; Peng, Y.; He, Y.; Lu, S. EDSCVD: Enhanced Dual-Channel Smart Contract Vulnerability Detection Method. Symmetry 2024, 16, 1381. https://doi.org/10.3390/sym16101381
Wu H, Peng Y, He Y, Lu S. EDSCVD: Enhanced Dual-Channel Smart Contract Vulnerability Detection Method. Symmetry. 2024; 16(10):1381. https://doi.org/10.3390/sym16101381
Chicago/Turabian StyleWu, Huaiguang, Yibo Peng, Yaqiong He, and Siqi Lu. 2024. "EDSCVD: Enhanced Dual-Channel Smart Contract Vulnerability Detection Method" Symmetry 16, no. 10: 1381. https://doi.org/10.3390/sym16101381
APA StyleWu, H., Peng, Y., He, Y., & Lu, S. (2024). EDSCVD: Enhanced Dual-Channel Smart Contract Vulnerability Detection Method. Symmetry, 16(10), 1381. https://doi.org/10.3390/sym16101381