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

超越函数级分析:面向跨过程的漏洞检测上下文感知推理

Beyond Function-Level Analysis: Context-Aware Reasoning for Inter-Procedural Vulnerability Detection

Singapore Management University(新加坡管理大学);Monash University(蒙纳士大学);GovTech, Singapore(新加坡政府科技局)

Yikun Li, Ting Zhang, Jieke Shi, Chengran Yang, Junda He, Xin Zhou, Jinfeng Jiang, Huihui Huang, Wen Bin Leow, Yide Yin, Eng Lieh Ouh, Lwin Khin Shar, David Lo

AI总结:

CPRVul通过结合上下文剖析与结构化推理,提升跨过程漏洞检测的准确性,其在多个数据集上均优于传统函数级方法。

摘要:

近年来,机器学习和大语言模型(LLM)的进步提升了漏洞检测能力,而近期的数据集已减少了标签噪声和无关代码变更。然而,大多数现有方法仍停留在函数级别,即模型被要求预测单个函数是否易受攻击,而没有跨过程的上下文。在实践中,漏洞的存在和根本原因往往依赖于上下文信息。简单地附加此类上下文并不是可靠的方法:现实中的上下文很长、冗余且嘈杂,我们发现无结构的上下文经常会降低强微调代码模型的性能。我们提出了CPRVul,一种上下文感知的漏洞检测框架,它将上下文剖析与选择与结构化推理相结合。CPRVul构建了一个代码属性图,并提取候选上下文。然后使用LLM生成以安全为导向的属性并分配相关性分数,选择仅高影响的上下文元素,这些元素适合在模型的上下文窗口内。在第二阶段,CPRVul将目标函数、所选上下文和辅助漏洞元数据结合起来,生成推理轨迹,这些轨迹用于微调LLM以进行基于推理的漏洞检测。我们在三个高质量的漏洞数据集上评估了CPRVul:PrimeVul、TitanVul和CleanVul。在所有数据集中,CPRVul始终优于仅函数的基线方法,准确率范围从64.94%到73.76%,相比UniXcoder的56.65%到63.68%。特别是,在具有挑战性的PrimeVul基准上,CPRVul达到了67.78%的准确率,优于先前的最先进方法,将准确率从55.17%提高到67.78%(提高了22.9%)。我们的消融实验进一步表明,单独的原始上下文或处理后的上下文对强代码模型没有好处;只有在处理后的上下文与结构化推理相结合时,才能获得收益。

英文摘要:

Recent progress in ML and LLMs has improved vulnerability detection, and recent datasets have reduced label noise and unrelated code changes. However, most existing approaches still operate at the function level, where models are asked to predict whether a single function is vulnerable without inter-procedural context. In practice, vulnerability presence and root cause often depend on contextual information. Naively appending such context is not a reliable solution: real-world context is long, redundant, and noisy, and we find that unstructured context frequently degrades the performance of strong fine-tuned code models. We present CPRVul, a context-aware vulnerability detection framework that couples Context Profiling and Selection with Structured Reasoning. CPRVul constructs a code property graph, and extracts candidate context. It then uses an LLM to generate security-focused profiles and assign relevance scores, selecting only high-impact contextual elements that fit within the model's context window. In the second phase, CPRVul integrates the target function, the selected context, and auxiliary vulnerability metadata to generate reasoning traces, which are used to fine-tune LLMs for reasoning-based vulnerability detection. We evaluate CPRVul on three high-quality vulnerability datasets: PrimeVul, TitanVul, and CleanVul. Across all datasets, CPRVul consistently outperforms function-only baselines, achieving accuracies ranging from 64.94% to 73.76%, compared to 56.65% to 63.68% for UniXcoder. Specifically, on the challenging PrimeVul benchmark, CPRVul achieves 67.78% accuracy, outperforming prior state-of-the-art approaches, improving accuracy from 55.17% to 67.78% (22.9% improvement). Our ablations further show that neither raw context nor processed context alone benefits strong code models; gains emerge only when processed context is paired with structured reasoning.

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

↑