Beyond “Protected” and “Private”: An Empirical Security Analysis of Custom Function Modifiers in Smart Contracts

Yuzhou FANG, Daoyuan WU*, Xiao YI, Shuai WANG*, Yufan CHEN, Mengjie CHEN, Yang LIU, Lingxiao JIANG

*Corresponding author for this work

Research output: Book Chapters | Papers in Conference ProceedingsConference paper (refereed)Researchpeer-review

14 Citations (Scopus)

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 languageEnglish
Title of host publicationISSTA 2023: Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis
EditorsRené JUST, Gordon FRASER
PublisherAssociation for Computing Machinery, Inc
Pages1157-1168
Number of pages12
ISBN (Electronic)9798400702211
DOIs
Publication statusPublished - 13 Jul 2023
Externally publishedYes
Event32nd ACM SIGSOFT International Symposium on Software Testing and Analysis - Seattle, United States
Duration: 17 Jul 202321 Jul 2023

Conference

Conference32nd ACM SIGSOFT International Symposium on Software Testing and Analysis
Abbreviated titleISSTA 2023
Country/TerritoryUnited States
CitySeattle
Period17/07/2321/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

Fingerprint

Dive into the research topics of 'Beyond “Protected” and “Private”: An Empirical Security Analysis of Custom Function Modifiers in Smart Contracts'. Together they form a unique fingerprint.

Cite this