DeFiGuard: A Price Manipulation Detection Service in DeFi using Graph Neural Networks

Dabao Wang,Bang Wu,Xingliang Yuan,Lei Wu,Yajin Zhou,Helei Cui
2024-06-17
Abstract:The prosperity of Decentralized Finance (DeFi) unveils underlying risks, with reported losses surpassing 3.2 billion USD between 2018 and 2022 due to vulnerabilities in Decentralized Applications (DApps). One significant threat is the Price Manipulation Attack (PMA) that alters asset prices during transaction execution. As a result, PMA accounts for over 50 million USD in losses. To address the urgent need for efficient PMA detection, this paper introduces a novel detection service, DeFiGuard, using Graph Neural Networks (GNNs). In this paper, we propose cash flow graphs with four distinct features, which capture the trading behaviors from transactions. Moreover, DeFiGuard integrates transaction parsing, graph construction, model training, and PMA detection. Evaluations on a dataset of 208 PMA and 2,080 non-PMA transactions show that DeFiGuard with GNN models outperforms the baseline in Accuracy, TPR, FPR, and AUC-ROC. The results of ablation studies suggest that the combination of the four proposed node features enhances DeFiGuard's efficacy. Moreover, DeFiGuard classifies transactions within 0.892 to 5.317 seconds, which provides sufficient time for the victims (DApps and users) to take action to rescue their vulnerable funds. In conclusion, this research offers a significant step towards safeguarding the DeFi landscape from PMAs using GNNs.
Cryptography and Security
What problem does this paper attempt to address?
The problem that this paper attempts to solve is the price manipulation attacks (PMA) in the decentralized finance (DeFi) field. Specifically, the paper focuses on how to effectively detect and prevent the behavior of manipulating asset prices through smart contract vulnerabilities. Such attacks led to losses of over $320 million between 2018 and 2022, of which price manipulation attacks alone caused losses of over $50 million. To solve this problem, the author proposes a novel detection service named DeFiGuard, which uses graph neural networks (GNNs) to identify and detect price manipulation attacks. DeFiGuard is implemented in the following ways: 1. **Transaction Parsing**: Collect raw transaction data from EVM - based blockchains and extract call traces and event logs related to transfers. 2. **Graph Construction**: Construct cash - flow graphs based on the extracted data. These graphs contain four different node features to capture transaction behaviors. 3. **Model Training and Classification**: Use the GNN model to train the constructed cash - flow graphs and use them to detect price manipulation attacks. In this way, DeFiGuard can not only effectively detect known price manipulation attacks, but also adapt to changing attack patterns, thus providing broader protection. ### Main Contributions - **Novel Detection Service**: DeFiGuard integrates transaction parsing, graph construction, model training, and PMA detection, forming a complete solution. - **Unique Graph Representation Method**: Transform raw transactions into cash - flow graphs and introduce four node features (node type, transfer frequency, transfer diversity, profit score), which significantly improve the effectiveness of PMA detection. - **Performance Evaluation**: Through the evaluation of 208 PMA and 2080 non - PMA transactions, it is proved that DeFiGuard is superior to the baseline model in terms of accuracy, true positive rate, false positive rate, and AUC - ROC. - **High Efficiency**: DeFiGuard can complete the classification of a single transaction within 0.892 to 5.317 seconds, which is faster than the time for Ethereum to generate a new block, providing victims with enough time to take action. In summary, this research aims to provide an efficient and adaptable method for detecting price manipulation attacks in the DeFi field through graph neural network technology.