---
title: "言语胜于代码：探究LLM在代码漏洞检测中的认知启发式偏差"
source: "arXiv AI/CL/LG（论文）"
source_tier: "t2"
url: "https://arxiv.org/abs/2606.30587v1"
permalink: "https://feed.astralor.com/items/itm_39a62d7426540c6cd05dcfdb"
published: "2026-06-29T17:31:10.000Z"
score: 59
channel: "ai"
tags: ["代码漏洞检测","大型语言模型","晕轮效应","框架效应","认知启发式","锚定效应"]
---

# 言语胜于代码：探究LLM在代码漏洞检测中的认知启发式偏差

## 速览

这篇论文首次系统探索了大型语言模型（LLM）在代码漏洞检测中是否受认知启发式偏差影响。作者设计了一个控制框架，在固定代码的前提下，仅改变周围语境来触发晕轮效应、框架效应和锚定效应等三种启发式。实验评估了8种LLM在三种编程语言上的表现，结果表明所有模型均易受这些偏差影响，其中框架效应影响最大（33.2%），其次是锚定效应（23.5%）和晕轮效应（18.4%）。代码级分析显示，需要语义推理的漏洞比模式匹配可识别的漏洞更易受启发式影响。此外，模型常常在认知条件下将安全判定改为脆弱，且未能准确识别实际漏洞。作者还展示了概念验证的黑盒认知攻击，可抑制高达97%之前检测到的漏洞。结论表明认知易感性是LLM漏洞检测的一致且可利用的特性。

## 关键点

- 首次系统研究LLM在代码漏洞检测中的认知启发式偏差。
- 框架效应影响最大（33.2%），锚定效应次之（23.5%），晕轮效应最小（18.4%）。
- 需要语义推理的漏洞比模式匹配漏洞更易受启发式影响。
- 概念验证黑盒攻击可抑制97%之前检测到的漏洞。

## 全文

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.

---

引用前请核对原文;本文由星际流动整理:https://feed.astralor.com/items/itm_39a62d7426540c6cd05dcfdb
