Skip to main navigation Skip to search Skip to main content

Using My Functions Should Follow My Checks: Understanding and Detecting Insecure OpenZeppelin Code in Smart Contracts

  • Han LIU
  • , Daoyuan WU*
  • , Yuqiang SUN
  • , Haijun WANG
  • , Kaixuan LI
  • , Yang LIU
  • , Yixiang CHEN
  • *Corresponding author for this work

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

Abstract

OpenZeppelin is a popular framework for building smart contracts. It provides common libraries (e.g., SafeMath), implementations of Ethereum standards (e.g., ERC20), and reusable components for access control and upgradability. However, unlike traditional software libraries, which are typically imported as static linking libraries or dynamic loading libraries, OpenZeppelin is utilized by Solidity contracts in the form of source code. As a result, developers often make custom modifications to their copies of OpenZeppelin code, which may lead to unintended security consequences. In this paper, we conduct the first systematic study on the security of OpenZeppelin code used in real-world contracts. Specifically, we focus on the security checks in the official OpenZeppelin library and examine whether they are faithfully enforced in the relevant OpenZeppelin functions of real contracts. To this end, we propose a novel tool named ZepScope that comprises two components: MINER and CHECKER. First, MINER analyzes the official OpenZeppelin functions to extract the facts of explicit checks (i.e., the checks defined within the functions) and implicit checks (i.e., the conditions of calling the functions). Second, based on the facts extracted by MINER, CHECKER examines real contracts to identify their OpenZeppelin functions, match their checks with those in the facts, and validate the consequences for those inconsistent checks. By overcoming multiple challenges in developing ZepScope, we obtain not only the first taxonomy of OpenZeppelin checks but also the comprehensive results of checking the top 35, 882 contracts from three mainstream blockchains.

Original languageEnglish
Title of host publicationSEC '24: Proceedings of the 33rd USENIX Conference on Security Symposium
PublisherUSENIX Association
Pages3585-3601
Number of pages17
ISBN (Electronic)9781939133441
Publication statusPublished - 14 Aug 2024
Externally publishedYes
Event33rd USENIX Security Symposium - Philadelphia, United States
Duration: 14 Aug 202416 Aug 2024

Conference

Conference33rd USENIX Security Symposium
Country/TerritoryUnited States
CityPhiladelphia
Period14/08/2416/08/24

Bibliographical note

Acknowledgements:
We thank the anonymous shepherd and reviewers for their constructive feedback.

Publisher Copyright:
© USENIX Security Symposium 2024.All rights reserved.

Funding

This research is supported by the National Research Foundation, Singapore, and DSO National Laboratories under the AI Singapore Programme (AISG Award No: AISG2-GC-2023-008), the National Research Foundation, Singapore, and the Cyber Security Agency under its National Cybersecurity R&D Programme (NCRP25-P04-TAICeN). Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not reflect the views of National Research Foundation, Singapore and Cyber Security Agency of Singapore.

Fingerprint

Dive into the research topics of 'Using My Functions Should Follow My Checks: Understanding and Detecting Insecure OpenZeppelin Code in Smart Contracts'. Together they form a unique fingerprint.

Cite this