Netinfo Security ›› 2022, Vol. 22 ›› Issue (9): 46-54.doi: 10.3969/j.issn.1671-1122.2022.09.006

Previous Articles     Next Articles

Smart Contract Vulnerability Detection Scheme Based on BiLSTM and Attention Mechanism

ZHANG Guanghua1,2, LIU Yongsheng2, WANG He1, YU Naiwen2()   

  1. 1. School of Cyber Engineering, Xidian University, Xi’an 710071, China
    2. School of Information Science and Engineering, Hebei University of Science Technology, Shijiazhuang 050018, China
  • Received:2022-06-28 Online:2022-09-10 Published:2022-11-14
  • Contact: YU Naiwen E-mail:yunaiwen@hebust.edu.cn

Abstract:

Aiming at the low detection accuracy of the traditional smart contract vulnerability detection scheme and the single type of vulnerability detected by the deep learning scheme, this paper proposed a smart contract vulnerability detection scheme based on bi-directional long short-term memory (BiLSTM) network and attention mechanism. Firstly, the word2vec word embedding technology was used to train the data to obtain the word vector representation of the opcode. Secondly, the word vector was passed into BiLSTM to extract sequence features, and an attention mechanism was introduced to give different weights to different features to highlight key features. Finally, the activation function was normalized to realize the detection and identification of smart contract vulnerabilities. This paper collected 3,000 smart contracts in Ethereum and used them to evaluate the model. The experimental results show that compared with the deep learning model and traditional tools, the scheme in this paper has improved the precision rate, recall rate and F1 score, and can accurately identify four kinds of type of smart contract vulnerabilities, the accuracy rate reached 86.34%.

Key words: BiLSTM, blockchain, smart contract, attention mechanism, vulnerability detection

CLC Number: