一句话:首次实证刻画以太坊智能合约中 require、if…revert、if…throw 等交易回滚语句的使用模式与安全影响。
智能合约在运行时违反输入约束或安全属性时,需要通过交易回滚语句避免异常后果。以太坊开发者可使用 require、if…revert 和 if…throw 三类回滚语句,但其实际使用方式缺乏系统理解。本文首次对以太坊智能合约中的交易回滚语句进行实证研究:测量了 3,866 个来自热门 DApp 的已验证合约中这些语句的普遍性;人工分析 557 条回滚语句并构建用途分类体系;比较模板合约与对应自定义合约,理解开发者如何定制回滚语句;通过删除回滚语句生成变异合约并与原合约对比,分析其安全影响。研究发现,回滚语句常用于七类权限验证或有效性检查,缺失可能损害合约安全;现有智能合约安全分析器在检测漏洞时无法有效处理这些语句。
Smart contracts are programs stored on blockchains to execute transactions. When input constraints or security properties are violated at runtime, the transaction being executed by a smart contract needs to be reverted to avoid undesirable consequences. On Ethereum, the most popular blockchain that supports smart contracts, developers can choose among three transaction-reverting statements (i.e., require, if…revert, and if…throw) to handle anomalous transactions. While these transaction-reverting statements are vital for preventing smart contracts from exhibiting abnormal behaviors or suffering malicious attacks, there is limited understanding of how they are used in practice. In this work, we perform the first empirical study to characterize transaction-reverting statements in Ethereum smart contracts. We measured the prevalence of these statements in 3,866 verified smart contracts from popular dapps and built a taxonomy of their purposes via manually analyzing 557 transaction-reverting statements. We also compared template contracts and their corresponding custom contracts to understand how developers customize the use of transaction-reverting statements. Finally, we analyzed the security impact of transaction-reverting statements by removing them from smart contracts and comparing the mutated contracts against the original ones. Our study led to important findings. For example, we found that transaction-reverting statements are commonly used to perform seven types of authority verifications or validity checks, and missing such statements may compromise the security of smart contracts. We also found that current smart contract security analyzers cannot effectively handle transaction-reverting statements when detecting security vulnerabilities. Our findings can shed light on further research in the broad area of smart contract quality assurance and provide practical guidance to smart contract developers on the appropriate use of transaction-reverting statements.
DOI 原文 ·
@inproceedings{paperbot6632,
title = {Characterizing Transaction-Reverting Statements in Ethereum Smart Contracts},
author = {Lu Liu and Lili Wei and Wuqi Zhang and Ming Wen and Yepang Liu and Shing-Chi Cheung},
booktitle = {ASE},
year = {2021},
doi = {10.1109/ase51524.2021.9678597}
}