[论文解读] When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?
本文评估了ChatGPT在使用SmartBugs数据集检测智能合约漏洞方面的有效性,发现其召回率较高但精确率较低,尤其在某些漏洞类型上表现明显。研究识别出导致误报的四个根本原因,并将ChatGPT与11种最先进工具进行对比,发现其仅在七类漏洞中的四类表现优于其他工具,凸显其在鲁棒性和代码长度处理方面的局限性。
With the development of blockchain technology, smart contracts have become an important component of blockchain applications. Despite their crucial role, the development of smart contracts may introduce vulnerabilities and potentially lead to severe consequences, such as financial losses. Meanwhile, large language models, represented by ChatGPT, have gained great attentions, showcasing great capabilities in code analysis tasks. In this paper, we presented an empirical study to investigate the performance of ChatGPT in identifying smart contract vulnerabilities. Initially, we evaluated ChatGPT's effectiveness using a publicly available smart contract dataset. Our findings discover that while ChatGPT achieves a high recall rate, its precision in pinpointing smart contract vulnerabilities is limited. Furthermore, ChatGPT's performance varies when detecting different vulnerability types. We delved into the root causes for the false positives generated by ChatGPT, and categorized them into four groups. Second, by comparing ChatGPT with other state-of-the-art smart contract vulnerability detection tools, we found that ChatGPT's F-score is lower than others for 3 out of the 7 vulnerabilities. In the case of the remaining 4 vulnerabilities, ChatGPT exhibits a slight advantage over these tools. Finally, we analyzed the limitation of ChatGPT in smart contract vulnerability detection, revealing that the robustness of ChatGPT in this field needs to be improved from two aspects: its uncertainty in answering questions; and the limited length of the detected code. In general, our research provides insights into the strengths and weaknesses of employing large language models, specifically ChatGPT, for the detection of smart contract vulnerabilities.
研究动机与目标
- 评估ChatGPT在多种漏洞类型下检测智能合约漏洞的有效性。
- 识别并分类ChatGPT在漏洞检测过程中生成误报的根本原因。
- 将ChatGPT的性能与11种最先进的智能合约漏洞检测工具进行对比。
- 分析ChatGPT在此领域中的局限性,特别是响应不确定性与代码长度限制方面。
- 为使用类似ChatGPT的大型语言模型进行区块链安全检测提供实际可行性见解与改进需求。
提出的方法
- 本研究采用广泛使用的SmartBugs-整理数据集,其中包含9个DASP10定义的漏洞类别下的142个存在漏洞的智能合约。
- 设计了标准化提示,用于指导ChatGPT(GPT-3.5和GPT-4)检测九类漏洞。
- 采用标准指标(精确率、召回率、F1值)评估性能,以量化检测效果。
- 系统性地分析并分类误报,分为四类:保护机制偏差、开发意图偏差、注释干扰、死代码干扰。
- 在相同数据集上与11种最先进工具(如Mythril、Confuzzius)进行对比评估,以基准化性能表现。
- 分析还考察了ChatGPT的局限性,特别是其响应的不稳定性以及输入代码长度的限制。
实验结果
研究问题
- RQ1RQ1:ChatGPT在检测智能合约漏洞方面的有效性如何?其在不同漏洞类型上的表现有何差异?
- RQ2RQ2:ChatGPT的检测性能与其它最先进的智能合约漏洞检测工具相比如何?
- RQ3RQ3:ChatGPT在智能合约漏洞检测中生成误报的根本原因是什么?
- RQ4RQ4:在此背景下,ChatGPT的关键局限性是什么,特别是关于鲁棒性和输入长度方面?
主要发现
- GPT-3.5的召回率为51.4%,GPT-4达到88.2%,表明其具备识别大量真实漏洞的强大能力。
- 然而,精确率较低,GPT-3.5仅为19.7%,GPT-4为22.6%,表明误报率较高。
- 对于Short Address Attack等特定漏洞,GPT-3.5和GPT-4表现均不佳,而在Unchecked Return Values漏洞上表现良好。
- ChatGPT在检测Front Running和Denial of Service漏洞方面优于其余11种工具,但其F1值分别仅为12.8%和15.9%。
- 误报主要源于四类原因:保护机制偏差、开发意图偏差、注释干扰和死代码干扰。
- ChatGPT的检测失败率高于81.8%的评估工具,且在鲁棒性和长代码输入处理方面存在局限。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。