Forever Security:Downloads 中的恶意 AGENTS.md 可驱动 Codex 安装恶意 npm 包
安全公司 Forever Security 称在真实客户机器上拦截到编码智能体按 Downloads 目录中陌生 AGENTS.md 改写配置并试图安装恶意 npm 包;复现显示 Codex 在多数尝试中执行载荷,自制 CLAUDE.md 也可诱导 Claude Code 改道 API 流量并泄露令牌。
安全公司 Forever Security 报告称,其防护在真实客户机器上拦住了一次由编码智能体发起的恶意软件安装:客户 Downloads 目录里出现一份伪装成工程说明的 AGENTS.md,智能体按文件指示改写本机配置,并尝试安装与 MALFEX 活动相关的恶意 npm 包(公开报道点名 function-color)。公司强调这不是传统「用户双击木马」,而是网站可写入的 Downloads 与智能体默认信任的项目说明文件叠在一起后,把执行权交给了智能体本身。
公开技术说明与转述给出的复现要点包括:把攻击者原始 AGENTS.md 放进隔离环境后,Codex 在多数尝试中会改写机器级 ~/.codex/config.toml(例如写入攻击者控制的 MCP/工具服务),并以绕过审批/沙箱的方式拉起安装;因为配置是用户级全局文件,影响可能延续到其他工作目录的会话。团队另写一份 CLAUDE.md 测试 Claude Code,称在约一半尝试中可把 API 流量指到攻击者服务器并泄露登录令牌。Forever 的结论是:智能体「听从目录里的说明文件」是产品设计使然,单靠模型厂商补丁无法关闭「可被 Web 写入的目录被当成可信工作区」这一类场景。
可立刻做的缓解与厂商博客一致:不要在 ~/Downloads 里启动 Codex、Claude Code 或其他编码智能体;对不是自己写的 AGENTS.md/CLAUDE.md(含刚克隆的仓库)先人工阅读;检查 ~/.codex/config.toml 是否出现陌生 [mcp_servers.*],以及项目 .claude/settings.json 是否被写入陌生 ANTHROPIC_BASE_URL 或代理;保持审批与沙箱开启,对要求关闭防护的指令保持警惕;若怀疑已中招,轮换令牌——只删文本文件不足以撤销已写入的配置。
事件综述帖:https://x.com/aipokolypse/status/2114162898620866829 ;Forever 原文:https://forever.security/blog/hijacking-ai-agents-via-downloads-folder/ 。
Forever Security blocks AGENTS.md malware via coding agent
Security firm Forever Security says it blocked an AI coding agent on a real customer's machine from installing malicious npm software, after the agent obeyed an AGENTS.md file the customer had never seen, sitting in their Downloads folder. Replaying the attacker's own file in an isolated machine, the firm found Codex rewrote its machine-wide config and ran the malware in more than 90% of attempts. A separately crafted CLAUDE.md got Claude Code to reroute its API traffic to an attacker server, leaking its login token, about half the time.