Skip to content

Now You See It, Now You Don't: Manipulating the Perception and Attention of Code Vulnerability Detection LLM AgentsNow 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
School of Computer Science and Engineering, Nanjing University of Science and Technology; School of Cyber Science and Engineering, Nanjing University of Science and Technology; Department of Electrical and Electronic Engineering, The Hong Kong Polytechnic University; School of Cyber Science and Engineering, Southeast University
arXiv: Adversarial Attacks, Backdoors & PoisoningarXiv:2612.00836Originally published Indexed by this site · 17 hr agoAttacks

Quick read

Attacks

Based on the paper PDF (AI-generated); refer to the original

The authors propose a black-box attack, PAMA, that simultaneously manipulates the perception and LLM attention of code vulnerability detection agents; on three types of VDA driven by GPT-5.4, the average escape rate is 60.98%.

Threat modelThe attacker knows the original vulnerable code, vulnerability type, and root cause, but has only black-box knowledge of the victim VDA; the attacker can modify the source code and observe the labels and explanations for the original code, but cannot modify the VDA, tools, or execution environment. The goal is to preserve the vulnerability, cause the VDA to miss it or misattribute it, and maintain stealthiness.

Questions
Tool-augmented code vulnerability detection agents acquire structure, context or vulnerability knowledge, but whether this perception enhancement brings adversarial robustness remains unclear. The authors focus on how to interfere with both information acquisition and LLM reasoning while preserving the vulnerability.
Methods
PAMA combines four types of code transformations—IDF, LCD, NRJ, and DSC—first uses a small number of benign queries to infer the perception pattern of the victim VDA, then selects a matching combination to generate candidates, and sequentially checks syntax, perturbation budget, and vulnerability preservation.
Experiments and results
On 60 held-out samples from PrimeVul and on GPT-5.4-driven GRACE, JITVul, and Vul-RAG, PAMA achieves an average ER of 60.98%, while the three baselines achieve an average ER of 34.19%–35.75%. Its average CSIS is 0.593, and the manual Hit@1 is 29.0%.
Limitations and future work
The authors state that whether the conclusions generalize depends on more VDAs, models and vulnerability distributions, and that systems combining perception modes and adding a verification stage especially need to be examined. The experiments use 120 C/C++ samples, with 60 of them in the main evaluation; no dynamic vulnerability-triggering verification is reported.
Experimental setupGPT-5.4、DeepSeek-V4-Flash et al. · PrimeVul、GRACE et al. · ER、DRadv et al.
Metrics
ERDRadvCSISMacroERMode acc.Hit@1Hit@2Fleiss’ κTokens/AttackQueries/Success
AI summaryThe researchers propose a black-box attack framework, PAMA, which simultaneously manipulates the perception of code vulnerability detection LLM agents and the attention of the underlying LLM, achieving an average evasion rate of 60.98% across multiple vulnerability detection agents, 25.23% higher than the strongest baseline. A pilot evaluation shows that tool augmentation reduces the average evasion rate of existing attacks from 61.19% against LLM-based vulnerability detectors to 25.43% against agents, so an effective attack must simultaneously manipulate the underlying LLM and the agent's acquisition and integration of supplementary information. PAMA combines four strategies that manipulate lexical anchors, vulnerability-related logic, non-executable context, and defensive semantics, respectively, infers the victim agent's perception pattern and selects a matching combination, while verifying syntax, perturbation magnitude, and vulnerability preservation. The attack generalizes across four underlying LLMs, and the generated adversarial examples are the hardest for human evaluators to detect; each attack requires only 17,706.36 tokens, 2.7 to 5.8 times fewer than baselines.

The researchers propose a black-box attack framework, PAMA, which simultaneously manipulates the perception of code vulnerability detection LLM agents and the attention of the underlying LLM, achieving an average evasion rate of 60.98% across multiple vulnerability detection agents, 25.23% higher than the strongest baseline. A pilot evaluation shows that tool augmentation reduces the average evasion rate of existing attacks from 61.19% against LLM-based vulnerability detectors to 25.43% against agents, so an effective attack must simultaneously manipulate the underlying LLM and the agent's acquisition and integration of supplementary information. PAMA combines four strategies that manipulate lexical anchors, vulnerability-related logic, non-executable context, and defensive semantics, respectively, infers the victim agent's perception pattern and selects a matching combination, while verifying syntax, perturbation magnitude, and vulnerability preservation. The attack generalizes across four underlying LLMs, and the generated adversarial examples are the hardest for human evaluators to detect; each attack requires only 17,706.36 tokens, 2.7 to 5.8 times fewer than baselines.

Related events and news

1 events · 0 news mentions

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Studies whether tool augmentation improves the adversarial robustness of VDAs, and proposes a black-box attack that manipulates perception and attention simultaneously.

    The core question is: can an attacker, while preserving the target vulnerability, systematically manipulate the enhanced perception and reasoning of a vulnerability detection agent (VDA) so that it misses the vulnerability or misattributes it?

    • Research setting: The VDA obtains program structure, non-local context, or vulnerability knowledge through tools, and then reasons jointly with the source code. The authors argue that its decisions no longer depend only on the underlying LLM, but also on tool calls, the returned information, and how it is integrated.
    • Mismatch of existing attacks: Existing attacks mainly target standalone LLM-VDs. In preliminary experiments, three attacks achieved an average escape rate of 61.19% against LLM-VDs and 25.43% against VDAs (Table I); the authors accordingly argue that perception enhancement raises the bar for existing attacks, but this does not prove that VDAs themselves are robust.
    • Core observation: The authors propose a two-layer coupled attack surface. Attacker-controlled semantic anchors can influence the supplementary information the VDA obtains and associates; dispersed vulnerability clues and seemingly safe semantics may divert the LLM's attention and lead it to form benign hypotheses.
    • Proposed method: PAMA (Perception and Attention Manipulation Attack) combines four strategies, infers the perception pattern offline and selects a matching combination, then validates syntax, perturbation magnitude, and vulnerability preservation.
    • Threat model:
      • Goal: Generate syntactically valid candidates that preserve program behavior and the target vulnerability, cause the VDA to miss the vulnerability or give the wrong type or root cause, and limit the perturbation distance.
      • Knowledge: Knows the original vulnerable code, vulnerability type, and root cause; has only black-box knowledge of the VDA, not its parameters, training data, prompts, tool configuration, retrieval index, or internal state.
      • Capabilities: Can modify the source code, observe the labels and natural-language explanations for the original code, and passively collect historical outputs; candidate analysis, generation, and validation are performed locally.
      • Victim systems: Structure-enhanced GRACE, context-enhanced JITVul, and knowledge-enhanced Vul-RAG; the attacker cannot modify the VDA, external tools, or the execution environment.
  2. What related research exists?

    Related work is divided into LLM vulnerability analysis, three types of VDAs, and three types of adversarial code attacks; PAMA targets the tool-enhanced decision chain.

    LLM-driven vulnerability analysis

    • Assistive LLMs: Related work has LLMs identify sources/sinks, generate harnesses or complex inputs, guide fuzzing and concolic execution, and summarize code behavior; security tools still own the discovery process.
    • LLM-VDs: One class adapts models through vulnerability data, instruction tuning, or preference optimization, such as LLMxCPG [11], which is fine-tuned on CPG slices, and VULPO [26], which uses policy learning; another class fixes the model and organizes auditing through roles, reasoning flows, and output formats, such as Huynh et al. [18] and SpecAuditor [19]. The authors note that these systems still mainly analyze the input code rather than actively acquiring supplementary information.

    Tool-enhanced VDAs

    • Structure enhancement: GRACE [20] serializes graph nodes and edges, VulTriage [22] converts AST, CFG, and data-flow information into natural language, and VerilogLAVD [23] combines program graphs with graph traversal rules.
    • Context enhancement: Vuleval [24] studies repository-level context evaluation; DREA [44] retrieves repository context on demand, and JITVul [25] acquires cross-procedural context in a ReAct style.
    • Knowledge enhancement: Vul-RAG [28] abstracts vulnerability knowledge from historical CVEs, and LSAST [45] introduces vulnerability intelligence and matches high-risk patterns by code similarity.

    Adversarial code vulnerability attacks

    • Code obfuscation: reordering, splicing, renaming, and control-flow rewriting [32]–[34]. The paper states that such methods mainly change surface patterns, rely on predefined templates, and have limited stealthiness.
    • Feedback-driven: ITGen [35] uses Bayesian optimization to guide identifier replacement, CodeBreaker [36] combines feedback from multiple detectors for ranking, and CoTDeceptor [37] uses reasoning-chain feedback. The paper states that they depend on the completeness and accuracy of feedback, and code regions not covered may be ignored.
    • Model features: exploit gradients, attention, confidence, surrogate signals, or biases [40]–[43]; FPA [39] exploits familiar patterns to induce overgeneralization, and Flashboom [46] constructs decoy functions and secondary patches. The authors argue that their effectiveness may depend on model-specific sensitive features and may not transfer to different VDAs.

    Baselines and positioning of this paper

    • Baselines and data: Compares with Li et al. [34], CodeBreaker [36], and FPA [39], using real CVE samples from PrimeVul [48]; the victim systems are GRACE, JITVul, and Vul-RAG.
    • Difference: The authors position PAMA as a black-box attack targeting the VDA's complete decision process, perturbing not only the output-sensitive features of standalone detectors but simultaneously the mapping from code to supplementary information and the LLM's attention allocation.
  3. How does the paper address this problem?

    PAMA perturbs code with four composable strategies, completing the attack through offline pattern inference, matching-combination generation, and multiple validation steps.

    PAMA divides the attack into one-time offline perception pattern inference and an online attack; in the online phase, the attacker-controlled Analyzer and Generator perform feedback analysis, candidate generation, and validation.

    Vulnerability Abstraction and Strategy Contracts

    • The Analyzer abstracts a vulnerability as Gv=⟨ entry,propagation,trigger,sink,anchors,Psafe⟩, denoting the entry, propagation, trigger condition, dangerous operation, semantic anchors, and the safety condition required for a genuine fix, respectively.
    • Each strategy is written as a four-tuple of preconditions, allowed operations, postconditions, and evidence; the Generator receives a contract bound to a specific vulnerability, not merely a strategy name.
    • The four strategies have 15 non-empty combinations in total. The contract requires that the main modifications be traceable to a certain strategy, and rejects cases where one strategy undermines the effect of another.

    Four Composable Attack Strategies

    • IDF (Identifier Fragmentation): weakens the static lexical anchors of salient identifiers or literals, restoring the original values when execution requires them; applicable when the vulnerability has obvious lexical anchors such as API, command, or query fragments.
    • LCD (Logical-Chain Dispersion): stretches the logical chain from entry to trigger to dangerous operation through alias indirection, container encapsulation, and separation across helper functions; newly added nodes must still serve the original vulnerability chain.
    • NRJ (Non-executable-Region Injection): adds security narratives in non-executable or inert elements within the vulnerability's own semantic context, but does not introduce genuine protective operations; its placement and LCD's modification locations are constrained separately.
    • DSC (Defensive Semantic Camouflage): adds defensive structures that appear to handle the safety condition but in fact cannot guarantee it, while keeping the vulnerability reachable. Figure 1 gives independent examples of the four strategies; the appendix does not list attack prompts separately.

    Offline Perception Pattern Inference and Feedback Analysis

    • For each benign analysis feedback, the Analyzer labels it K, C, S, or none in order of diagnostic specificity: citing external vulnerability semantics is labeled K, concretely using context outside the fragment is labeled C, and substantive security analysis based on code behavior is labeled S.
    • Majority voting over multiple labels yields a structural, contextual, or knowledge pattern; this process does not train a model, access VDA internals, or require labeled data.
    • The online attack first submits the original vulnerable code, and only samples that "report the vulnerability and whose explanation matches a known root cause" are listed as attackable targets. The Analyzer uses ROUGE to compare the feedback summary with the known root cause, with a threshold of 0.34; when below the threshold, it revises the summary using code clues.
    • A language parser extracts elements such as function calls, variables, literals, branches, and boundary checks, and the Analyzer matches them against the normalized vulnerability profile to form key code elements and Gv.

    Candidate Generation, Validation, and Success Determination

    • Offline ranking selects pattern-matching combinations: GRACE and JITVul use IDF+LCD+NRJ, and Vul-RAG uses LCD+NRJ+DSC. The Generator takes as input the original code, vulnerability profile, key elements, and contract, and returns the complete candidate along with validation metadata such as vulnerability conditions and trigger paths.
    • Validation proceeds in order: syntax, perturbation budget, vulnerability preservation, and strategy postconditions. A full build environment is preferred for compilation checks; otherwise Tree-sitter is used; compilation errors or ERROR nodes lead to rejection.
    • The perturbation distance is Dist=α Distsem+β Distast, combining the cosine distance of code embeddings with the Jaccard distance of the AST parent-child edge sets; the experiments set α=0.6 and β=0.4, and filter when Dist>0.2.
    • Vulnerability preservation checks include the reachability of the trigger point from the entry, and whether the relevant inputs or states still satisfy the vulnerability conditions along the data flow. On failure, only the unsatisfied postconditions are returned for targeted regeneration.
    • Detection determination is consistent for the original code and the candidate: a correct detection requires the VDA to report the vulnerability and the explanation to match the target root cause; a candidate that is missed or misattributed counts as evaded.
  4. What experiments did the paper conduct?

    The experiments cover three VDAs and five detection backbones, and evaluate escape rate, cost, stealthiness, pattern inference, and cross-VDA transfer.

    Experimental Setup

    • Dataset: 120 real CVE-associated C/C++ vulnerability samples from PrimeVul, covering 20 CWE types, 6 each; split into non-overlapping profiling set and held-out evaluation set, 60 each, 3 per CWE type.
    • Victim systems: GRACE (structure), JITVul (context), Vul-RAG (knowledge). The main experiments all use GPT-5.4 as the detection model; the generalization experiments switch to DeepSeek-V4-Flash, GLM-4.7, Qwen3.7-Plus, and add LLMxCPG fine-tuned on QwQ-32B-Preview.
    • Baselines: the 12 fixed rule combinations of Li et al., CodeBreaker's candidates after 3 rounds of feedback optimization, FPA's best candidate among 12 familiar patterns per sample; PAMA uses the Rank-1 combination of pattern matching.
    • Metrics: ER=Candevaded/Candtested, where a candidate missed or misattributed counts as evaded; DRadv is the candidate detection rate. Strategy ranking additionally uses MacroER, averaged first within CWE categories and then across categories.
    • Generation and repetition: in the main experiments, each original sample generates 2 independent candidates, each tested once; in Table II, the Orig. Det. of PAMA, CodeBreaker and FPA is 27/60, 23/60, 25/60, and Li et al. uses a larger candidate budget.
    • Sampling settings: all LLMs use temperature=0.0, with default top p retained. The paper does not specify the concrete models used for the Analyzer and Generator, nor does it report statistical significance tests.

    Main Results

    According to Table II, the condition is GPT-5.4, held-out evaluation set; higher ER means a stronger attack.

    Swipe horizontally to read the table

    VDALi et al. ERCodeBreaker ERFPA ERPAMA ER (combination)
    GRACE (structure)33.64%27.78%46.30%55.56% (IDF+LCD+NRJ)
    JITVul (context)38.59%43.48%30.43%67.39% (IDF+LCD+NRJ)
    Vul-RAG (knowledge)30.33%36.00%28.00%60.00% (LCD+NRJ+DSC)
    Macro Avg.34.19%35.75%34.91%60.98%
    • Authors' interpretation: PAMA exceeds each VDA's strongest baseline on all three VDAs; the authors attribute the average advantage to the combination selection of perception-pattern matching rather than to any single favorable victim system.
    • Difficulty differences: the authors state that structure-enhanced VDAs remain harder to attack, and conjecture that explicit program relations are relatively stable under local rewrites.
    • Budget exception: Li et al. uses 600 candidate queries per VDA, while other methods use 50; its number of evaded CVEs is the highest on each VDA (27, 21, 25), but its average ER is the lowest. The authors explain this as a larger number of repeated attempts rather than a more stable attack direction.

    Attack Cost and Stealthiness

    • Cost: in Table III, PAMA uses 1 candidate per attack, Queries/Success=1.65, Tokens/Attack=17,706.36, Total Tokens=442,659; the authors state that its total token consumption is 1/2.7–1/5.8 of the baselines. Li et al.'s Tokens/Query=3,140.38, lower than PAMA's 8,853.18.
    • Automatic style metric: CSIS takes the larger of the empirical percentiles of local style and identifier style; lower is closer to surrounding code. In Table IV, PAMA's average CSIS=0.593, CodeBreaker=0.695, Li et al.=0.755, FPA=0.963; PAMA is 0.642, 0.600, 0.538 on GRACE, JITVul, Vul-RAG respectively.
    • Human evaluation: 10 evaluators with 2–5 years of C/C++ development or security analysis experience, 20 rounds per method, each round selecting 1 adversarial sample from 5 code segments, N=200/method. In Table S1, PAMA Hit@1=29.0%, Hit@2=48.0%, Fleiss' κ=0.083; random-guess baselines are 20% and 40% respectively.

    Strategy Selection, Pattern Inference and Generalization

    • Combination selection: Table V compares Rank-1, All-4 and Random. Rank-1's MacroER on GRACE, JITVul, Vul-RAG is 68.33%, 72.29%, 65.50% respectively, the highest in each row; All-4's average regeneration count is 2.957–3.040, Rank-1's is 0.852–1.130.
    • Pattern inference: Table VI performs 10 independent matching random-sampling trials for each budget. The average Mode acc. for 5, 10, 20, 30 profiling queries is 80.00%, 90.00%, 100.00%, 100.00% respectively; at 5 queries JITVul is only 40.00%, which the authors attribute to its explanations mixing structural and contextual cues.
    • Cross-backbone: Table VII fixes the combination selected under GPT-5.4; after changing the backbone, Overall Avg. ER=59.47%. The exception is LLMxCPG on JITVul with ER=47.37%; the authors state that as a shadow model it localizes code components less accurately than commercial backbones, and the retrieved context re-exposes vulnerability cues.

    Other Ablations and Analyses

    • Cross-VDA transfer: in Table S2, GRACE→JITVul is 65.63%, JITVul→GRACE is 53.13%; Vul-RAG→GRACE, JITVul are 42.11%, 53.13% respectively.
    • Category sensitivity: Figure S2 gives a MacroER heatmap of 15 combinations×5 categories; the authors state that no combination dominates in all categories of the same VDA.
    • Empty cells: JITVul's State-Control Errors is N/A; the paper explains that no original sample in this category met the victim detection criterion, not that ER is zero.
    • Transfer conditions: the source and target VDAs in Table S2 both use GPT-5.4 and the same detection configuration, differing only in the perception-enhancement pipeline.
    • Cost accounting: tokens are uniformly estimated offline with cl100k_base; PAMA's Pre-an. Tokens=116,757, FPA's is 560,000, and Li et al. and CodeBreaker are "–".
  5. What are some points that can be further explored?

    The authors propose category- or sample-adaptive selection and broadening the evaluation scope; existing evidence is mainly based on three VDAs and C/C++ CVEs.

    Limitations and Future Directions Noted by the Authors

    • Selection granularity: pattern-level combinations are not necessarily optimal for every sample; the authors propose future research on category-aware or sample-adaptive selection, trading off attack effectiveness against query budget (VII. Discussion, Strategy-selection granularity).
    • Extrapolation of conclusions: the authors state that the generality of the conclusions depends on whether the attack effectiveness persists across VDA designs, underlying models and vulnerability distributions (VII. Discussion, Evaluation scope and generality).
    • Broadening evaluation: the authors state that broader evaluations are also needed for other systems, languages and vulnerability distributions, especially VDAs that combine multiple perception modes or add a verification stage (VII. Discussion, Evaluation scope and generality).
    • Defense recommendations: the authors recommend adversarial regression testing before deployment, multi-view perception, cross-validation with program analysis, and attention-aware calibration; these are potential protective measures, not validated defenses (VII. Discussion, Defense implications and mitigations).

    Scope of Experimental Coverage

    • Data scope: 120 real C/C++ CVE samples from PrimeVul, covering 20 CWE types; the main attack evaluation uses 60 held-out samples, and candidates are generated only from samples that each VDA originally detected correctly (VI-A, Table II).
    • System scope: the victim VDAs are GRACE, JITVul, Vul-RAG, each representing one type of perception enhancement; the cross-backbone experiments report four models besides GPT-5.4, of which LLMxCPG is a vulnerability-specialized fine-tuned model (Table VII).
    • Verification method: vulnerability preservation uses static data-flow and control-flow checks; syntax verification falls back to Tree-sitter when a build environment is lacking, and the paper does not report dynamic execution or vulnerability-triggering tests (V-F).
    • Human evaluation scale: 10 evaluators, N=200 per method; inter-evaluator Fleiss' κ is reported, but the agreement between automatic detection judgments and human judgments is not reported (S1).
    • Implementation information: the paper does not specify the models used by the Analyzer and Generator; the main experiments generate two candidates per original sample and test each once, and each query budget in pattern inference is repeated 10 times (VI-B, VI-F).
  6. Summarize the main content of the paper

    PAMA extends VDA attacks to two layers, information acquisition and attention, and reports results on escape rate, cost, and stealthiness.

    This is a black-box attack study on code vulnerability detection agents, examining whether tool augmentation truly brings adversarial robustness.

    • Problem: VDAs acquire program structure, non-local context or vulnerability knowledge. The authors argue that an attack needs to affect both the acquisition and association of this information, as well as the underlying LLM's allocation of attention to source code and supplementary evidence.
    • Method: PAMA combines four strategies, IDF, LCD, NRJ and DSC, analyzes benign feedback offline to infer perception patterns, and selects pattern-matching combinations online; candidates must pass syntax, perturbation budget, vulnerability preservation and strategy contract checks.
    • Preliminary experiments: three existing attacks achieve an average ER of 61.19% against LLM-VD and 25.43% against the three VDAs (Table I). The authors conclude from this that tool augmentation weakens existing attacks but introduces a new code-dependent attack surface.
    • Main results: on GPT-5.4-driven GRACE, JITVul, Vul-RAG, PAMA's ER is 55.56%, 67.39%, 60.00% respectively, with Macro Avg. 60.98%; the three baselines' average ER is 34.19%–35.75% (Table II).
    • Cost and stealthiness: PAMA's Tokens/Attack is 17,706.36, average CSIS is 0.593; in the human odd-one-out, Hit@1 is 29.0%, versus 20% for random guessing (Table III, IV, S1).
    • Authors' conclusion: the authors state that PAMA exploits mechanism-level dependencies shared across perception patterns and models, rather than a single implementation detail; they also caution that stronger prompt constraints or the underlying LLM cannot be treated as a complete defense, and recommend cross-validating supplementary information against executable program behavior.

Research lineage

2 foundations · 0 follow-ups in library
Explore in knowledge graph →
This paper
Now You See It, Now You Don't: Manipulating Perception and Attention in Code Vulnerability Detection LLM Agents
2026-12-01
Follow-up work

No later in-library follow-ups recorded yet.

Hover or focus a connected paper to inspect the citation context.

Related papers

Read originalarxiv.org