Journal of South China University of Technology(Natural Science Edition) ›› 2023, Vol. 51 ›› Issue (5): 36-44.doi: 10.12141/j.issn.1000-565X.220167

Special Issue: 2023年计算机科学与技术

• Computer Science & Technology • Previous Articles     Next Articles

Smart Contract Vulnerability Detection Method Based on Capsule Network and Attention Mechanism

LU Lu LAI Jinxiong   

  1. School of Computer Science and Engineering,South China University of Technology,Guangzhou 510006,Guangdong,China
  • Received:2022-03-30 Online:2023-05-25 Published:2022-11-15
  • Contact: 陆璐(1971-),男,博士,教授,主要从事计算机视觉和软件质量保障研究。 E-mail:lul@scut.edu.cn
  • About author:陆璐(1971-),男,博士,教授,主要从事计算机视觉和软件质量保障研究。
  • Supported by:
    the General Program of the Natural Science Foundation of Guangdong Province(2021A1515011798)

Abstract:

In recent years, with the increasing number of smart contracts and the increasing economic losses caused by contract loopholes, the security of smart contracts has attracted more and more attention. The vulnerability detection method based on deep learning can solve the problems of low detection efficiency and insufficient accuracy of the early traditional smart contract vulnerability detection method. However, most of the existing deep learning-based vulnerability detection methods directly use smart contract source code, opcode sequence or bytecode sequence as the input of the deep learning model. This fact will weaken the effective information due to the introduction of too much invalid information. To solve this problem, this paper proposed a smart contract vulnerability detection method based on capsule network and attention mechanism. Considering the execution timing information of the program, the study extracted key operation code sequence of the smart contract as the source code feature. Then a hybrid network structure of capsule network and attention mechanism was used for training. The capsule network extracts the context information of the smart contract and the connection between the part and the whole; while the attention mechanism is used to assign different weights to different opcodes according to their importance. The experimental results show that the F1 score and accuracy of the algorithm proposed in this paper in the smart contract data set are 94.48% and 97.15%, indicating that this algorithm is superior to other detection methods in performance.

Key words: smart contract, key opcode sequence, capsule network, attention mechanism

CLC Number: