arxiv.org·2026/10/19
针对编码智能体面临的仓库级投毒风险,现有红队研究多依赖人工选点与固定伪装,作者提出首个自动化框架 TrojanForge:用AST把agent执行轨迹映射到代码节点得到任务可达候选点,经安全审查agent按可疑度倒序选出信任盲点挂载载荷,并与目标agent对抗迭代,把检测原因反转为改进约束且跨仓库迁移成功策略。据此构建 TrojanBench,含384个确定性验证的投毒仓库,覆盖6个领域、9种编程语言及多种载荷。相较基线,TrojanForge在DeepSeek harness上各载荷ASR最高,总体攻击成功率超 60%、后门植入超 90%;跨多个harness和模型的回放显示商业agent同样难防御,模型安全比harness护栏更重要。作者称多轮迭代成本高,仅公开验证工具与良性准备材料,不发布投毒管道和可执行样本。
为什么重要 编码 agent 已进入真实开发流程,仓库级投毒可在完成正常任务时触发数据外泄,团队需在 agent 工具链中加入代码审计环节。适合 做 coding agent 与代码安全审计的工程师
编码智能体的能力与自主性日益增强,这使它们暴露于仓库级投毒(repository-level poisoning)的风险之中。现有的红队测试(red-teaming)研究仍局限于对恶意载荷位置进行人工选择并采用固定的伪装策略,无法代表真实的仓库投毒。我们提出了TrojanForge,这是首个用于仓库投毒的自动化框架。
TrojanForge通过抽象语法树(AST)解析仓库结构,并将智能体的执行轨迹映射到AST节点上。一个安全审查智能体对这些候选节点进行排序,并选择其中最不显眼的节点用于载荷挂载。随后,通过与目标智能体进行对抗博弈,TrojanForge通过反推智能体检测出投毒的原因来迭代优化伪装策略,并将积累的成功经验跨仓库迁移。
我们进一步构建了TrojanBench,这是一个包含384个被投毒仓库的基准,涵盖6个领域和9种编程语言。大量实验表明,TrojanForge实现了超过60%的稳定投毒成功率,后门注入成功率超过90%。在TrojanBench上跨4种测试框架(harness)和12个模型开展的全面评估表明,即使是商用智能体也无法防御仓库级投毒。
Coding agents are increasingly capable with autonomy, which exposes them to repository-level poisoning.
Existing red-teaming studies remain restricted to manual selection for malicious payload locations and fixed disguise strategies, which cannot represent realistic repository poisoning.
We present TrojanForge, the first automated framework for repository poisoning.
TrojanForge parses repository structure through abstract syntax trees (AST) and maps agent execution traces onto AST nodes.
A security review agent ranks these candidates and selects the least conspicuous ones for payload mounting.
Then, through adversarial play with the target agent, TrojanForge iteratively refines disguise strategies by inverting the causes of agent detection, and transfers accumulated success experience across repositories.
We further construct TrojanBench, a benchmark of 384 poisoned repositories spanning 6 domains and 9 programming languages.
Extensive experiments show that TrojanForge achieves a stable poisoning success rate of over 60% with backdoor injection exceeding 90%.
Comprehensive evaluation on TrojanBench across 4 harnesses and 12 models reveals that even commercial agents fail to defend against repository-level poisoning.



EVIDENCE / METHODS
要点
编码 agent 能自主遍历仓库、编辑文件、执行命令,隐藏在仓库中的恶意逻辑会在它执行正常开发任务时被一并触发。
原版排版与图表 · 手机无法内嵌时可在浏览器打开。PDF 插件内选文不能传给网页助手。