OptimalFix: An Automated Framework for Fixing Vulnerabilities in Smart Contracts Effectively
摘要
Ethereum smart contracts have attracted significant attention in recent years, but their security vulnerabilities could result in substantial financial losses, highlighting the importance of detecting and patching these vulnerabilities. However, recent research primarily focuses on vulnerability detection rather than notable repair tools, which could result in high costs for manual repair. To address this challenge, the paper introduces OptimalFix, a novel framework capable of automatically generating security patches for vulnerable smart contracts. OptimalFix employs a template-based approach to design different patch strategies for various vulnerabilities and uses program analysis for false positive filtering and data dependency analysis, thereby selecting the most optimal patch template to generate patches. The process not only enhances the accuracy and effectiveness of the patches but also strives to minimize the increase in gas consumption of the smart contract after repairs. We evaluate OptimalFix on three datasets, successfully fixing 92.3% of the vulnerabilities, with an average cost of only 393 milliseconds and a 6.7% increase in gas consumption.