mlsanityData to 24 Nov 2026

NameTrap: Steering AI Coding Agents Toward Security Vulnerabilities via Variable Names

arXiv 2610.34253 ↗Submitted 25 Oct 2026cs.CR cs.AIcited by 0

On the map: LLM agents and tool use → Agent threats, guardrails and governance

Abstract (arXiv)

AI coding agents routinely clone repositories, install packages, and read source code obtained from the Web, so publicly hosted code becomes part of the context that shapes the code they write. We show that this Web-borne context can be weaponized without any explicit instruction. We present NameTrap, a source-code poisoning attack that only renames identifiers in third-party Python files to steer AI coding agents toward attacker-targeted Common Weakness Enumeration (CWE) vulnerabilities. An attacker-side coding agent iteratively aligns identifiers with a CWE-specific naming convention and confirms through local probe completions that the renamed file elicits the target weakness, while the released bait contains neither instructions nor vulnerable statements. We evaluate NameTrap across six AI coding agents, ten underlying language models, and four vulnerability categories: CWE-78, CWE-79, CWE-327, and CWE-502. Starting from files whose clean versions never yield the targeted CWE, identifier-level manipulation achieves overall attack success rates of 22.5% to 56.0% across the six agents, reaching 75.0% for certain agent--model configurations, and substantially outperforms random renaming, neutral renaming, and the prior identifier-poisoning attack XOXO. The attack remains effective under Traditional Chinese prompts and transfers across models, while a security-reminder defense fails to consistently prevent vulnerability introduction. Moreover, three AI-based security analyzers and four static analyzers report none of the targeted weaknesses in the poisoned files. These findings expose an overlooked attack surface of agents that consume Web content: seemingly harmless variable names in untrusted, Web-hosted code can compromise the security of downstream software.

Key facts. No citing papers in the map yet (data through 24 Nov 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 23 of its 44 references that are in the map. Submitted 25 Oct 2026.

Builds on

23 of 44 references.

Closest ancestors · 3

Same direction, newest first

  1. 2024EIA: Environmental Injection Attack on Generalist Web Agents for Privacy Leakage17 Sep
  2. 2024AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Bases17 Jul
  3. 2023Identifying the Risks of LM Agents with an LM-Emulated Sandbox25 Sep

Other references · 20

  1. 2024OpenHands: An Open Platform for AI Software Developers as Generalist Agentscited by 1,155
  2. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 926
  3. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 622
  4. 2024The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructionscited by 568
  5. 2024StruQ: Defending Against Prompt Injection with Structured Queriescited by 433
  6. 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 387
  7. 2023RepoBench: Benchmarking Repository-Level Code Auto-Completion Systemscited by 384
  8. 2022Do Users Write More Insecure Code with AI Assistants?cited by 202
  9. 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 165
  10. 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 135
  11. 2022ReCode: Robustness Evaluation of Code Generation Modelscited by 114
  12. 2022Natural Attack for Pre-trained Models of Codecited by 78
8 more
  1. 2024We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMscited by 72
  2. 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 71
  3. 2019Adversarial Examples for Models of Codecited by 66
  4. 2023TrojanPuzzle: Covertly Poisoning Code-Suggestion Modelscited by 65
  5. 2022CodeAttack: Code-Based Adversarial Attacks for Pre-trained Programming Language Modelscited by 54
  6. 2023Stealthy Backdoor Attack for Code Modelscited by 52
  7. 2024An LLM-Assisted Easy-to-Trigger Backdoor Attack on Code Completion Models: Injecting Disguised Vulnerabilities against Strong Detectioncited by 43
  8. 2026RealSec-bench: A Benchmark for Evaluating Secure Code Generation in Real-World Repositoriescited by 16

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2025"Your AI, My Shell": Demystifying Prompt Injection Attacks on Agentic AI Coding Editors
  2. 2025Breaking the Code: Security Assessment of AI Code Agents Through Systematic Jailbreaking Attacks
  3. 2026Setup Complete, Now You Are Compromised: Weaponizing Setup Instructions Against AI Coding Agents
  4. 2024RedCode: Risky Code Execution and Generation Benchmark for Code Agents
  5. 2026Authority Is Not a String: A Capability-Scoped Harness for Prompt-Injection-Resistant Coding Agents
  6. 2026Prompt Injection Attacks on Agentic Coding Assistants: A Systematic Analysis of Vulnerabilities in Skills, Tools, and Protocol Ecosystems
  7. 2025SecureVibeBench: Benchmarking Secure Vibe Coding of AI Agents via Reconstructing Vulnerability-Introducing Scenarios
  8. 2026IssueTrojanBench: Benchmarking AI Coding Agents Against Malicious Issue Requests