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

编辑时基于 Transformer 的代码漏洞检测:零样本、少样本还是微调?

Transformer-based Vulnerability Detection in Code at EditTime: Zero-shot, Few-shot, or Fine-tuning?

Microsoft(微软)

Aaron Chan, Anant Kharkar, Roshanak Zilouchian Moghaddam, Yevhen Mohylevskyy, Alec Helyar, Eslam Kamal, Mohamed Elkamhawy, Neel Sundaresan

AI总结:

本文提出利用预训练 LLM 的零样本、少样本与微调方法,在编辑时对不完整代码检测 250 多种漏洞,性能提升 10%,高风险场景漏洞最多减少 90%。

摘要:

软件漏洞给企业带来了巨大成本。尽管在软件漏洞检测方法的研究与开发方面已投入大量努力,未被发现的漏洞仍持续使软件所有者和用户处于风险之中。当前许多漏洞检测方法要求代码片段能够编译和构建,然后才尝试检测。遗憾的是,这会在漏洞被引入与被移除之间造成较长延迟,从而显著增加修复漏洞的成本。我们认识到,机器学习的最新进展可用于在开发者于 EditTime 编写代码时,对语法上不完整的代码片段检测易受攻击的代码模式。本文提出一个实用系统,利用深度学习在大规模易受攻击代码模式数据集上学习超过 250 种漏洞类型的复杂表现,并在 EditTime 检测易受攻击的代码模式。我们讨论了针对最先进的预训练大语言模型(LLM)的零样本、少样本和微调方法。结果表明,与最先进的漏洞检测模型相比,我们的方法将当前最优水平提升了 10%。我们还评估了该方法检测代码 LLM 自动生成代码中漏洞的能力。在高风险代码场景基准上的评估显示,漏洞最多减少 90%。

英文摘要:

Software vulnerabilities bear enterprises significant costs. Despite extensive efforts in research and development of software vulnerability detection methods, uncaught vulnerabilities continue to put software owners and users at risk. Many current vulnerability detection methods require that code snippets can compile and build before attempting detection. This, unfortunately, introduces a long latency between the time a vulnerability is injected to the time it is removed, which can substantially increases the cost of fixing a vulnerability. We recognize that the current advances in machine learning can be used to detect vulnerable code patterns on syntactically incomplete code snippets as the developer is writing the code at EditTime. In this paper we present a practical system that leverages deep learning on a large-scale data set of vulnerable code patterns to learn complex manifestations of more than 250 vulnerability types and detect vulnerable code patterns at EditTime. We discuss zero-shot, few-shot, and fine-tuning approaches on state of the art pre-trained Large Language Models (LLMs). We show that in comparison with state of the art vulnerability detection models our approach improves the state of the art by 10%. We also evaluate our approach to detect vulnerability in auto-generated code by code LLMs. Evaluation on a benchmark of high-risk code scenarios shows a reduction of up to 90% vulnerability reduction.

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

↑