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

检测Llama——利用大型语言模型发现智能合约中的漏洞

Detect Llama -- Finding Vulnerabilities in Smart Contracts using Large Language Models

Peter Ince, Xiapu Luo, Jiangshan Yu, Joseph K. Liu, Xiaoning Du

AI总结:

本文通过微调Code Llama和GPT-3.5构建Detect Llama模型,在智能合约漏洞检测中超越GPT-4,其中GPT-3.5FT和Detect Llama - Foundation在二元分类和漏洞识别上均取得更高F1分数。

摘要:

在本文中,我们检验了一个假设:尽管OpenAI的GPT-4在总体上表现良好,但我们可以通过微调开源模型,使其在智能合约漏洞检测方面超越GPT-4。我们基于Meta的Code Llama微调了两个模型,并使用包含17k提示的数据集,分别命名为Detect Llama - Foundation和Detect Llama - Instruct,同时我们还微调了OpenAI的GPT-3.5 Turbo模型(GPT-3.5FT)。随后,我们在我们开发的测试集上评估这些模型以及一个随机基线,与GPT-4和GPT-4 Turbo进行比较,针对数据集中的八种漏洞以及识别出的两个最突出的漏洞进行检测,并计算其加权F1分数。我们发现,对于二元分类(即该智能合约是否存在漏洞?),我们表现最好的两个模型GPT-3.5FT和Detect Llama - Foundation分别取得了0.776和0.68的F1分数,优于GPT-4的0.66和GPT-4 Turbo的0.675。在针对单个漏洞识别的评估中,我们的两个顶尖模型GPT-3.5FT和Detect Llama - Foundation在全部漏洞的加权F1上均显著优于GPT-4和GPT-4 Turbo(分别为0.61和0.56,对比GPT-4的0.218和GPT-4 Turbo的0.243),并且在识别出的两个最突出漏洞的加权F1上也显著更优(GPT-3.5FT为0.719,Detect Llama - Foundation为0.674,对比GPT-4的0.363和GPT-4 Turbo的0.429)。

英文摘要:

In this paper, we test the hypothesis that although OpenAI's GPT-4 performs well generally, we can fine-tune open-source models to outperform GPT-4 in smart contract vulnerability detection. We fine-tune two models from Meta's Code Llama and a dataset of 17k prompts, Detect Llama - Foundation and Detect Llama - Instruct, and we also fine-tune OpenAI's GPT-3.5 Turbo model (GPT-3.5FT). We then evaluate these models, plus a random baseline, on a testset we develop against GPT-4, and GPT-4 Turbo's, detection of eight vulnerabilities from the dataset and the two top identified vulnerabilities - and their weighted F1 scores. We find that for binary classification (i.e., is this smart contract vulnerable?), our two best-performing models, GPT-3.5FT and Detect Llama - Foundation, achieve F1 scores of $0.776$ and $0.68$, outperforming both GPT-4 and GPT-4 Turbo, $0.66$ and $0.675$. For the evaluation against individual vulnerability identification, our top two models, GPT-3.5FT and Detect Llama - Foundation, both significantly outperformed GPT-4 and GPT-4 Turbo in both weighted F1 for all vulnerabilities ($0.61$ and $0.56$ respectively against GPT-4's $0.218$ and GPT-4 Turbo's $0.243$) and weighted F1 for the top two identified vulnerabilities ($0.719$ for GPT-3.5FT, $0.674$ for Detect Llama - Foundation against GPT-4's $0.363$ and GPT-4 Turbo's $0.429$).

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

↑