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

基于提示的本地LLM循环漏洞检测框架

A Prompt-Based Framework for Loop Vulnerability Detection Using Local LLMs

Brilloconnetz Partners avoin yhtiö(Brilloconnetz Partners 普通合伙);Department of Computing, University of Turku(图尔库大学计算系)

Adeyemi Adeseye, Aisvarya Adeseye

AI总结:

本文提出基于本地LLM的循环漏洞检测框架,利用提示技术提高代码分析的准确性和安全性,验证Phi模型在性能上的优势。

摘要:

循环漏洞是软件开发中的主要风险构造。它们容易导致无限循环或执行,耗尽资源,或引入逻辑错误,从而降低性能并影响安全性。传统静态分析工具往往无法检测此类问题,因为这些工具依赖于语法模式,使其难以检测语义缺陷。因此,大型语言模型(LLMs)为漏洞检测提供了新的潜力,因为它们能够理解代码的上下文。此外,本地LLM不同于商业模型如ChatGPT或Gemini,通过促进高效的离线分析来解决隐私、延迟和依赖性问题。因此,本研究提出了一种基于提示的框架,利用本地LLM检测Python 3.7+代码中的循环漏洞。该框架针对三种类型的循环相关问题,如控制和逻辑错误、循环内的安全风险以及资源管理的低效性。设计并测试了一个通用且结构化的提示基于框架,通过迭代提示引导两个本地部署的LLM(LLaMA 3.2;3B和Phi 3.5;4B)的行为。设计的提示基于框架包括关键的安全保障功能,如语言特定意识、代码感知接地、版本敏感性和幻觉预防。LLM的结果通过手动建立的基准真相进行验证,结果表明Phi在精度、召回率和F1分数上优于LLaMA。发现强调了为本地LLM设计有效的提示以进行安全且准确的代码漏洞分析的重要性。

英文摘要:

Loop vulnerabilities are one major risky construct in software development. They can easily lead to infinite loops or executions, exhaust resources, or introduce logical errors that degrade performance and compromise security. The problem are often undetected by traditional static analyzers because such tools rely on syntactic patterns, which makes them struggle to detect semantic flaws. Consequently, Large Language Models (LLMs) offer new potential for vulnerability detection because of their ability to understand code contextually. Moreover, local LLMs unlike commercial ones like ChatGPT or Gemini addresses issues such as privacy, latency, and dependency concerns by facilitating efficient offline analysis. Consequently, this study proposes a prompt-based framework that utilize local LLMs for the detection of loop vulnerabilities within Python 3.7+ code. The framework targets three categories of loop-related issues, such as control and logic errors, security risks inside loops, and resource management inefficiencies. A generalized and structured prompt-based framework was designed and tested with two locally deployed LLMs (LLaMA 3.2; 3B and Phi 3.5; 4B) by guiding their behavior via iterative prompting. The designed prompt-based framework included key safeguarding features such as language-specific awareness, code-aware grounding, version sensitivity, and hallucination prevention. The LLM results were validated against a manually established baseline truth, and the results indicate that Phi outperforms LLaMA in precision, recall, and F1-score. The findings emphasize the importance of designing effective prompts for local LLMs to perform secure and accurate code vulnerability analysis.

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

↑