Skip to content

Now You See It, Now You Don't: Manipulating Perception and Attention in Code Vulnerability Detection LLM Agents

Shanquan Yang, Boyu Kuang, Chunyi Zhou, Yifeng Zheng, Yansong Gao, Anmin Fu

cs.CR

Abstract

Emerging code vulnerability detection agents (VDAs) enhance conventional LLM-based vulnerability detectors (LLM-VDs) by using tools to acquire program structure, non-local context, or vulnerability knowledge, enabling reasoning beyond initial prompts. However, whether this perception augmentation provides adversarial robustness remains unknown. Our pilot evaluation reveals that tool augmentation reduces the average evasion rate of existing attacks from 61.19% against LLM-VDs to 25.43% against LLM-VDAs. This poses a new challenge: effective attacks must manipulate both the underlying LLM and the agent's code-dependent acquisition and integration of supplementary information. We uncover a coupled attack surface spanning VDA perception and LLM attention. Attacker-controlled semantic anchors influence what supplementary information a VDA acquires and associates with vulnerable code, while dispersed vulnerability cues and plausible safety semantics redirect the LLM toward an incorrect hypothesis. Based on this insight, we present PAMA (Perception and Attention Manipulation Attack), a black-box attack framework that jointly targets both layers. PAMA composes four strategies that manipulate lexical anchors, vulnerability-related logic, non-executable context, and defensive semantics. It systematically explores their combinations, infers the victim's perception mode, and selects a mode-matched combination while validating syntax, perturbation magnitude, and vulnerability preservation. PAMA achieves a 60.98% average evasion rate across diverse LLM-VDAs, outperforming the strongest baseline by 25.23%. It generalizes across four underlying LLMs and generates adversarial samples that are hardest for human evaluators to detect. Furthermore, PAMA is highly cost-efficient, requiring only 17,706.36 tokens per attack (2.7 to 5.8 less than baselines).

Create a lesson

Metadata

Comments
Our artifact is available at https://github.com/dierye/PAMA_public.git