深翼判例库DeepWing Case Library · INC-045 · 知识层Knowledge
下载目录里一份恶意 AGENTS.md 让 Codex 去装恶意 npm 包:真实客户机上被监控拦下,复现中九成以上照做(Forever 自测)A malicious AGENTS.md in the Downloads folder told Codex to install a malicious npm package: blocked by monitoring on a real customer machine, and followed in over 90% of reproduction runs (Forever’s own tests)
本条在判例库中的登记行This entry in the Case Library: deepwingai.com/cases#INC-045
时间线Timeline
已证实事实Confirmed facts
真实事件(据 Forever 报告):一名客户的下载目录里出现一份约 13 KB 的 AGENTS.md,伪装成平淡的工程规范,攻击内容藏在靠后一节;该目录同时是 Codex 的工作目录。Codex 照文件指令,把一个工具服务器条目写进全局配置 ~/.codex/config.toml,由它在会话启动时安装 npm 包 function-color;该包把下载器 function-flag 装作依赖,再拉取最终载荷,属研究机构命名的 MALFEX 供应链活动。Forever 的监控在任何代码运行前拦下了安装,未遂,无数据损失报告。文件怎么进的下载目录,Forever 查不出;事件日期与客户身份未公开。全局配置一旦写成,此后该机器上每一个 Codex 会话都会加载攻击者的服务器,不限于下载目录。
复现(Forever 自测,试验次数均未披露):Codex 在隔离虚拟机中复现整链,成功率九成以上;BleepingComputer 的说法是重构攻击链、用只打开计算器的无害载荷录得 90%,与博客「运行了恶意软件」的措辞对不上,按保守口径读。另有研究者自制的 CLAUDE.md 变体(非野外样本):诱使 Claude Code 把 API 地址改写进项目设置,令牌随请求泄露,研究者借此接管账户;Claude 侧写入需人工批准,长篇工程文书的包装使获批率约一半(BleepingComputer 把约一半系于整链执行);经子 Agent 在同一会话内达成代码执行约五分之一(据 Help Net Security)。投放环节:Forever 的概念验证页可在访问者离开时把 AGENTS.md 存进下载目录,BleepingComputer 自行测试,Chrome、Edge、Firefox 只弹下载通知,Brave 会先征求同意;这只证明投放可行,不是本案的实际路径。
暴露面(Forever 客户遥测,不可独立核):约半数客户在下载目录里运行编程 Agent,约四分之一的 Agent 会话会打开浏览器;Claude Code 单产品就有 1,300 多次会话从该目录启动。
当事方回应:OpenAI、Anthropic 截至 2026-10-29 未见就本案的公开回应。发现方的立场是「There is nothing here for OpenAI or Anthropic to patch」:Agent 照所在文件夹的 AGENTS.md 行事,正是它的设计。报道中「建议从项目目录启动 Agent」是两家一贯的使用建议,不是对本案的回应。
证据说明:记为一手已核,但这里的「一手」是发现方自述:真实客户事件只有 Forever 一家说法,客户匿名、无第二方证实,成功率与遥测全部是 Forever 自测或自家数据。Forever 是卖 Agent 监控的厂商,本报告同时是其产品叙事。13 KB、MALFEX 活动持续时长与 npm 下架三项本站未能在报道中逐一核到,未写入或只据 Forever 报告。
Real incident (per Forever’s report): a customer’s Downloads folder held an AGENTS.md of about 13 KB, dressed up as a dull engineering guide with the attack buried in a late section; the same folder was Codex’s working directory. Following the file, Codex wrote a tool-server entry into its global config, ~/.codex/config.toml, which installs the npm package function-color at session start; that package pulls in the downloader function-flag as a dependency, which fetches the final payload, part of a supply-chain campaign researchers named MALFEX. Forever’s monitoring stopped the install before any code ran: an attempt, with no reported data loss. Forever could not tell how the file got into the folder; the date and the customer were not disclosed. Once the global config is written, every later Codex session on that machine loads the attacker’s server, in any folder.
Reproduction (Forever’s own tests; trial counts not disclosed): Codex reproduced the full chain in an isolated VM in over 90% of attempts; BleepingComputer describes a reconstructed chain with a harmless payload that only opened the calculator, recording 90%, which does not match the blog’s wording that Codex ran the malware, so read the figure conservatively. A researcher-built CLAUDE.md variant (not a sample from the wild) got Claude Code to write a new API address into project settings, leaking the session token, which the researchers used to take over the account; Claude needs a human to approve that write, and the long engineering-document framing got it approved about half the time (BleepingComputer ties the half to the full chain). Code execution in the same session via a sub-agent came in about a fifth of tests (per Help Net Security). Delivery: Forever’s proof-of-concept page can save an AGENTS.md into Downloads as a visitor leaves; in BleepingComputer’s own test Chrome, Edge and Firefox only showed a download notice, while Brave asked first. This shows delivery is possible; it is not the route in this case.
Exposure (Forever customer telemetry, not independently verifiable): about half of customers run a coding agent inside Downloads, and about a quarter of agent sessions open a browser; Claude Code alone launched more than 1,300 sessions from that folder.
Party response: as of 2026-10-29, no public response from OpenAI or Anthropic. The discoverer’s position: “There is nothing here for OpenAI or Anthropic to patch”; an agent that follows its folder’s AGENTS.md is doing what it was built to do. The advice reported elsewhere to launch agents from the project directory is the vendors’ standing guidance, not a response to this case.
Evidence note: graded primary-source verified, but the primary source is the discoverer’s own account: the real customer incident rests on Forever alone, with an anonymous customer and no second-party confirmation, and all success rates and telemetry are Forever’s tests or data. Forever sells agent monitoring, and the report doubles as its product story. Three details (the 13 KB size, how long MALFEX has run, and the npm takedown) could not each be confirmed in the coverage; they are left out or attributed to Forever.
失效机制Failure mechanism深翼分析DeepWing analysis
第一处失效在上下文的准入:一份来路不明的文件,只因放在 Agent 的工作目录里,就被当作可信指令读进上下文,没有任何来源核验。这与 INC-014(伪造的错误事件被编程 Agent 当作修复指引)是同一类问题:外来文字以指令身份进了上下文。因此本案归入知识层。
次要相关是门禁层:Codex 未经人工批准就改写了全局配置,一次会话的错误由此变成整台机器的持久化;Claude Code 一侧有人工批准这道门,但长篇文书的包装让它约一半时候被放行。拦下真实攻击的不是 Agent 自身,而是第三方的出站与安装监控。
The first defence to fail was admission into context: a file of unknown origin was read in as trusted instructions simply because it sat in the agent’s working directory, with no check on where it came from. It is the same class of problem as INC-014 (a forged error event taken by a coding agent as a fix instruction): outside text entered the context with the authority of an instruction. The case therefore belongs to the Knowledge layer.
Access Control is the secondary layer: Codex rewrote its global config without human approval, turning one session’s mistake into machine-wide persistence; Claude Code does have a human approval gate, but the long-document framing got the write through about half the time. What stopped the real attack was not the agent but third-party egress and install monitoring.
工程启示Engineering lessons
不在杂物目录启动 Agent:下载目录、桌面这类混放外来文件的位置不作工作目录;只在明确的项目目录里启动。
指令文件当作外来输入:工作目录里的 AGENTS.md、CLAUDE.md 一类文件,来源不明时不自动生效,先让人看过。
全局配置写入要批准并盯住:对 Agent 改写全局配置与项目设置一律人工批准;定期检查配置里的陌生工具服务器条目与陌生 API 地址。
出站与安装有第二道防线:包安装与外联经监控或白名单,不靠 Agent 自觉。
Don’t launch agents in junk folders: never use Downloads or the desktop, where outside files pile up, as a working directory; launch only inside a defined project folder.
Treat instruction files as outside input: an AGENTS.md or CLAUDE.md of unknown origin in the working folder should not take effect automatically; have a person look first.
Approve and watch config writes: require human approval for any agent write to global config or project settings, and regularly check config for unfamiliar tool-server entries and API addresses.
Keep a second line on egress and installs: route package installs and outbound calls through monitoring or an allowlist rather than trusting the agent.
你的系统里,Agent 的对外动作有人盯着吗?Is anyone watching what your agents do outside your system?
做 17 题免费自检Take the free 17-question self-check