Abstract
A smart contract is a piece of application-layer code running on blockchain ledgers and it provides programmatic logic via transaction-based execution of pre-defined functions. Smart contract functions are by default invokable by any party. To safeguard them, the mainstream smart contract language, i.e., Solidity of the popular Ethereum blockchain, proposed a unique language-level keyword called "modifier,"which allows developers to define custom function access control policies beyond the traditional "protected"and "private"modifiers in classic programming languages. In this paper, we aim to conduct a large-scale security analysis of the modifiers used in real-world Ethereum smart contracts. To achieve this, we design and implement a novel smart contract analysis tool called SoMo. Its main objective is to identify insecure modifiers that can be bypassed from one or more unprotected smart contract functions. This is challenging because of the complicated relationship between modifiers and their variables/functions and the ambiguity of attacker-accessible entry functions. To overcome them, we first propose a new structure, the Modifier Dependency Graph (MDG), to connect all the modifier-related control/data flows. Over MDGs, we then model system variables, generate symbolic path constraints, and iteratively test each candidate entry function. Our extensive evaluation shows that SoMo outperforms the state-of-the-art SPCon tool by detecting all its true positives and correctly avoiding 9 out of 11 false positives. It also achieves high precision of 91.2% when analyzing a large dataset of 62,464 contracts, over 400 of which were identified with bypassable modifiers. Our analysis further reveals three interesting security findings about modifiers and nine major types of modifier usage in the wild. SoMo has been integrated into an online security scanning service, MetaScan.
| Original language | English |
|---|---|
| Title of host publication | ISSTA 2023: Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis |
| Editors | René JUST, Gordon FRASER |
| Publisher | Association for Computing Machinery, Inc |
| Pages | 1157-1168 |
| Number of pages | 12 |
| ISBN (Electronic) | 9798400702211 |
| DOIs | |
| Publication status | Published - 13 Jul 2023 |
| Externally published | Yes |
| Event | 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis - Seattle, United States Duration: 17 Jul 2023 → 21 Jul 2023 |
Conference
| Conference | 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis |
|---|---|
| Abbreviated title | ISSTA 2023 |
| Country/Territory | United States |
| City | Seattle |
| Period | 17/07/23 → 21/07/23 |
Bibliographical note
Acknowledgements:We thank all the reviewers for their detailed and constructive comments. We thank Yue Xue of MetaTrust Labs for helping integrate SoMo into MetaScan.
Publisher Copyright:
© 2023 ACM.
Funding
This work was partially supported by a direct grant (ref. no. 4055127) and a TDLEG grant (ref. no. 4170890) from The Chinese University of Hong Kong, and the Cyber Security Agency under its National Cybersecurity R&D Programme (NCRP25-P04-TAICeN). The HKUST authors were supported in part by RGC RMGS under the contract RMGS22EG02.
Keywords
- Smart Contract Security
- Taint Analysis
- Access Control
- Modifiers