ML-AGNN: Smart Contract Vulnerability Detection Method Based on a Multi-Level Attention Graph Neural Network
Haochen Li, Chunjie Cao, Mengnan Wang, Zhi Li, Qi Zhang, Jingzhang Sun · 2024
Smart contracts and blockchain mutually reinforce each other, leveraging their core attribute of decentralized interoperability to play crucial roles in both on-chain code and off-chain data. Nonetheless, this dual-edged nature, characterized by immutability once deployed and an immature language ecosystem, introduces significant risks. Consequently, smart contract vulnerabilities have emerged as a major security threat within trusted blockchain environments. With the exponential growth in the number of smart contracts, traditional detection methods necessitate considerable data overhead. On the other hand, the growing complexity of code semantic relationships and the cumulative error effects of conventional detection techniques further compound the issue. To address these challenges and enhance the learning capability for complex semantic relationships, we proposed a novel deep learning approach: Multi-Level Attention Graph Neural Network (ML-AGNN). This method integrates adaptive attention mechanisms and channel aggregation within a message passing neural network, effectively tackling the limitations of local semantic information and inaccuracies in modeling semantic information due to deeper network layers. We have implemented this approach in a prototype named GNN and validated it using over 40,000 smart contracts from Ethereum. Our extensive results demonstrated that this solution achieves an accuracy of 91.77%and a recall of 87.17% in detecting reentrancy vulnerabilities, significantly surpassing state-of-the-art methods. Additionally, another experiment confirms that our approach markedly outperforms contemporary methods in detecting timestamp dependency vulnerabilities.