Abstract
With the rapid proliferation of Internet of Things (IoT) devices, ensuring their communication security has become increasingly important. Blockchain and smart contract technologies, with their decentralized nature, provide a robust framework for secure data exchange. However, smart contracts are highly susceptible to reentrancy attacks. This paper introduces GMS, a novel detection method that combines expert-defined pattern matching with Graph Attention Networks (GAT) and Squeeze-and-Excitation Networks (SENet). By fusing structural graph data with rule-based features, GMS achieves a state-of-the-art 94.07% accuracy, significantly outperforming traditional static analysis tools and existing graph neural network approaches.
Introduction: The Reentrancy Challenge in IoT
As the Internet of Things (IoT) increasingly relies on blockchain for decentralized communication, the security of smart contracts has become a critical concern. Among the various vulnerabilities, the reentrancy flaw is particularly devastating. This vulnerability, famously exploited in the 2016 DAO hack, occurs when an external malicious contract repeatedly calls back into a victim contract before the initial execution is completed, often leading to the unauthorized draining of funds.
Current detection tools generally fall into two categories, both with significant drawbacks:
- Traditional Static Analysis: Tools like Slither or Oyente rely on developer-defined rules. They often produce high false positive rates because they lack the context to distinguish between legitimate security patterns (like reentrancy locks) and actual vulnerabilities.
- Standard Deep Learning: Many machine learning models treat contract code as simple text. This approach fails to capture the complex control and data flow dependencies essential for identifying sophisticated attacks.
Methodology: The GMS Architecture
To address these limitations, the GMS framework employs a hybrid architecture that integrates expert knowledge with advanced deep learning.
1. Reentrancy Pattern Extraction
GMS begins by identifying three specific reentrancy patterns through keyword matching and syntax analysis:
- CallValueInvocation: Focuses on standard value transfer checks.
- CallAfterVary: Targets state changes occurring after external calls, specifically addressing the nuance of read-only reentrancy.
- CrossFunction: Detects vulnerabilities that span multiple functions with different access controls.
2. Semantic Graph Construction
The source code is transformed into a contract semantic graph. In this representation, nodes denote functions or variables, while edges represent control flow, data flow, and fallback mechanisms. To ensure consistency and efficiency, "ordinary" nodes are aggregated into "core" nodes that represent the contract's primary logic.
3. Feature Fusion via GAT and SENet
The core of GMS lies in its dual-layered neural processing:
- Graph Attention Network (GAT): Processes the semantic graph to extract high-level structural embeddings. GAT allows the model to learn the relative importance of different execution paths.
- Squeeze-and-Excitation Network (SENet): The graph embeddings and rule-based features are fused into a multi-channel input. SENet then dynamically recalibrates the weights of these channels, enabling the model to prioritize the most relevant vulnerability indicators for final classification.
Performance and Results
The GMS model was evaluated using the Ethereum Smart Contract (ESC) dataset, which includes over 300,000 functions from real-world contracts.
Exceptional Accuracy
GMS achieved a remarkable 94.07% accuracy, with a recall of 91.09% and a precision of 90.57%. This represents a 3.88% improvement over the previous state-of-the-art graph-based method (AME).
Comparison with Industry Standards
When compared to traditional static analysis tools, GMS demonstrated superior performance. While Slither achieved 77.12% accuracy, other tools like Mythril and Oyente struggled, reaching only ~60%. Furthermore, GMS is highly efficient, averaging just 0.1 seconds per contract detection—significantly faster than Slither (0.6s) or Securify (1.6s).
Conclusion and Future Directions
The success of GMS highlights the power of combining expert-defined rules with structural graph analysis. By effectively identifying complex threats like read-only reentrancy, GMS provides a robust solution for securing the blockchain-based IoT ecosystem. Future research will focus on extending this GAT + SENet fusion architecture to detect other critical vulnerabilities, such as integer overflows and logic errors, further hardening decentralized systems against attack.
Summary updated