探究LLM代码漏洞检测中的认知启发

Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detection

精选理由

想知道LLM有多容易受骗吗?这篇论文用实验告诉你,LLM检测漏洞时跟人一样有认知偏差,改个上下文就能让它放跑97%的漏洞。

AI 摘要

研究者首次系统探索认知启发对LLM代码漏洞检测的影响。他们构建控制框架,通过改变上下文触发光环、框架、锚定三种启发。在8个LLM和3种编程语言上的评估显示,所有模型均受影响:框架效应平均易感性最高(33.2%),锚定效应23.5%,光环效应18.4%。代码级分析表明,需语义推理的漏洞比模式匹配的更易受影响。此外,黑盒攻击可抑制高达97%之前检测到的漏洞。

原文 · arXiv cs.AI

Words Speak Louder Than Code: Investigating Cognitive Heuristics in LLM-Based Code Vulnerability Detection

Researchers and practitioners increasingly apply Large Language Models (LLMs) for automated vulnerability detection. Recent work has shown that LLMs are susceptible to the same cognitive heuristics that bias human judgment. Yet, no work has investigated whether these heuristics affect a model's assessment of code vulnerabilities. In this paper, we present the first systematic exploration of cognitive heuristics in LLM-driven code vulnerability detection. We introduce a controlled framework that holds the code fixed and only varies the surrounding context to trigger three cognitive heuristics: the halo effect through author attribution, the framing effect through task objectives and consequences, and the anchoring effect through prior analysis results. Within this framework, we evaluate eight LLMs across three programming languages and perform both quantitative and code-level analyses. Our findings demonstrate that all evaluated models are susceptible to these heuristics. Cross-model average susceptibility is highest for framing at 33.2%, followed by anchoring at 23.5% and halo at 18.4%. Code-level analysis reveals that vulnerabilities that require semantic reasoning for detection are more susceptible to cognitive heuristics than those identifiable through pattern matching. Furthermore, models often change their verdict from safe to vulnerable based on the cognitive condition, without accurately identifying the actual vulnerability. To highlight the practical impact, we demonstrate a proof-of-concept black-box cognitive attack that can suppress up to 97% of previously detected vulnerabilities. These findings indicate that cognitive susceptibility is a consistent and exploitable property of LLM-based vulnerability detection.

探究LLM代码漏洞检测中的认知启发 · AI 热点