To address the problems of low detection accuracy of traditional smart contract vulnerability detection schemes and single vulnerability type detection of deep learning-based schemes, this paper proposes a smart contract vulnerability detection scheme based on TextCNN and attention mechanism. Firstly, word embedding is used to obtain the word vector representation of operation codes, and then the word vectors are input into TextCNN to extract sequential features. An attention mechanism is used to assign different weights to different features to highlight key features. Finally, normalization processing is carried out through activation functions to implement detection and recognition of smart contract vulnerabilities. The paper collected and screened 3735 valid smart contracts and used these contracts for model experiments and evaluation. The experimental results show that compared with deep learning models and traditional tools, the scheme proposed in the paper has certain improvements in terms of accuracy, precision, recall and Fl score, and can accurately identify 5 types of smart contract vulnerabilities with an accuracy of 99.20%.
Huaiguang WuHanjie DongYaqiong HeQianheng Duan
J WangCheng ZengQing Yu QuanYi Wang