Journal of Computer Applications ›› 2025, Vol. 45 ›› Issue (1): 153-161.DOI: 10.11772/j.issn.1001-9081.2024010025

• Cyber security • Previous Articles     Next Articles

Smart contract vulnerability detection method based on echo state network

Chunxia LIU, Hanying XU, Gaimei GAO(), Weichao DANG, Zilu LI   

  1. College of Computer Science and Technology,Taiyuan University of Science and Technology,Taiyuan Shanxi 030024,China
  • Received:2024-01-15 Revised:2024-04-10 Accepted:2024-04-10 Online:2024-05-09 Published:2025-01-10
  • Contact: Gaimei GAO
  • About author:LIU Chunxia, born in 1977, M. S., associate professor. Her research interests include software engineering, database.
    XU Hanying, born in 1997, M. S. candidate. Her research interests include blockchain, smart contract security.
    DANG Weichao, born in 1974, Ph. D., associate professor. His research interests include intelligent computing, software reliability.
    LI Zilu, born in 2000, M. S. candidate. His research interests include smart contract security, network security.
  • Supported by:
    Shanxi Province Applied Basic Research Program(202203021221153)

基于回声状态网络的智能合约漏洞检测方法

刘春霞, 徐晗颖, 高改梅(), 党伟超, 李子路   

  1. 太原科技大学 计算机科学与技术学院,太原 030024
  • 通讯作者: 高改梅
  • 作者简介:刘春霞(1977—),女,山西大同人,副教授,硕士,CCF会员,主要研究方向:软件工程、数据库;
    徐晗颖(1997—),女,黑龙江密山人,硕士研究生,主要研究方向:区块链、智能合约安全;
    党伟超(1974—),男,山西运城人,副教授,博士,CCF会员,主要研究方向:智能计算、软件可靠性;
    李子路(2000—),男,山西太原人,硕士研究生,主要研究方向:智能合约安全、网络安全。
  • 基金资助:
    山西省应用基础研究计划项目(202203021221153)

Abstract:

Smart contracts on blockchain platforms are decentralized applications to provide secure and trusted services to multiple parties on the chain. Smart contract vulnerability detection can ensure the security of these contracts. However, the existing methods for detecting smart contract vulnerabilities encountered issues of insufficient feature learning and low vulnerability detection accuracy when dealing with imbalanced sample sizes and incomplete semantic information mining. Moreover, these methods cannot detect new vulnerabilities in contracts. A smart contract vulnerability detection method based on Echo State Network (ESN) was proposed to address the above problems. Firstly, different semantic and syntactic edges were learned on the basis of contract graph, and feature vectors were obtained through Skip-Gram model training. Then, ESN was combined with transfer learning to achieve transfer and extension of new contract vulnerabilities in order to improve the vulnerability detection rate. Finally, experiments were conducted on the smart contract dataset collected on Etherscan platform. Experimental results show that the accuracy, precision, recall, and F1-score of the proposed method reach 94.30%, 97.54%, 91.68%, and 94.52%, respectively. Compared with Bidirectional Long Short-Term Memory (BLSTM) network and Bidirectional Long Short-Term Memory with ATTention mechanism (BLSTM-ATT), the proposed method has the accuracy increased by 5.93 and 11.75 percentage points respectively, and the vulnerability detection performance is better. The ablation experiments also further validate the effectiveness of ESN for smart contract vulnerability detection.

Key words: vulnerability detection, smart contract, Echo State Network (ESN), transfer learning, blockchain

摘要:

区块链平台上的智能合约是为链上各方提供安全可信赖服务的去中心化应用程序,而智能合约漏洞检测能确保智能合约的安全性。然而,现有的智能合约漏洞检测方法在样本数量不均衡和语义信息挖掘不全面时,会出现特征学习不足和漏洞检测准确率低的问题,而且,这些方法无法对新的合约漏洞进行检测。针对上述问题,提出一种基于回声状态网络(ESN)的智能合约漏洞检测方法。首先,根据合约图,对不同语义、语法边进行学习,并利用Skip-Gram模型训练得到特征向量;其次,结合ESN和迁移学习,实现对新合约漏洞的迁移扩展,以提高漏洞检测率;最后,在Etherscan平台搜集的智能合约数据集上进行实验。实验结果表明,所提方法的准确率、精确率、召回率和F1分数分别达到了94.30%、97.54%、91.68%和94.52%,与双向长短时记忆(BLSTM)网络、自注意力机制的双向长短时记忆(BLSTM-ATT)相比,所提方法的准确率分别提高了5.93和11.75个百分点,漏洞检测性能更优。消融实验也进一步验证了ESN对智能合约漏洞检测的有效性。

关键词: 漏洞检测, 智能合约, 回声状态网络, 迁移学习, 区块链

CLC Number: