跳到正文
arXiv cs.AI· Chieh-Yuan Chang, Guan-Wei Chen, Chia-Yi Hsu, Chih Yang, Chia-Mu Yu, Chun-Ying Huang·· 14 小时前AI 评分48

NameTrap:仅靠重命名变量名即可诱导 AI 编程智能体引入安全漏洞

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

AI 导读

NameTrap 是一种源码投毒攻击,只重命名第三方 Python 文件中的标识符,就能在无任何显式指令的情况下诱导 AI 编程智能体生成攻击者指定的 CWE 漏洞。

正文 · 原文

View PDF HTML (experimental)

Abstract: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.
Subjects: Cryptography and Security (cs.CR); Artificial Intelligence (cs.AI)
Cite as: arXiv:2610.34253 [cs.CR]
  (or arXiv:2610.34253v1 [cs.CR] for this version)
  https://doi.org/10.48550/arXiv.2610.34253

arXiv-issued DOI via DataCite (pending registration)

Submission history

From: Chia-Yi Hsu [view email]
[v1] Sun, 25 Oct 2026 12:29:23 UTC (1,538 KB)

来源:arXiv cs.AI · arxiv.org