LookAhead: Preventing DeFi Attacks via Unveiling Adversarial Contracts
Preprint
Abstract
DeFi incidents stemming from various smart contract vulnerabilities have culminated in financial damages exceeding 3 billion USD. The attacks causing such incidents commonly commence with the deployment of adversarial contracts, subsequently leveraging these contracts to execute adversarial transactions that exploit vulnerabilities in victim contracts. Existing defense mechanisms leverage heuristic or machine learning algorithms to detect adversarial transactions, but they face significant challenges in detecting private adversarial transactions. Namely, attackers can send adversarial transactions directly to miners, evading visibility within the blockchain network and effectively bypassing the detection. In this paper, we propose a new direction for detecting DeFi attacks, i.e., detecting adversarial contracts instead of adversarial transactions, allowing us to proactively identify potential attack intentions, even if they employ private adversarial transactions. Specifically, we observe that most adversarial contracts follow a similar pattern, e.g., anonymous fund source, closed-source, frequent token-related function calls. Based on this observation, we build a machine learning classifier that can effectively distinguish adversarial contracts from benign ones. We build a dataset consists of features extracted from 269 adversarial contracts and 13,000 benign contracts. Based on this dataset, we evaluate different classifiers, the results of which show that our method for identifying DeFi adversarial contracts performs exceptionally well. For example, the F1-Score for LightGBM-based classifier is 0.9541, with a remarkably low false positive rate of only 0.15%.Keywords
All Related Versions
This publication has 10 references indexed in Scilit:
- DeFiRanger: Detecting DeFi Price Manipulation AttacksIEEE Transactions on Dependable and Secure Computing, 2023
- Securing the Ethereum from Smart Ponzi Schemes: Identification Using Static FeaturesACM Transactions on Software Engineering and Methodology, 2023
- DeFiScanner: Spotting DeFi Attacks Exploiting Logic Vulnerabilities on BlockchainIEEE Transactions on Computational Social Systems, 2022
- Time-travel Investigation: Toward Building a Scalable Attack Detection Framework on EthereumACM Transactions on Software Engineering and Methodology, 2022
- SADPonzi: Detecting and Characterizing Ponzi Schemes in Ethereum Smart ContractsProceedings of the ACM on Measurement and Analysis of Computing Systems, 2021
- SODA: A Generic Online Detection Framework for Smart Contracts2020
- Dissecting Ponzi schemes on Ethereum: Identification, analysis, and impactFuture Generation Computer Systems, 2020
- Sereum: Protecting Existing Smart Contracts Against Re-Entrancy Attacks2019
- Online detection of effectively callback free objects with applications to smart contractsProceedings of the ACM on Programming Languages, 2017
- Introducing Ethereum and Solidity2017