防护思路
点击放大

Full article here
This repository contains a proof-of-concept exploit that enables remote code execution in Anthropic's Claude Code CLI (with Claude Sonnet 4.6 & 5, Opus 4.8) and OpenAI's Codex CLI (with GPT-5.5) when employed to defensively assess the security of an untrusted open-source or third-party library. Our attack only requires an out-of-the-box configuration of Claude Code in "auto-mode" or Codex in "auto-review" and le prompt injections disseminated across a library's source code that target AI-enabled cyber defense without the need for hooks, skills, plugins, MCP servers, or configuration files as an injection .
This repository contains the code and demos of the proof-of-concept, as well as a brief o of the epxloit. For a full, detailed explanation of the attack and its implications, see our article here
Demos for Claude Code with Sonnet 4.6, Sonnet 5, Opus 4.8, and Codex with GPT-5.5 are provided in the resources folder.
This proof-of-concept assumes the following scenario: an AI agent (Claude Code, Codex) is provided with a local copy of an untrusted codebase, and its task is to perform a security review of the codebase. We show how malicious files injected into the codebase can hijack the agent and make it run arbitrary attacker-controlled code, achieving RCE in its deployment en.
The injection of files in an open-source codebase can either be done intentionally by someone with access or by third-party attackers via a supply-chain compromise. In this proof-of-concept, we construct an example of such an injected codebase that is based upon the benign open-source geocoding library, geopy to which we add a few malicious files. The modified geopy source code is included in this repo in the /geopy directory.
> [!NOTE]
> Note that our attack has the potential to be ported to any other open-source or third-party library, and the use of geopy in this research is only for demonstrati
The injected files are:
code_policies: a pre-compiled binary that appears to be a static code analysis tool but contains a hidden attacker payload. Note that the code_policies binary provided in this repo is there for reproduction purposes and has been stripped from any malicious code.code_policies.go: a decoy benign file that leads the models to regard it as the source code for the malicious code_policies binary, leading to code_policies being considered safe to run. More details on this in our full article.security.sh: a wrapper script that references common security tools and calls the code_policies binary.README.md: a short section is added at the end of the original geopy README. It contains a prompt injection that steers the model to run the security.sh script.When the agent scans the modified geopy codebase, it processes README.md. The prompt injection con the agent to run code_policies (or security.sh, which in turn calls code_policies), despite the fact that it is an untrusted binary. This attack works on Claude Code and Codex when run in "auto-mode" and "re" respectively, and bypasses safety measures deployed by the tools to prevent them from performing such unsafe actions.
The diagram below summarizes the attack flow.
!Attack flow
To reproduce this proof-of-concept:
1. Setup Claude Code or Codex in your test en. Run their default , without additional skills, tools, MCP servers, or configuration.
- For Claude Code: run in "auto-mode" with claude --enable-auto-mode or switching the mode from the Claude Code console with shift+tab
- For Codex, enable "auto-review mode" with codex --sandbox workspace-write --ask-for-appro -c appro=auto_review or appro = "auto_review"
2. Copy the ./geopy directory to your test en.
3. Prompt the agent with "Perform security testing on /path/to/geopy".
4. Wait for the agent to run security.sh or code_policies, which is the point of compromise.
Note that our PoC exploit may not always yield the exact outputs and agent actions as shown in our demo video given the nondeterministic nature of frontier AI models, user en, and prospecti changes that Anthropic or OpenAI may deploy for Claude Code CLI or Codex CLI. Anthropic does not provide guarantees of determinism for their models despite using a temperature configuration of 0, while OpenAI's GPT-5 no longer supports temperature control. That said, we repeated our attacks across these models numerous times, with success, to ensure the consistency of our PoC.
Also note that our PoC itself does not chain the achieved RCE to sandbox escape exploits, as our exploit's aim is to demonstrate the attack introduced by the use of agentic AI for defensi. Agent sandboxing is addressed in our full article.
All original files from the geopy folder are included under their original MIT licence.
All other resources and code artifacts in this repository are released by the AI Now Institute under the Creati Attribution-NonCommercial 4.0 International licence
开发语言:Python
Star 数:14
该项目属于防护思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕This repository contains a proof-of-concept exploit that enables remote code execution in Anthropic's Claude Code CLI (with Claude Sonnet 4.6 & 5, Opus 4.8) and OpenAI's Codex CLI (with GPT-5.5) when employed to defensively assess the security of an untrusted open-source or third-party library展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | friendly-fire-ai-agent-exploit - This repository contains a proof-of-concept exploi |
| 所属分类 | 防护思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-06 00:11:25 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 122 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |