Demystifying Invariant Effectiveness for Securing Smart Contracts
Open Access
- 12 July 2024
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Software Engineering
- Vol. 1 (FSE) , 1772-1795
Abstract
Smart contract transactions associated with security attacks often exhibit distinct behavioral patterns compared with historical benign transactions before the attacking events. While many runtime monitoring and guarding mechanisms have been proposed to validate invariants and stop anomalous transactions on the fly, the empirical effectiveness of the invariants used remains largely unexplored. In this paper, we studied 23 prevalent invariants of 8 categories, which are either deployed in high-profile protocols or endorsed by leading auditing firms and security experts. Using these well-established invariants as templates, we developed a tool Trace2Inv which dynamically generates new invariants customized for a given contract based on its historical transaction data. We evaluated Trace2Inv on 42 smart contracts that fell victim to 27 distinct exploits on the Ethereum blockchain. Our findings reveal that the most effective invariant guard alone can successfully block 18 of the 27 identified exploits with minimal gas overhead. Our analysis also shows that most of the invariants remain effective even when the experienced attackers attempt to bypass them. Additionally, we studied the possibility of combining multiple invariant guards, resulting in blocking up to 23 of the 27 benchmark exploits and achieving false positive rates as low as 0.28%. Trace2Inv significantly outperforms state-of-the-art works on smart contract invariant mining and transaction attack detection in accuracy. Trace2Inv also surprisingly found two previously unreported exploit transactions.Keywords
All Related Versions
This publication has 33 references indexed in Scilit:
- AChecker: Statically Detecting Smart Contract Access Control Vulnerabilities2023
- SMARTIAN: Enhancing Smart Contract Fuzzing with Static and Dynamic Data-Flow Analyses2021
- Formal Analysis of Composable DeFi Protocols2021
- The Decentralized Financial Crisis2020
- Finding The Greedy, Prodigal, and Suicidal Contracts at Scale2018
- ContractFuzzer: fuzzing smart contracts for vulnerability detection2018
- SmartCheck2018
- Validation and Verification of Smart Contracts: A Research AgendaComputer, 2017
- A Survey of Attacks on Ethereum Smart Contracts (SoK)2017
- Making Smart Contracts Smarter2016