arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2412.12039cs.CRcs.AIcs.CLcs.SE
收藏

LLM 提示能否作为漏洞检测中静态分析的代理

Can LLM Prompting Serve as a Proxy for Static Analysis in Vulnerability Detection

Columbia University(哥伦比亚大学);Amherst College(阿默斯特学院)

Ira Ceka, Feitong Qiao, Anik Dey, Aastha Valecha, Gail Kaiser, Baishakhi Ray

AI总结:

本研究探讨在部分代码设置下,LLM提示能否替代静态分析进行漏洞检测,提出结合自然语言指令与对比思维链的提示策略,利用DeepSeek-R1等模型显著提升了准确率与F1分数并降低了假阴性率。

摘要:

尽管大型语言模型(LLMs)取得了显著成功,但它们在安全关键代码任务(如漏洞检测)上的能力仍然有限。通常,静态分析(SA)工具(如 CodeQL、CodeGuru Security 等)被用于漏洞检测。SA 依赖于预定义的、人工编写的规则来标记各种漏洞。因此,SA 在检测漏洞方面的有效性取决于人类专家,并且已知具有较高的错误率。在本研究中,我们探讨了在部分代码设置下,LLM 提示能否成为这些静态分析器的有效替代方案。我们提出了将漏洞的自然语言指令与对比思维链推理相结合的提示策略,并使用来自合成数据集的对比样本进行增强。我们的研究结果表明,安全感知提示技术可以成为静态分析器中费时费力的人工编写规则的有效替代方案,这些人工规则在部分代码设置下通常会导致较高的假阴性率。当利用 DeepSeek-R1 等 SOTA 推理模型时,我们的每种提示策略都超越了静态分析器基线,其中最佳策略将准确率提高了 31.6%,F1 分数提高了 71.7%,成对准确率提高了 60.4%,并将 FNR 降低了 37.6%。

英文摘要:

Despite their remarkable success, large language models (LLMs) have shown limited ability on safety-critical code tasks such as vulnerability detection. Typically, static analysis (SA) tools, like CodeQL, CodeGuru Security, etc., are used for vulnerability detection. SA relies on predefined, manually-crafted rules for flagging various vulnerabilities. Thus, effectiveness of SA in detecting vulnerabilities depends on human experts and is known to report high error rates. In this study we investigate whether LLM prompting can be an effective alternative to these static analyzers in the partial code setting. We propose prompting strategies that integrate natural language instructions of vulnerabilities with contrastive chain-of-thought reasoning, augmented using contrastive samples from a synthetic dataset. Our findings demonstrate that security-aware prompting techniques can be effective alternatives to the laborious, hand-crafted rules of static analyzers, which often result in high false negative rates in the partial code setting. When leveraging SOTA reasoning models such as DeepSeek-R1, each of our prompting strategies exceeds the static analyzer baseline, with the best strategies improving accuracy by as much as 31.6%, F1-scores by 71.7%, pairwise accuracies by 60.4%, and reducing FNR by as much as 37.6%.

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

↑