[论文解读] ACFIX: Guiding LLMs with Mined Common RBAC Practices for Context-Aware Repair of Access Control Vulnerabilities in Smart Contracts
ACFIX 使用挖掘的 RBAC 分类和基于上下文的 prompts 与 GPT-4 来修复智能合约中的访问控制漏洞,相对于基线 GPT-4 有显著改进,并实现与人类修补一致的补丁。
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%.
研究动机与目标
- 在现实世界的智能合约中识别常见的 RBAC(基于角色的访问控制)实践,并构建一个动态的 RBAC 分类体系。
- 利用静态代码分析构建一个 AC 上下文图(ACG),用于指导补丁生成。
- 通过 RBAC 分类和上下文图来引导 GPT-4 生成针对 AC 漏洞的正确补丁。
- 使用专用验证器对补丁进行验证,以确保与 RBAC 策略的一致性并防止回归。
- 对 ACFIX 相对于最先进工具进行基准测试,并评估与人工修复的一致性。
提出的方法
- 对 344,251 个链上智能合约进行离线挖掘 RBAC 实践,建立包含 49 对角色-权限的分类体系。
- 静态切片以在易受攻击的函数周围构建一个 AC 上下文图(ACG)。
- 在线双代理(生成器与验证器)MAD 框架引导 LLM 选择合适的角色-权限对并生成补丁(连带推理提示)。
- 补丁经静态检查,并由验证器进行迭代验证,以确保语义正确性和 RBAC 一致性。
- 在包含 118 个真实世界 AC 漏洞案例的基准上评估,ACFIX 的修复率为 94.92%,相比 GPT-4 基线的 52.54%。
- 与最先进的修复工具进行对比,并进行消融研究以评估上下文和分类的贡献。
实验结果
研究问题
- RQ1挖掘的 RBAC 模式能否有效引导 LLM 在智能合约中修复 AC 漏洞?
- RQ2将 AC 上下文图和 RBAC 分类引入是否比纯粹的 LLM 修复在补丁准确性和语义一致性方面有所提升?
- RQ3在真实世界的 AC 案例中,ACFIX 相比基线 GPT-4 和其他最先进的漏洞修复工具的表现如何?
- RQ4MAD 框架中验证器对修复成功率和质量的影响是什么?
主要发现
- ACFIX 在基准测试中修复了 94.92% 的 AC 漏洞,显著高于 GPT-4 基线的 52.54%。
- 消融研究显示,丰富上下文和分类能提升修复效果(仅 GPT-4 固定为 52.54%)。
- 验证器组件将修复有效性从 87.28% 提升到 94.92%。
- 人工专家在很大程度上与 ACFIX 的修复一致,在开放问题上有时甚至超越;而许多修复对于人类单独进行并不简单。
- RBAC 分类捕获了 49 对角色-权限,覆盖了在链上合约中观察到的大多数常见的 AC 实践。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。