Detecting Nondeterministic Payment Bugs in Ethereum Smart Contracts
The term “smart contracts” has become ubiquitous to describe an enormous number of programs uploaded to the popular Ethereum blockchain system. Despite rapid growth of the smart contract ecosystem, errors and exploitations have been constantly reported from online contract systems, which has put financial stability at risk with losses totaling millions of US dollars. Most existing research focuses on pinpointing specific types of vulnerabilities using known patterns. However, due to the lack of awareness of the inherent nondeterminism in the Ethereum blockchain system and how it affects the funds transfer of smart contracts, there can be unknown vulnerabilities that may be exploited by attackers to access numerous online smart contracts.
In this paper, we introduce a methodical approach to understanding the inherent nondeterminism in the Ethereum blockchain system and its (unwanted) influence on contract payments. We show that our new focus on nondeterminism-related smart contract payment bugs captures the root causes of many common vulnerabilities without relying on any known patterns and also encompasses recently disclosed issues that are not handled by existing research. To do so, we introduce techniques to systematically model components in the contract execution context and to expose various nondeterministic factors that are not yet fully understood. We further study how these nondeterministic factors impact contract funds transfer using information flow tracking. The technical challenge of detecting nondeterministic payments lies in discovering the contract global variables subtly affected by read-write hazards because of unpredictable transaction scheduling and external callee behavior. We show how to augment and instrument a contract program into a representation that simulates the execution of a large subset of the contract behavior. The instrumented code is then analyzed to flag nondeterministic global variables using off-the-shelf model checkers.
We implement the proposed techniques as a practical tool named NPChecker (Nondeterministic Payment Checker) and evaluate it on 30K online contracts (3,075 distinct) collected from the Ethereum mainnet. NPChecker has successfully detected nondeterministic payments in 1,111 online contracts with reasonable cost. Further investigation reports high precision of NPChecker (only four false positives in a manual study of 50 contracts). We also show that NPChecker unveils contracts vulnerable to recently-disclosed attack vectors. NPChecker can identify all six new vulnerabilities or variants of common smart contract vulnerabilities that are missed by existing research relying on a “contract vulnerability checklist.”
Fri 25 OctDisplayed time zone: Beirut change
11:00 - 12:30
Repair & TransformationOOPSLA at Templars
Chair(s): Bor-Yuh Evan Chang University of Colorado Boulder | Amazon
|Detecting Nondeterministic Payment Bugs in Ethereum Smart Contracts|
Shuai Wang Hong Kong University of Science and Technology, Chengyu Zhang East China Normal University, Zhendong Su ETH ZurichDOI
|Automatic Repair of Regular Expressions|
Rong Pan University of Texas at Austin, Qinheping Hu University of Wisconsin, Madison, Gaowei Xu University of Wisconsin Madison, Loris D'Antoni University of Wisconsin MadisonDOI Pre-print
|Getafix: Learning to Fix Bugs Automatically|
Johannes Bader Facebook, Andrew Scott Facebook, Michael Pradel University of Stuttgart, Satish Chandra FacebookDOI Pre-print
|IntelliMerge: A Refactoring-Aware Software Merging Technique|
Bo Shen Peking University, Wei Zhang Peking University, Haiyan Zhao Peking University, Guangtai Liang Huawei Technologies Co. Ltd, Zhi Jin Peking University, Qianxiang Wang Huawei Technologies Co. LtdDOI