Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/3597503.3623335acmconferencesArticle/Chapter ViewAbstractPublication PagesicseConference Proceedingsconference-collections
research-article

Revealing Hidden Threats: An Empirical Study of Library Misuse in Smart Contracts

Published: 06 February 2024 Publication History

Abstract

Smart contracts are Turing-complete programs that execute on the blockchain. Developers can implement complex contracts, such as auctions and lending, on Ethereum using the Solidity programming language. As an object-oriented language, Solidity provides libraries within its syntax to facilitate code reusability and reduce development complexity. Library misuse refers to the incorrect writing or usage of libraries, resulting in unexpected results, such as introducing vulnerabilities during library development or incorporating an unsafe library during contract development. Library misuse could lead to contract defects that cause financial losses. Currently, there is a lack of research on library misuse. To fill this gap, we collected more than 500 audit reports from the official websites of five audit companies and 223,336 real-world smart contracts from Etherscan to measure library popularity and library misuse. Then, we defined eight general patterns for library misuse; three of them occurring during library development and five during library utilization, which covers the entire library lifecycle. To validate the practicality of these patterns, we manually analyzed 1,018 real-world smart contracts and publicized our dataset. We identified 905 misuse cases across 456 contracts, indicating that library misuse is a widespread issue. Three patterns of misuse are found in more than 50 contracts, primarily due to developers lacking security awareness or underestimating negative impacts. Additionally, our research revealed that vulnerable libraries on Ethereum continue to be employed even after they have been deprecated or patched. Our findings can assist contract developers in preventing library misuse and ensuring the safe use of libraries.

References

[1]
Apr., 2018. Beauty Chain | Address 0xc5d105e63711398af9bbjf092d4b6769c82f793d. https://etherscan.io/address/0xc5d105e63711398af9bbff092d4b6769c82f793d
[2]
Apr., 2018. POSC | Address 0x3d807baa0342b748ec59aa0b01e93f774672f7ac. https://etherscan.io/address/0x3d807baa0342b748ec59aa0b01e93f774672f7ac
[3]
Apr., 2020. Library UniswapV2Router01. https://github.com/Uniswap/v2-periphery/blob/0335e8f7e1bd1e8d8329fd300aea2ef2f36dd19f/contracts/UniswapV2Router01.sol original-date: 2019-12-09T20:17:43Z.
[4]
Apr., 2021. Solidity v0.8.0 Breaking Changes --- Solidity 0.8.19 documentation. https://docs.soliditylang.org/en/v0.8.19/080-breaking-changes.html
[5]
Aug., 2022. Ethereum Development Documentation. https://ethereum.org/en/developers/docs/smart-contracts/testing/#code-audits
[6]
Dec., 2022. Blockchain Consilium - REPORT VERIFICATION V2. https://www.blockchainconsilium.com/verifyreport.html
[7]
Dec., 2022. CertK - Resources. https://www.certik.com/resources/blog
[8]
Dec., 2022. Smart Dec Audit. https://blog.smartdec.net/smart-contracts-security-audits/home
[9]
Feb., 2021. Fei Protocol. https://github.com/fei-protocol/fei-protocol-core/blob/d8aebc2b119739ad1525d5c8861f2480d1610ddb/contracts/bondingcurve/BondingCurve.sol
[10]
Feb., 2021. fei-protocol BondingCurve.sol commit d8aebc2. https://github.com/fei-protocol/fei-protocol-core/blob/d8aebc2b119739ad1525d5c8861f2480d1610ddb/contracts/bondingcurve/BondingCurve.sol
[11]
Feb., 2021. Pre release fix flash attacks by Joeysantoro • Pull Request #81 • fei-protocol/fei-protocol-core. https://github.com/fei-protocol/fei-protocol-core/pull/81
[12]
Jan., 2018. ERC-165: Standard Interface Detection. https://eips.ethereum.org/EIPS/eip-165
[13]
Jan., 2018. OpenZeppelin IERC20.sol. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/b7d60f2f9a849c5c2d59e24062f9c09f3390487a/contracts/token/ERC20/SafeERC20.sol
[14]
Jan., 2019. Ethereum.org. https://www.ethereum.org/
[15]
Jan., 2019. OpenZeppelin ECDSA.sol commit 547a5f2. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/547a5f242a80c7df68015768c8770cc82a5e6058/contracts/cryptography/ECDSA.sol
[16]
Jan., 2019. OpenZeppelin SafeERC20.sol commit fc17a1d. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/fc17a1d9f58b7ca6e2de884769f8b6b362dc0e3c/contracts/token/ERC20/SafeERC20.sol
[17]
Jan., 2023. Ethereum Docs: Smart contract library. https://ethereum.org/en/developers/docs/smart-contracts/libraries
[18]
Jan., 2023. Ethereum Docs: Smart contract library. https://ethereum.org/en/developers/docs/smart-contracts/libraries/#related-tools
[19]
Jan., 2023. openzeppelin-contracts • Github. https://github.com/OpenZeppelin/openzeppelin-contracts
[20]
Jan., 2023. OpenZeppelin Docs. https://docs.openzeppelin.com/
[21]
Jan., 2023. Openzeppelin Docs - Address. https://docs.openzeppelin.com/contracts/4.x/api/utils#Address
[22]
Jan., 2023. Openzeppelin Docs - Counters. https://docs.openzeppelin.com/contracts/4.x/api/utils#Counters
[23]
Jan., 2023. Openzeppelin Docs - ECDSA. https://docs.openzeppelin.com/contracts/4.x/api/utils#ECDSA
[24]
Jan., 2023. Openzeppelin Docs - EnumerableSet. https://docs.openzeppelin.com/contracts/4.x/api/utils#EnumerableSet
[25]
Jan., 2023. Openzeppelin Docs - Math. https://docs.openzeppelin.com/contracts/4.x/api/utils#Math
[26]
Jan., 2023. Openzeppelin Docs - MerkleProof. https://docs.openzeppelin.com/contracts/4.x/api/utils#MerkleProof
[27]
Jan., 2023. Openzeppelin Docs - SafeCast. https://docs.openzeppelin.com/contracts/4.x/api/utils#SafeCast
[28]
Jan., 2023. Openzeppelin Docs - SafeERC20. https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#SafeERC20
[29]
Jan., 2023. Openzeppelin Docs - SafeMath. https://docs.openzeppelin.com/contracts/4.x/api/utils#SafeMath
[30]
Jan., 2023. Openzeppelin Docs - StorageSlot. https://docs.openzeppelin.com/contracts/4.x/api/utils#StorageSlot
[31]
Jan., 2023. Openzeppelin Docs - Strings. https://docs.openzeppelin.com/contracts/4.x/api/utils#Strings
[32]
Jan., 2023. Openzeppelin Github - AddressUpgradeable. https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/contracts/utils/AddressUpgradeable.sol
[33]
Jan., 2023. OpenZeppelin/openzeppelin-contracts • Security Advisories Page. https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories
[34]
Jan., 2023. PeckShield - Industry Leading Blockchain Security Company. https://peckshield.com/#services
[35]
Jan., 2023. Smart Contract Sanctuary. https://github.com/tintinweb/smart-contract-sanctuary
[36]
Jan., 2023. Smart Contracts Audit and Security. https://etherscan.io/directory/Smart_Contracts/Smart_Contracts_Audit_And_Security
[37]
Jul., 2021. ShibAsia | Address 0x2d415bd832a37dd332a9b58c6a7ab209a2d1286c. https://etherscan.io/address/0x2d415bd832a37dd332a9b58c6a7ab209a2d1286c
[38]
Mar., 2018. EtherScan. https://etherscan.io/
[39]
Mar., 2018. openzeppelin-contracts ECRecovery.sol. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/e299a7950e31f35809339316dbbda894c6b52e01/contracts/ECRecovery.sol
[40]
Mar., 2018. Solidity Document. http://solidity.readthedocs.io
[41]
Mar., 2019. OpenZeppelin/openzeppelin-contracts Pull Request #1622. https://github.com/OpenZeppelin/openzeppelin-contracts/pull/1622
[42]
Mar., 2023. Dateset: library_misuse_data Github. https://github.com/libraryMisuse/library_misuse_data
[43]
Nov., 2015. ERC-20: Token Standard. https://eips.ethereum.org/EIPS/eip-20
[44]
Sep., 2022. Router01 | Address 0xf164fC0Ec4E93095b804a4795bBe1e041497b92a. https://etherscan.io/address/0xf164fC0Ec4E93095b804a4795bBe1e041497b92a
[45]
Ira D Baxter, Andrew Yahin, Leonardo Moura, Marcelo Sant'Anna, and Lorraine Bier. 1998. Clone detection using abstract syntax trees. In Proceedings. International Conference on Software Maintenance (Cat. No. 98CB36272). IEEE, 368--377.
[46]
CertiK. Apr., 2018. How Formal Verification Would Have Fortified Beauty Chain (BEC) Contract. https://medium.com/certik/how-formal-verification-would-have-fortified-beauty-chain-bec-contract-f53e78159400
[47]
Jiachi Chen, Xin Xia, David Lo, John Grundy, Xiapu Luo, and Ting Chen. 2020. Defining smart contract defects on ethereum. IEEE Transactions on Software Engineering 48, 1 (2020), 327--345.
[48]
Ting Chen, Rong Cao, Ting Li, Xiapu Luo, Guofei Gu, Yufei Zhang, Zhou Liao, Hang Zhu, Gang Chen, Zheyuan He, et al. 2020. SODA: A Generic Online Detection Framework for Smart Contracts. In NDSS.
[49]
Jacob Cohen. 1960. A coefficient of agreement for nominal scales. Educational and psychological measurement 20, 1 (1960), 37--46.
[50]
Thomas Durieux, João F Ferreira, Rui Abreu, and Pedro Cruz. 2020. Empirical review of automated analysis tools on 47,587 ethereum smart contracts. In Proceedings of the ACM/IEEE 42nd International conference on software engineering. 530--541.
[51]
Yuanrui Fan, Xin Xia, David Lo, Ahmed E Hassan, Yuan Wang, and Shanping Li. 2021. A Differential Testing Approach for Evaluating Abstract Syntax Tree Mapping Algorithms. In 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 1174--1185.
[52]
Josselin Feist, Gustavo Grieco, and Alex Groce. 2019. Slither: a static analysis framework for smart contracts. In 2019 IEEE/ACM 2nd International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB). IEEE, 8--15.
[53]
W.B. Frakes and Kyo Kang. 2005. Software reuse research: status and future. IEEE Transactions on Software Engineering 31, 7 (2005), 529--536.
[54]
James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. 2000. The Java language specification. Addison-Wesley Professional.
[55]
Neville Grech, Lexi Brent, Bernhard Scholz, and Yannis Smaragdakis. 2019. Giga-horse: thorough, declarative decompilation of smart contracts. In 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE). IEEE, 1176--1186.
[56]
Jingxuan He, Mislav Balunović, Nodar Ambroladze, Petar Tsankov, and Martin Vechev. 2019. Learning to fuzz from symbolic execution with application to smart contracts. In Proceedings of the 2019 ACM SIGSAC Conference on Computer and Communications Security. 531--548.
[57]
Bo Jiang, Ye Liu, and Wing Kwong Chan. 2018. Contractfuzzer: Fuzzing smart contracts for vulnerability detection. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering. 259--269.
[58]
Loi Luu, Duc-Hiep Chu, Hrishi Olickel, Prateek Saxena, and Aquinas Hobor. 2016. Making smart contracts smarter. In Proceedings of the 2016 ACM SIGSAC conference on computer and communications security. 254--269.
[59]
M Douglas McIlroy, J Buxton, Peter Naur, and Brian Randell. 1968. Mass-produced software components. In Proceedings of the 1st international conference on software engineering, Garmisch Pattenkirchen, Germany. 88--98.
[60]
Tai D Nguyen, Long H Pham, Jun Sun, Yun Lin, and Quang Tran Minh. 2020. sfuzz: An efficient adaptive fuzzer for solidity smart contracts. In Proceedings of the ACM/IEEE 42nd International Conference on Software Engineering. 778--788.
[61]
Ivica Nikolić, Aashish Kolluri, Ilya Sergey, Prateek Saxena, and Aquinas Hobor. 2018. Finding the greedy, prodigal, and suicidal contracts at scale. In Proceedings of the 34th annual computer security applications conference. 653--663.
[62]
p0n1. Apr., 2018. A disastrous vulnerability found in smart contracts of BeautyChain (BEC). https://medium.com/secbit-media/a-disastrous-vulnerability-found-in-smart-contracts-of-beautychain-bec-dbf24ddbc30e
[63]
Martin Reddy. 2011. API Design for C++. Elsevier.
[64]
Sunbeom So, Seongjoon Hong, and Hakjoo Oh. 2021. SmarTest: Effectively Hunting Vulnerable Transaction Sequences in Smart Contracts through Language Model-Guided Symbolic Execution. In USENIX Security Symposium. 1361--1378.
[65]
Donna Spencer. 2009. Card sorting: Designing usable categories. Rosenfeld Media.
[66]
Liya Su, Xinyue Shen, Xiangyu Du, Xiaojing Liao, XiaoFeng Wang, Luyi Xing, and Baoxu Liu. 2021. Evil Under the Sun: Understanding and Discovering Attacks on Ethereum Decentralized Applications. In USENIX Security Symposium. 1307--1324.
[67]
Christof Ferreira Torres, Julian Schütte, and Radu State. 2018. Osiris: Hunting for integer bugs in ethereum smart contracts. In Proceedings of the 34th Annual Computer Security Applications Conference. 664--676.
[68]
Petar Tsankov, Andrei Dan, Dana Drachsler-Cohen, Arthur Gervais, Florian Buenzli, and Martin Vechev. 2018. Securify: Practical security analysis of smart contracts. In Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security. 67--82.
[69]
Dabao Wang, Siwei Wu, Ziling Lin, Lei Wu, Xingliang Yuan, Yajin Zhou, Haoyu Wang, and Kui Ren. 2021. Towards a first step to understand flash loan and its applications in defi ecosystem. In Proceedings of the Ninth International Workshop on Security in Blockchain and Cloud Computing. 23--28.
[70]
Gavin Wood. 2014. Ethereum: A secure decentralised generalised transaction ledger. Ethereum Project Yellow Paper (2014).
[71]
Mengya Zhang, Xiaokuan Zhang, Yinqian Zhang, and Zhiqiang Lin. 2020. TXSPECTOR: Uncovering attacks in ethereum from transactions. In USENIX Security Symposium.
[72]
Peilin Zheng, Zibin Zheng, Jiajing Wu, and Hong-ning Dai. 2020. XBlock-ETH: Extracting and Exploring Blockchain Data from Ethereum. IEEE Open Journal of the Computer Society 1 (2020), 95--106.
[73]
Zibin Zheng, Shaoan Xie, Hong-Ning Dai, Xiangping Chen, and Huaimin Wang. 2018. Blockchain challenges and opportunities: A survey. International journal of web and grid services 14, 4 (2018), 352--375.

Cited By

View all
  • (2024)Broken Agreement: The Evolution of Solidity Error HandlingProceedings of the 18th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement10.1145/3674805.3686686(257-268)Online publication date: 24-Oct-2024

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
ICSE '24: Proceedings of the IEEE/ACM 46th International Conference on Software Engineering
May 2024
2942 pages
ISBN:9798400702174
DOI:10.1145/3597503
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

In-Cooperation

  • Faculty of Engineering of University of Porto

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 06 February 2024

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. blockchain
  2. ethereum
  3. library misuse
  4. empirical study

Qualifiers

  • Research-article

Funding Sources

Conference

ICSE '24
Sponsor:

Acceptance Rates

Overall Acceptance Rate 276 of 1,856 submissions, 15%

Upcoming Conference

ICSE 2025

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)350
  • Downloads (Last 6 weeks)41
Reflects downloads up to 29 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Broken Agreement: The Evolution of Solidity Error HandlingProceedings of the 18th ACM/IEEE International Symposium on Empirical Software Engineering and Measurement10.1145/3674805.3686686(257-268)Online publication date: 24-Oct-2024

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media