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

📅 2026-06-29
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This study addresses a critical gap in understanding whether large language models (LLMs) are susceptible to human-like cognitive heuristics—such as the halo effect, framing effect, and anchoring bias—in the context of code vulnerability detection. The authors introduce a controlled experimental framework that manipulates contextual cues while keeping the underlying code fixed, enabling cross-model and cross-language evaluation across eight prominent LLMs and three programming languages. Combining quantitative analysis with fine-grained, code-level inspection, they find that all models exhibit significant susceptibility to cognitive biases, with an average 33.2% performance drop due to framing effects. Semantic vulnerabilities prove especially prone to heuristic interference, and models frequently misjudge code safety without accurately localizing flaws. Leveraging these insights, the authors propose a cognitive attack method capable of suppressing 97% of detected vulnerabilities, exposing fundamental weaknesses and suggesting avenues for robustness improvement.
📝 Abstract
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.
Problem

Research questions and friction points this paper is trying to address.

cognitive heuristics
code vulnerability detection
large language models
bias
LLM reliability
Innovation

Methods, ideas, or system contributions that make the work stand out.

cognitive heuristics
LLM vulnerability detection
framing effect
halo effect
anchoring effect