arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2308.03314cs.CRcs.AIcs.SE
收藏

GPTScan:结合GPT与程序分析检测智能合约逻辑漏洞

GPTScan: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysis

Nanyang Technological University(南洋理工大学);MetaTrust Labs(MetaTrust实验室);East China Normal University(华东师范大学);Xi’an Jiaotong University(西安交通大学);Singapore Management University(新加坡管理大学)

Yuqiang Sun, Daoyuan Wu, Yue Xue, Han Liu, Haijun Wang, Zhengzi Xu, Xiaofei Xie, Yang Liu

AI总结:

本文提出GPTScan,将GPT作为代码理解工具与静态分析结合,通过场景-属性匹配和静态确认检测智能合约逻辑漏洞,在保持高精确率和召回率的同时实现快速低成本的审计。

摘要:

智能合约容易受到各种漏洞的影响,随着时间的推移导致大量财务损失。当前的智能合约分析工具主要针对具有固定控制流或数据流模式的漏洞,例如重入和整数溢出。然而,最近一项关于Web3安全漏洞的研究表明,由于缺乏领域特定的属性描述和检查,现有工具无法审计其中约80%的漏洞。鉴于大语言模型(LLMs)的最新进展,探索生成式预训练Transformer(GPT)如何帮助检测逻辑漏洞是值得的。\n\n在本文中,我们提出了GPTScan,这是第一个将GPT与静态分析相结合用于智能合约逻辑漏洞检测的工具。与其完全依赖GPT来识别漏洞——这可能导致高误报率并受限于GPT的预训练知识——我们将GPT用作一种通用的代码理解工具。通过将每种逻辑漏洞类型分解为场景和属性,GPTScan利用GPT匹配候选漏洞。为了提高准确性,GPTScan进一步指示GPT智能地识别关键变量和语句,然后通过静态确认对这些变量和语句进行验证。在包含约400个合约项目和3K个Solidity文件的多样化数据集上的评估表明,GPTScan在代币合约上实现了高精确率(超过90%),在Web3Bugs等大型项目上实现了可接受的精确率(57.14%)。它以超过70%的召回率有效检测真实逻辑漏洞,包括9个人工审计员遗漏的新漏洞。GPTScan快速且经济高效,扫描每千行Solidity代码平均耗时14.39秒,花费0.01美元。此外,静态确认帮助GPTScan减少了三分之二的误报。

英文摘要:

Smart contracts are prone to various vulnerabilities, leading to substantial financial losses over time. Current analysis tools mainly target vulnerabilities with fixed control or data-flow patterns, such as re-entrancy and integer overflow. However, a recent study on Web3 security bugs revealed that about 80% of these bugs cannot be audited by existing tools due to the lack of domain-specific property description and checking. Given recent advances in Large Language Models (LLMs), it is worth exploring how Generative Pre-training Transformer (GPT) could aid in detecting logicc vulnerabilities. In this paper, we propose GPTScan, the first tool combining GPT with static analysis for smart contract logic vulnerability detection. Instead of relying solely on GPT to identify vulnerabilities, which can lead to high false positives and is limited by GPT's pre-trained knowledge, we utilize GPT as a versatile code understanding tool. By breaking down each logic vulnerability type into scenarios and properties, GPTScan matches candidate vulnerabilities with GPT. To enhance accuracy, GPTScan further instructs GPT to intelligently recognize key variables and statements, which are then validated by static confirmation. Evaluation on diverse datasets with around 400 contract projects and 3K Solidity files shows that GPTScan achieves high precision (over 90%) for token contracts and acceptable precision (57.14%) for large projects like Web3Bugs. It effectively detects ground-truth logic vulnerabilities with a recall of over 70%, including 9 new vulnerabilities missed by human auditors. GPTScan is fast and cost-effective, taking an average of 14.39 seconds and 0.01 USD to scan per thousand lines of Solidity code. Moreover, static confirmation helps GPTScan reduce two-thirds of false positives.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑