| Literature DB >> 35746403 |
Lejun Zhang1,2,3, Yuan Li1, Tianxing Jin4, Weizheng Wang5, Zilong Jin6, Chunhui Zhao7, Zhennao Cai8, Huiling Chen8.
Abstract
With countless devices connected to the Internet of Things, trust mechanisms are especially important. IoT devices are more deeply embedded in the privacy of people's lives, and their security issues cannot be ignored. Smart contracts backed by blockchain technology have the potential to solve these problems. Therefore, the security of smart contracts cannot be ignored. We propose a flexible and systematic hybrid model, which we call the Serial-Parallel Convolutional Bidirectional Gated Recurrent Network Model incorporating Ensemble Classifiers (SPCBIG-EC). The model showed excellent performance benefits in smart contract vulnerability detection. In addition, we propose a serial-parallel convolution (SPCNN) suitable for our hybrid model. It can extract features from the input sequence for multivariate combinations while retaining temporal structure and location information. The Ensemble Classifier is used in the classification phase of the model to enhance its robustness. In addition, we focused on six typical smart contract vulnerabilities and constructed two datasets, CESC and UCESC, for multi-task vulnerability detection in our experiments. Numerous experiments showed that SPCBIG-EC is better than most existing methods. It is worth mentioning that SPCBIG-EC can achieve F1-scores of 96.74%, 91.62%, and 95.00% for reentrancy, timestamp dependency, and infinite loop vulnerability detection.Entities:
Keywords: IoT; blockchain; deep learning; serial hybrid network; smart contract; vulnerability detection
Mesh:
Year: 2022 PMID: 35746403 PMCID: PMC9231163 DOI: 10.3390/s22124621
Source DB: PubMed Journal: Sensors (Basel) ISSN: 1424-8220 Impact factor: 3.847
Figure 1A holistic design solution for smart contract source code vulnerability detection based on deep learning.
Figure 2SPCBIG-EC.
The typical Solidity symbol corresponds to the token representation.
| Symbolic Representation | Token |
|---|---|
| function | FUN |
| contract | CON |
| for | FOR |
| if | IF |
| else | ELSE |
| number | NUM |
| constant | CONS |
| variable | VAR |
The key points corresponding to different vulnerabilities.
| Vulnerability | Key Points |
|---|---|
| Reentrancy | |
| Timestamp dependence |
|
| Infinite loop | |
| Integer overflow |
|
| Integer underflow |
|
| Callstack depth attack |
Figure 3Guidelines for labeling vulnerabilities.
Figure 4The code embedding process. ①–④ represent the process of representing the original smart contract code into vectors.
Figure 5Hierarchy of the SPCNN.
Figure 6Structure diagram of the Ensemble Classifier.
Figure 7The SCR Detection Framework.
Figure 8Composition of the CESC dataset.
The key points corresponding to different vulnerabilities.
| Dataset | Vulnerability | Models | ACC | TPR | FPR | PRE | F1 |
|---|---|---|---|---|---|---|---|
| CESC | Reentrancy | SPCBIG-EC | 96.66 | 98.04 | 5.71 | 94.55 | 96.74 |
| Timestamp | SPCBIG-EC | 91.11 | 96.84 | 14.64 | 86.93 | 91.62 | |
| Infinite loop | SPCBIG-EC | 94.87 | 93.16 | 3.41 | 96.46 | 95.00 | |
| Callstack depth attack | SPCBIG-EC | 90.02 | 86.32 | 7.24 | 92.25 | 89.14 | |
| Integer overflow | SPCBIG-EC | 85.11 | 97.10 | 16.90 | 83.80 | 85.42 | |
| Integer underflow | SPCBIG-EC | 86.47 | 89.24 | 16.29 | 84.57 | 86.83 |
Figure 9Plots of Acc-Loss.
Performance comparison of a single model and serial hybrid model.
| Metrics | ACC (%) | TPR (%) | FPR (%) | PRE (%) | F1 (%) | |
|---|---|---|---|---|---|---|
| Model | ||||||
| Reentrancy | BiGRU | 85.38 | 86.57 | 11.42 | 85.23 | 85.55 |
| SPCNN | 87.14 | 87.12 | 12.23 | 85.45 | 86.77 | |
| SPCBIG-EC | 96.66 | 98.04 | 5.71 | 94.55 | 96.74 | |
| Timestamp | BiGRU | 82.45 | 83.82 | 13.28 | 71.29 | 76.82 |
| SPCNN | 83.48 | 82.56 | 12.84 | 75.27 | 79.19 | |
| SPCBIG-EC | 91.11 | 96.84 | 14.64 | 86.93 | 91.62 | |
| Infinite loop | BiGRU | 80.11 | 83.54 | 21.45 | 73.98 | 76.27 |
| SPCNN | 79.79 | 85.14 | 11.84 | 75.17 | 78.86 | |
| SPCBIG-EC | 94.87 | 93.16 | 3.41 | 96.46 | 95.00 |
The results of the detection of hybrid vulnerabilities with the SCR Detection Framework.
| Metrics | ACC (%) | TPR (%) | FPR (%) | PRE (%) | F1 (%) | |
|---|---|---|---|---|---|---|
| Serial Neural Network | ||||||
| CNN-RNN | 75.25 | 62.56 | 12.06 | 83.84 | 71.65 | |
| CNN-LSTM | 79.77 | 79.90 | 20.35 | 79.70 | 79.80 | |
| CNN-GRU | 80.52 | 71.11 | 10.05 | 87.61 | 78.50 | |
| CNN-BLSTM | 80.65 | 76.63 | 15.32 | 83.33 | 79.85 | |
| CNN-BiGRU | 81.41 | 81.91 | 19.09 | 81.10 | 81.50 | |
| SCNN-RNN | 79.02 | 72.36 | 14.32 | 83.47 | 77.52 | |
| SCNN-LSTM | 78.64 | 82.16 | 24.87 | 76.76 | 79.37 | |
| SCNN-GRU | 81.40 | 73.11 | 10.30 | 87.65 | 79.72 | |
| SCNN-BLSTM | 82.41 | 72.11 | 10.29 | 90.82 | 80.39 | |
| SCNN-BiGRU | 82.92 | 80.90 | 15.07 | 84.30 | 82.56 | |
| SPCNN-RNN | 79.27 | 87.69 | 29.14 | 75.05 | 80.88 | |
| SPCNN-LSTM | 80.15 | 80.00 | 19.50 | 80.30 | 80.10 | |
| SPCNN-GRU | 82.03 | 81.66 | 17.58 | 82.28 | 81.97 | |
| SPCNN-BLSTM | 82.66 | 81.16 | 15.82 | 83.68 | 82.40 | |
| SPCBIG-EC | 85.89 | 85.00 | 9.23 | 91.41 | 85.71 | |
The results of the detection of hybrid vulnerabilities with the SCR Detection Framework.
| Metrics | ACC (%) | TPR (%) | FPR (%) | PRE (%) | F1 (%) | |
|---|---|---|---|---|---|---|
| Model | ||||||
| Reentrancy | CNN-BiGRU | 84.76 | 76.19 | 6.67 | 91.95 | 83.33 |
| SCNN-BiGRU | 86.19 | 93.33 | 20.95 | 81.67 | 87.11 | |
| SPCBIG-EC | 96.66 | 98.04 | 5.71 | 94.55 | 96.74 | |
| Timestamp | CNN-BiGRU | 87.61 | 92.72 | 23.42 | 80.73 | 88.83 |
| SPCNN-BiGRU | 90.47 | 91.77 | 10.83 | 89.5 | 90.62 | |
| SPCBIG-EC | 91.11 | 96.84 | 14.64 | 86.93 | 91.62 | |
| Infinite loop | CNN-BiGRU | 80.77 | 72.65 | 11.11 | 86.73 | 79.0 |
| SPCNN-BiGRU | 89.74 | 88.03 | 8.55 | 91.15 | 89.57 | |
| SPCBIG-EC | 94.87 | 93.16 | 3.41 | 96.46 | 95.00 |
Figure 10Case study on the interpretability of our method. The “1” and “0” in the graph indicate the result of vulnerability detection. A “1” indicates that a vulnerability exists in the detected contract, and a “0” indicates that it does not exist.
Comparison results with advanced security audit tools.
| Methods | Reentrancy | Timestamp | ||||||
|---|---|---|---|---|---|---|---|---|
| ACC (%) | TPR (%) | PRE (%) | F1 (%) | ACC (%) | TPR (%) | PRE (%) | F1 (%) | |
| Oyenete | 71.50 | 50.84 | 51.72 | 51.28 | 60.54 | 31.94 | 48.94 | 38.66 |
| Mythril | 60.00 | 39.21 | 68.96 | 50.00 | 64.87 | 34.53 | 58.54 | 42.48 |
| Smartcheck | 52.00 | 24.32 | 31.03 | 27.27 | 61.08 | 29.17 | 50.00 | 36.84 |
| Securify | 53.50 | 37.41 | 89.66 | 52.79 | - | - | - | - |
| SPCBIG-EC | 96.66 | 98.04 | 94.55 | 96.74 | 91.11 | 96.84 | 86.93 | 91.62 |
Comparison results with existing advanced deep learning-based methods.
| Methods | Reentrancy | Timestamp | Infinite Loop | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ACC (%) | TPR (%) | PRE (%) | F1 (%) | ACC (%) | TPR (%) | PRE (%) | F1 (%) | ACC (%) | TPR (%) | PRE (%) | F1 (%) | |
| GR-GCN | 81.47 | 80.89 | 72.36 | 76.39 | 78.68 | 78.91 | 71.29 | 74.91 | 68.34 | 67.82 | 64.89 | 66.32 |
| TMP | 84.48 | 82.63 | 74.06 | 78.11 | 83.45 | 83.82 | 75.05 | 79.19 | 74.61 | 74.32 | 73.89 | 74.10 |
| CGE | 89.15 | 87.62 | 85.24 | 86.41 | 89.02 | 88.10 | 87.41 | 87.75 | 83.21 | 82.29 | 81.97 | 82.13 |
| AME | 90.19 | 89.69 | 86.25 | 87.94 | 86.52 | 86.23 | 82.07 | 84.10 | 80.32 | 79.08 | 78.69 | 78.88 |
| Eth2Vec | 85.50 | 74.32 | 86.60 | 61.50 | - | - | - | - | - | - | - | - |
| AFS | 93.07 | 94.60 | 90.00 | 93.21 | - | - | - | - | - | - | - | - |
| DeeSCV | 93.02 | 83.46 | 90.70 | 86.87 | 80.50 | 74.86 | 85.53 | 79.93 | - | - | - | - |
| SPCBIG-EC | 96.66 | 98.04 | 94.55 | 96.74 | 91.11 | 96.84 | 86.93 | 91.62 | 94.87 | 93.16 | 96.46 | 86.93 |
Figure 11Visualization of images compared to existing deep learning-based methods.
Figure 12The comparison in detection time.
Comparison of hybrid vulnerabilities under different datasets.
| Model | Dataset | ACC | TPR | FPR | PRE | F1 |
|---|---|---|---|---|---|---|
| SPCBIG-EC | UCESC | 85.89 | 85.00 | 9.23 | 91.41 | 85.71 |
| SCVDIE-Ensemble [ | 91.80 | 95.25 | 11.67 | 90.00 | 92.10 |
Figure 13Plots of Acc-Loss during hybrid vulnerability detection.