Formal verification of Reentrancy Vulnerability Based on CPN

Yaqiong He, Hanjie Dong, Huaiguang Wu, Qianheng Duan · Research Square · 2022

Abstract A smart contract is a special form of computer program running on a blockchain, which provides a new way to implement financial and business transactions in a free-of-conflicts and transparent environment. In blockchain systems, such as Ethereum, smart contracts can handle and autonomously transfer assets of considerable value to other parties. Hence, it is particularly important to ensure that smart contracts function as intended since bugs or vulnerabilities may lead and indeed have led, to substantial economic losses and erosion of trust for blockchain. While a number of approaches and tools have been developed to find vulnerabilities, formal method presents the highest level of confidence about the security of smart contracts. In this paper, we propose a formal solution to model smart contract based on Colored Petri Net (CPN). Herein we focus on the most common type of security bugs in smart contract, i.e., reentrancy bug, which led to a serious financial loss of around $60 million in 2016. We present a hierarchical CPN modelling method to analyze potential security vulnerabilities at the contract’s source code level. Then modeling analysis methods such as correlation matrix, state space report and state space graph generated by CPN Tools simulation were exploited for formal analysis of smart contracts. The example shows the full state space and wrong path in accordance with our expected results. Finally, the conclusion was verified in the Ethereum network based on Remix platform.

Read the paper · More papers on PaperTik