**StateGuard: Detecting State D derailment Defects in Decentralized Exchange Smart Contract**
**Authors:**
- Zongwei Li, Hainan University
- Xiaoqi Li, Hainan University
- Wenkai Li, Hainan University
- Yuqing Zhang, University of Chinese Academy of Sciences
**Abstract:**
Decentralized Exchanges (DEXs) have emerged as a core component of decentralized finance, leveraging blockchain technology and smart contracts. However, the complex state logic in multi-contract interactions makes it challenging to detect state defects, which can lead to security threats. This paper introduces STATEGUARD, a deep learning-based framework designed to identify state derailment defects in DEX smart contracts. STATEGUARD constructs an Abstract Syntax Tree (AST) and uses a Graph Convolutional Network (GCN) to detect defects. Evaluations on 46 DEX projects with 5,671 smart contracts show a precision of 92.24%. STATEGUARD also successfully identified multiple novel CVEs in real-world smart contracts.
**Key Contributions:**
1. The first systematic study on state defects in DEX smart contracts.
2. Proposal of STATEGUARD, a deep learning framework for detecting state defects.
3. Comprehensive evaluation on 46 DEX projects with a 94.25% F1-score.
4. Discovery of multiple novel real-world defects.
**Methodology:**
- **AST Generation:** Compiles smart contract code into an AST.
- **Feature Extraction:** Extracts critical features from the AST.
- **Graph Processing:** Optimizes the extracted data into a graphical structure.
- **Defect Detection:** Uses GCN to process normalized data and identify defects.
**Experiments:**
- **Public Dataset:** Analyzed 5,671 smart contracts with a 94.25% F1-score.
- **Comparison with Tools:** Outperformed five existing tools in accuracy, recall, precision, and F1 score.
- **Real-World Contracts:** Identified multiple novel defects in real-world smart contracts.
**Discussion and Conclusion:**
STATEGUARD effectively identifies state derailment defects in DEX smart contracts, with high precision and recall. Future work will focus on refining graphical representations and exploring Large Language Models for improved defect detection.**StateGuard: Detecting State D derailment Defects in Decentralized Exchange Smart Contract**
**Authors:**
- Zongwei Li, Hainan University
- Xiaoqi Li, Hainan University
- Wenkai Li, Hainan University
- Yuqing Zhang, University of Chinese Academy of Sciences
**Abstract:**
Decentralized Exchanges (DEXs) have emerged as a core component of decentralized finance, leveraging blockchain technology and smart contracts. However, the complex state logic in multi-contract interactions makes it challenging to detect state defects, which can lead to security threats. This paper introduces STATEGUARD, a deep learning-based framework designed to identify state derailment defects in DEX smart contracts. STATEGUARD constructs an Abstract Syntax Tree (AST) and uses a Graph Convolutional Network (GCN) to detect defects. Evaluations on 46 DEX projects with 5,671 smart contracts show a precision of 92.24%. STATEGUARD also successfully identified multiple novel CVEs in real-world smart contracts.
**Key Contributions:**
1. The first systematic study on state defects in DEX smart contracts.
2. Proposal of STATEGUARD, a deep learning framework for detecting state defects.
3. Comprehensive evaluation on 46 DEX projects with a 94.25% F1-score.
4. Discovery of multiple novel real-world defects.
**Methodology:**
- **AST Generation:** Compiles smart contract code into an AST.
- **Feature Extraction:** Extracts critical features from the AST.
- **Graph Processing:** Optimizes the extracted data into a graphical structure.
- **Defect Detection:** Uses GCN to process normalized data and identify defects.
**Experiments:**
- **Public Dataset:** Analyzed 5,671 smart contracts with a 94.25% F1-score.
- **Comparison with Tools:** Outperformed five existing tools in accuracy, recall, precision, and F1 score.
- **Real-World Contracts:** Identified multiple novel defects in real-world smart contracts.
**Discussion and Conclusion:**
STATEGUARD effectively identifies state derailment defects in DEX smart contracts, with high precision and recall. Future work will focus on refining graphical representations and exploring Large Language Models for improved defect detection.