首页|基于分层注意力网络和积分梯度的细粒度漏洞检测方法

基于分层注意力网络和积分梯度的细粒度漏洞检测方法

扫码查看
智能合约是一种基于区块链平台运行的去中心化应用程序,在数字货币、物联网、供应链等多个领域应用广泛.智能合约漏洞检测的研究对于保障数字资产安全、维护合约的可靠性与稳定性具有重要意义.目前的主流研究之一为利用深度学习模型自动学习代码特征,检测出智能合约漏洞,准确性较高,但是在漏洞解释方面具有局限性,不能提供细粒度的漏洞信息.针对目前基于深度学习的智能合约漏洞检测模型不能有效提供细粒度漏洞解释,且缺少细粒度标签的问题,提出一种基于分层注意力网络和积分梯度的细粒度漏洞检测方法.利用分层注意力网络进行粗粒度漏洞检测,通过两层注意力构建单词注意力编码层和函数注意力编码层分别学习源代码的函数级和合约级表示,以关注代码的不同令牌和语句;然后使用积分梯度方法进行细粒度解释,计算代码语句对漏洞预测的贡献度,以获取与漏洞相关的脆弱语句,实现无语句标签情况下的单词级别和语句级别的漏洞解释.在真实以太坊数据集Smartbugs Wilds,SmartbugsCurated和SolidiFIBenchmark上的实验结果表明,该方法在5种漏洞类型上的平均准确率达到80%以上,漏洞解释准确率提升6%,可以更加准确地定位漏洞代码,帮助开发人员审查合约.
Fine-grained Vulnerability Detection Based on Hierarchical Attention Networks and Integral Gradients
Smart contracts are decentralized applications that run on blockchain platforms and are widely used in many fields,in-cluding digital currencies,the Internet of Things,and supply chains.Research on vulnerability detection in smart contracts is of great importance for securing digital assets and maintaining the reliability and stability of contracts.One of the current main-stream researches is to use deep learning models to automatically learn code features,so as to detect vulnerabilities in smart con-tracts.It has high accuracy,but has limitations in vulnerability interpretation and cannot provide fine-grained vulnerability infor-mation.To address the problem that the current deep learning-based smart contract vulnerability detection model cannot effective-ly provide fine-grained vulnerability explanation and lacks of fine-grained labels,a fine-grained vulnerability detection method based on hierarchical attention network and integral gradient is proposed.Using hierarchical attention network for coarse-grained vulnerability detection,the word attention encoding layer and function attention encoding layer are constructed by two attention layers to learn the function-level and contract-level representations of the source code,respectively,to pay attention to the various tokens and statements of the code;and then the integrated gradient method is used to provide fine-grained explanations and calcu-late the contribution of code statements to vulnerability prediction,to obtain the vulnerability statements related to vulnerabili-ties,so as to realise the statement-less tags in the case of word-level and statement-level vulnerability interpretation.Experimental results on real Ethereum datasets SmartbugsWilds,SmartbugsCurated and SolidiFIBenchmark show that the proposed method achieves an average accuracy of more than 80%on five vulnerability types,with a 6%improvement in the accuracy of vulnerabili-ty interpretation,which can locate the vulnerable code more accurately and help developers to review contracts.

Smart contractVulnerability detectionAttention mechanismIntegrative gradients

李秋月、韩道军、张磊、许涛

展开 >

河南大学计算机与信息工程学院 河南开封 475004

河南财政金融学院计算机与人工智能学院 郑州 450002

河南省智能技术与应用工程技术研究中心 河南开封 475004

智能合约 漏洞检测 注意力机制 积分梯度

2024

计算机科学
重庆西南信息有限公司(原科技部西南信息中心)

计算机科学

CSTPCD北大核心
影响因子:0.944
ISSN:1002-137X
年,卷(期):2024.51(12)