arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2403.06838cs.SEcs.CR
收藏

ACFIX:利用挖掘的通用RBAC实践引导大语言模型对智能合约访问控制漏洞进行上下文感知修复

ACFIX: Guiding LLMs with Mined Common RBAC Practices for Context-Aware Repair of Access Control Vulnerabilities in Smart Contracts

Lyuye Zhang, Kaixuan Li, Kairan Sun, Daoyuan Wu, Ye Liu, Haoye Tian, Yang Liu

AI总结:

ACFIX通过从34万余个链上合约中挖掘通用RBAC实践并结合思维链引导GPT-4,实现了智能合约访问控制漏洞的上下文感知自动修复,在118个真实漏洞上修复率达94.92%。

摘要:

智能合约容易受到各种安全问题的影响,其中访问控制(AC)漏洞尤为关键。尽管现有研究已经提出了多种检测工具,但智能合约中AC漏洞的自动且恰当的修复仍然是一个挑战。与现有修复工具通常支持的漏洞类型(如重入漏洞,通常通过基于模板的方法修复)不同,AC的主要障碍在于需要在一长串与AC无关的源代码中识别适当的角色或权限,以生成正确的补丁代码,这一任务需要人类级别的智能。利用大语言模型(LLMs)的最新进展,我们采用了最先进的GPT-4模型,并通过一种名为ACFIX的新方法对其进行了增强。关键见解在于,我们可以针对主要类别的代码功能挖掘通用的AC实践,并利用这些实践来引导LLMs修复具有类似功能的代码。为此,ACFIX包含离线阶段和在线阶段。首先,在离线阶段,ACFIX从344,251个链上合约中挖掘出一套通用的基于角色的访问控制(RBAC)实践分类体系,从挖掘出的前1,000个角色-权限对中归纳出49个角色-权限对。其次,在在线阶段,ACFIX跟踪合约中与AC相关的元素,并利用这些上下文信息以及思维链(Chain-of-Thought)流水线来引导LLMs为目标合约识别最合适的角色-权限对,并随后生成合适的补丁。该补丁随后将接受有效性和有效性检查。为了评估ACFIX,我们构建了首个包含118个真实世界AC漏洞的基准数据集,我们的评估显示ACFIX成功修复了其中94.92%的漏洞。与基线GPT-4仅达到52.54%的修复率相比,这代表了显著的改进。

英文摘要:

Smart contracts are susceptible to various security issues, among which access control (AC) vulnerabilities are particularly critical. While existing research has proposed multiple detection tools, the automatic and appropriate repair of AC vulnerabilities in smart contracts remains a challenge. Unlike commonly supported vulnerability types by existing repair tools, such as reentrancy, which are usually fixed by template-based approaches, the main obstacle of AC lies in identifying the appropriate roles or permissions amid a long list of non-AC-related source code to generate proper patch code, a task that demands human-level intelligence. Leveraging recent advancements in large language models (LLMs), we employ the state-of-the-art GPT-4 model and enhance it with a novel approach called ACFIX. The key insight is that we can mine common AC practices for major categories of code functionality and use them to guide LLMs in fixing code with similar functionality. To this end, ACFIX involves both offline and online phases. First, during the offline phase, ACFIX mines a taxonomy of common Role-based Access Control (RBAC) practices from 344,251 on-chain contracts, categorizing 49 role-permission pairs from the top 1,000 pairs mined. Second, during the online phase, ACFIX tracks AC-related elements across the contract and uses this context information along with a Chain-of-Thought pipeline to guide LLMs in identifying the most appropriate role-permission pair for the subject contract and subsequently generating a suitable patch. This patch will then undergo a validity and effectiveness check. To evaluate ACFIX, we built the first benchmark dataset of 118 real-world AC vulnerabilities, and our evaluation revealed that ACFIX successfully repaired 94.92% of them. This represents a significant improvement compared to the baseline GPT-4, which achieved only 52.54%.

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

↑