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

使用生成式预训练Transformer模型的自动化软件漏洞静态代码分析

Automated Software Vulnerability Static Code Analysis Using Generative Pre-Trained Transformer Models

Sandia National Laboratories(桑迪亚国家实验室);New Mexico Tech(新墨西哥理工学院)

Elijah Pelofske, Vincent Urias, Lorie M. Liebrock

AI总结:

本文评估了5个开源GPT模型在NIST SARD数据集上自动检测C/C++代码漏洞的效果,发现其假阳性与假阴性率过高,不适合全自动漏洞扫描,但在部分测试用例中表现优于随机采样,最佳模型Llama-2-70b-chat-hf在缓冲区溢出用例上实现了召回率与精确率均为1.0。

摘要:

生成式预训练Transformer模型已被证明在多种自然语言处理任务中表现出惊人的效果,包括生成计算机代码。我们评估了开源GPT模型在自动识别易受攻击的代码语法存在性任务中的有效性(具体针对C和C++源代码)。该任务在来自NIST SARD数据集的36个源代码示例上进行评估,这些示例经过专门筛选,不包含表明特定漏洞存在与否的自然英语。NIST SARD源代码数据集包含已识别的易受攻击源代码行,这些代码行是839个不同通用弱点枚举(CWE)之一的示例,从而可以精确量化GPT输出分类错误率。共评估了5个GPT模型,使用10种不同的推理温度和每种设置下100次重复,导致每个被分析的易受攻击源代码产生5,000次GPT查询。最终,我们发现所评估的GPT模型不适合全自动漏洞扫描,因为假阳性和假阴性率过高,在实践中可能难以发挥作用。然而,我们确实发现GPT模型在某些测试用例的自动化漏洞检测中表现得出奇地好,特别是超过了随机采样,并且能够识别出易受攻击的确切代码行,尽管成功率较低。发现表现最佳的GPT模型结果是Llama-2-70b-chat-hf,推理温度为0.1,应用于NIST SARD测试用例149165(这是一个缓冲区溢出漏洞的示例),其正确且唯一地识别易受攻击代码行和正确CWE编号的二元分类召回率为1.0,精确率为1.0。

英文摘要:

Generative Pre-Trained Transformer models have been shown to be surprisingly effective at a variety of natural language processing tasks -- including generating computer code. We evaluate the effectiveness of open source GPT models for the task of automatic identification of the presence of vulnerable code syntax (specifically targeting C and C++ source code). This task is evaluated on a selection of 36 source code examples from the NIST SARD dataset, which are specifically curated to not contain natural English that indicates the presence, or lack thereof, of a particular vulnerability. The NIST SARD source code dataset contains identified vulnerable lines of source code that are examples of one out of the 839 distinct Common Weakness Enumerations (CWE), allowing for exact quantification of the GPT output classification error rate. A total of 5 GPT models are evaluated, using 10 different inference temperatures and 100 repetitions at each setting, resulting in 5,000 GPT queries per vulnerable source code analyzed. Ultimately, we find that the GPT models that we evaluated are not suitable for fully automated vulnerability scanning because the false positive and false negative rates are too high to likely be useful in practice. However, we do find that the GPT models perform surprisingly well at automated vulnerability detection for some of the test cases, in particular surpassing random sampling, and being able to identify the exact lines of code that are vulnerable albeit at a low success rate. The best performing GPT model result found was Llama-2-70b-chat-hf with inference temperature of 0.1 applied to NIST SARD test case 149165 (which is an example of a buffer overflow vulnerability), which had a binary classification recall score of 1.0 and a precision of 1.0 for correctly and uniquely identifying the vulnerable line of code and the correct CWE number.

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

↑