# Toward Vulnerability Detection for Ethereum Smart Contracts Using Graph-Matching Network
###### Abstract  
With the blooming of blockchain-based smart contracts in decentralized applications, the security problem of smart contracts has become a critical issue, as vulnerable contracts have resulted in severe financial losses. Existing research works have explored vulnerability detection methods based on fuzzing, symbolic execution, formal verification, and static analysis. In this paper, we propose two static analysis approaches called _ASGVulDetector_ and _BASGVulDetector_ for detecting vulnerabilities in Ethereum smart contacts from source-code and byteode perspectives, respectively. First, we design a novel intermediate representation called abstract semantic graph (ASG) to capture both syntactic and semantic features from the program. ASG is based on syntax information but enriched by code structures, such as control flow and data flow. Then, we apply two different training models, i.e., graph neural network (GNN) and graph matching network (GMN), to learn the embedding of ASG and measure the similarity of the contract pairs. In this way, vulnerable smart contracts can be identified by calculating the similarity to labeled ones. We conduct extensive experiments to evaluate the superiority of our approaches to state-of-the-art competitors. Specifically, _ASGVulDetector_ improves the best of three source-code-only static analysis tools (i.e., _SmartCheck_, _Slither_, and _DR-GCN_) regarding the F1 score by 12.6% on average, while _BASGVulDetector_ improves that of the three detection tools supporting bytecode (i.e., _ContractFuzzer_, _Oyente_, and _Securify_) regarding the F1 score by 25.6% on average. We also investigate the effectiveness and advantages of the GMN model for detecting vulnerabilities in smart contracts. s +
Footnote †: journal:  
1
Footnote †: journal:  
1
Footnote 1: School of Cyber Science and Engineering, Southeast University, Nanjing 211189, China 1  
+++ ==WARNING: Truncated because of repetitions==
189, China 1  
Footnote 1: financial losses. In 2016, the notorious DAO attack due to the reentrancy vulnerability in Ethereum caused losses of ETC 3.6 million (i.e., cryptocurrencies of Ethereum) worth over CNY 60 million at that time [5]. In 2017, a bug in a smart contract library used by the Parity Multisig Wallet caused the loss of CNY 30 million and the freezing of CNY 150 million worth of ETC [6]. In 2018, attackers exploited an integer overflow vulnerability in the BEC smart contract to transfer an extremely large amount of tokens to malicious accounts, causing instantaneous evaporation of over CNY 900 million [7]. The above cases are not isolated, and security vulnerabilities of smart contacts are disclosed every year [8]. Even worse, with the population of decentralized finance (i.e., DeFi), attacks on smart contracts and financial losses are surging [9]. Hence, security vulnerability has become a critical issue in smart contract applications. In contrast to other scenarios, the problem of security vulnerabilities in smart contracts faces more challenges, which can be summarized into three aspects. First, smart contracts are publicly available and hold increasing financial values, making them extremely tempting targets for attackers [10]. Second, although smart contracts can be obfuscated by only publishing the bytecode, it can still be decompiled for security analysis, which makes it a target of choice for attackers. Third, defects in smart contracts cannot be rectified due to the immutable nature of blockchain, which suggests the significant importance of vulnerability detection, especially before deployment on the blockchain. Recently, many research efforts have been focused on detecting the security vulnerabilities of smart contracts [11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21; 22; 23; 24; 25; 26; 27], while most of them are inspired by or inherited from popular methods in conventional software testing.