sGuard+: Machine Learning Guided Rule-Based Automated Vulnerability Repair on Smart Contracts
Open Access
- 4 June 2024
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Software Engineering and Methodology
- Vol. 33 (5) , 1-55
Abstract
Smart contracts are becoming appealing targets for hackers because of the vast amount of cryptocurrencies under their control. Asset loss due to the exploitation of smart contract codes has increased significantly in recent years. To guarantee that smart contracts are vulnerability-free, there are many works to detect the vulnerabilities of smart contracts, but only a few vulnerability repair works have been proposed. Repairing smart contract vulnerabilities at the source code level is attractive as it is transparent to users, whereas existing repair tools, such as SCRepair and sGuard , suffer from many limitations: (1) ignoring the code of vulnerability prevention; (2) possibly applying the repair to the wrong statements and changing the original business logic of smart contracts; and (3) showing poor performance in terms of time and gas overhead. In this work, we propose machine learning guided rule-based automated vulnerability repair on smart contracts to improve the effectiveness and efficiency of sGuard . To address the limitations mentioned above, we design the features that characterize both the symptoms of vulnerabilities and the methods of vulnerability prevention to learn various vulnerability patterns and reduce false positives. Additionally, a fine-grained localization algorithm is designed by traversing the nodes of the abstract syntax tree, and we refine and extend the repair rules of sGuard to preserve the original business logic of smart contracts and support new vulnerability types. Our tool, named sGuard+ , reduces time overhead based on machine learning models, and reduces gas overhead by fewer code changes and precise patching. In our experiment, we collect a publicly available vulnerability dataset from CVE, SWC, and SmartBugs Curated as a ground truth for evaluations. Overall, sGuard+ repairs more vulnerabilities with less time and gas overhead than state-of-the-art tools. Furthermore, we reproduce about 9,000 historical transactions for regression testing. It is shown that sGuard+ has no impact on the original business logic of smart contracts.Keywords
Funding Information
- Anhui Provincial Department of Science and Technology (202103a05020009)
- National Natural Science Foundation of China (61972373)
- Basic Research Program of Jiangsu Province (BK20201192)
- CAS Pioneer Hundred Talents Program of China
- Ministry of Education, Singapore under its Academic Research Fund Tier 3 (MOET32020-0004)
This publication has 68 references indexed in Scilit:
- A Massive Analysis of Ethereum Smart Contracts Empirical Study and Code MetricsIEEE Access, 2019
- A Survey of Symbolic Execution TechniquesACM Computing Surveys, 2018
- Automatic Software Repair: A SurveyIEEE Transactions on Software Engineering, 2017
- Software Vulnerability Analysis and Discovery Using Machine-Learning and Data-Mining TechniquesACM Computing Surveys, 2017
- Nopol: Automatic Repair of Conditional Statement Bugs in Java ProgramsIEEE Transactions on Software Engineering, 2016
- A random forest guided tourTEST, 2016
- Characterizing concept driftData Mining and Knowledge Discovery, 2016
- A few useful things to know about machine learningCommunications of the ACM, 2012
- GenProg: A Generic Method for Automatic Software RepairIEEE Transactions on Software Engineering, 2011
- An introduction to decision tree modelingJournal of Chemometrics, 2004