基于GPT-4代码解释器的上下文驱动智能合约共审计方法
A Context-Driven Approach for Co-Auditing Smart Contracts with The Support of GPT-4 code interpreter
AI总结:
本文提出一种基于GPT-4代码解释器的上下文驱动智能合约共审计方法,通过优化提示设计提升漏洞检测效率。
摘要:
智能合约的广泛应用亟需严格审计以确保其安全性和可靠性。虽然手动审计虽然全面,但耗时且高度依赖审计员的专业知识。随着大语言模型(LLMs)的兴起,人们越来越关注利用它们协助审计员进行审计过程(共审计)。然而,LLMs在智能合约共审计中的有效性取决于输入提示的设计,尤其是在上下文描述和代码长度方面。本文介绍了一种新的上下文驱动提示技术用于智能合约共审计。我们的方法采用三种技术进行上下文范围和增强,包括代码范围以根据代码依赖性将长代码分成自包含的代码段,评估范围以根据目标评估目标增强上下文描述,从而限制搜索空间,以及报告范围以强制生成响应的特定格式。通过在公开可用的易受攻击的合约上进行实证评估,我们的方法在检测易受攻击的功能方面表现出96%的检测率,优于原生提示方法,后者仅能检测到53%。为了评估我们提示方法的可靠性,通过我们合作伙伴Quantstamp(世界领先的智能合约审计公司)的专家审计员进行了手动分析。专家的分析表明,在无标签数据集中,我们提出的方法提高了GPT-4代码解释器检测漏洞的效率。
英文摘要:
The surge in the adoption of smart contracts necessitates rigorous auditing to ensure their security and reliability. Manual auditing, although comprehensive, is time-consuming and heavily reliant on the auditor's expertise. With the rise of Large Language Models (LLMs), there is growing interest in leveraging them to assist auditors in the auditing process (co-auditing). However, the effectiveness of LLMs in smart contract co-auditing is contingent upon the design of the input prompts, especially in terms of context description and code length. This paper introduces a novel context-driven prompting technique for smart contract co-auditing. Our approach employs three techniques for context scoping and augmentation, encompassing code scoping to chunk long code into self-contained code segments based on code inter-dependencies, assessment scoping to enhance context description based on the target assessment goal, thereby limiting the search space, and reporting scoping to force a specific format for the generated response. Through empirical evaluations on publicly available vulnerable contracts, our method demonstrated a detection rate of 96\% for vulnerable functions, outperforming the native prompting approach, which detected only 53\%. To assess the reliability of our prompting approach, manual analysis of the results was conducted by expert auditors from our partner, Quantstamp, a world-leading smart contract auditing company. The experts' analysis indicates that, in unlabeled datasets, our proposed approach enhances the proficiency of the GPT-4 code interpreter in detecting vulnerabilities.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。