ReenRepair: Automatic and Semantic Equivalent Repair of Reentrancy in Smart Contracts
Ruiyao Huang,Qingni Shen,Yuchen Wang,Yiqi Wu,Zhonghai Wu,Xiapu Luo,Anbang Ruan
DOI: https://doi.org/10.1016/j.jss.2024.112107
IF: 3.5
2024-01-01
Journal of Systems and Software
Abstract:Reentrancy, the most notorious vulnerability in smart contracts, has attracted extensive attention. To eliminate reentrancy before deploying contracts, there is a need to locate and repair the contracts. However, existing tools still have false alarm locations, destroy original semantics, and have high gas overhead problems. In this work, we proposed a gas-optimized template-based reentrancy repair method with semantic maintenance. We avoid false positive locations from verifying the attack’s effectiveness, using connectivity and read-write dependencies. We design the semantic equivalence check algorithm based on the def-use chain. We optimize the lock and reordering templates for reentrancy repair and add semantic maintenance operations. We implemented our tool, ReenRepair, and compared it with two state-of-the-art detection tools and two repair tools. The results show that ReenRepair yields good location precision, the highest repair rate, and the lowest gas overhead. All semantic changes caused by lock and 89.66% of semantic changes caused by reordering were successfully maintained.