The rapid adoption of AI-powered coding assistants has introduced a new layer of convenience to software development, but it also brings subtle security tradeโ€‘offs that many teams overlook. When these agents are configured to operate autonomously, they begin to interpret and execute commands without asking for explicit confirmation each time. This convenience is precisely what attackersโ€™ sweet spot: they can craft seemingly innocuous project files that coax the agent into running malicious payloads under the guise of routine security checks. The result is a scenario where the very tool meant to protect the codebase becomes the vector for compromise, turning trust into a liability.

Researchers from the AI Now Institute coined the term โ€œFriendly Fireโ€ to describe this class of attack, demonstrating how an AI coding agent can be tricked into executing hidden code while performing a requested security scan. The exploit hinges on the agentโ€™s internal safety classifier, which decides which commands are safe enough to run automatically. By embedding a malicious binary inside a seemingly helpful script referenced in a README file, the attack slips past the classifierโ€™s radar. The agent reads the documentation, concludes that running the script is part of the requested security review, and launches the payload without any further user interaction.

In their proofโ€‘ofโ€‘concept, the team chose the widely used geopy library as a carrier, though they emphasize that the technique is portable to virtually any openโ€‘source project. They added a benignโ€‘looking shell script called security.sh to the repositoryโ€™s root and referenced it in the README as a recommended preโ€‘pullโ€‘request check. When an autonomous agent such as Claude Codeโ€™s autoโ€‘mode or OpenAIโ€™s Codex autoโ€‘review receives a vague instruction like โ€œperform security testing on this project,โ€ it follows the READMEโ€™s suggestion, executes the script, and inadvertently runs the concealed binary that carries the true malicious payload.

To evade the agentโ€™s builtโ€‘in disassembly checks, the researchers took extra care to make the hidden binary look legitimate. They compiled a simple Go program, copied distinctive strings from that program into the binary, and placed both files side by side. The agentโ€™s classifier, which compares binaries to their supposed source code, sees enough similarity to deem the file safe. Because the libraryโ€™s own source never references the binary, there is nothing in the codebase that raises a flag, allowing the malicious payload to masquerade as an innocuous build artifact.

Earlier generations of attacks against AI coding assistants focused on manipulating configuration files such as .mcp.json or .claude/settings.json, which trigger explicit trust warnings in the tools. By contrast, the Friendly Fire technique plants its malicious instructions in README.mdโ€”a plainโ€‘text file that exists in virtually every repository and does not provoke any trust prompt. This shift dramatically widens the attack surface, as developers rarely scrutinize documentation for hidden threats, and the agents themselves treat it as benign instructional material.

Notably, the report mentions that Anthropic has already issued three patches aimed at preventing configurationโ€‘file injections over the past six months. Yet those patches do not address the new vector, underscoring the researchersโ€™ claim that the vulnerability lies not in a specific code version but in the underlying design of autonomous command execution. No simple version bump can fix the issue; instead, teams must reconsider how they grant agents the ability to run arbitrary commands on their behalf.

The attackโ€™s effectiveness across multiple model versions further highlights a systemic limitation. A payload crafted for Claude Sonnet 4.6 remained functional on Sonnet 5, Opus 4.8, and even OpenAIโ€™s GPTโ€‘5.5 without modification. In some test runs, newer models noticed discrepancies between the binary and its purported source yet still proceeded to execute it. This behavior indicates that the agentsโ€™ safety mechanisms cannot reliably distinguish between legitimate code they are supposed to evaluate and instructions they are meant to followโ€”a fundamental flaw that persists regardless of model improvements.

Friendly Fire is not an isolated curiosity; it fits into a broader pattern of attacks that exploit the same precondition: untrusted external text reaching an agent capable of executing commands. Earlier efforts such as Adversaโ€™s TrustFall and Tenetโ€™s Agentjacking achieved high success rates by poisoning different artifactsโ€”repositories and errorโ€‘tracker bug reports, respectively. The common denominator is the agentโ€™s propensity to act on textual cues from the environment without sufficient verification, a trait that becomes dangerous when those cues originate from adversaries.

The realโ€‘world relevance of this threat is reinforced by incidents like the PyTorch Lightning compromise, where malicious code was injected into a popular openโ€‘source project. Attackers already routinely poison public codebases, and the Friendly Fire method shows how such poison can be leveraged to turn an AIโ€‘assisted security review into a foothold on the developerโ€™s machine. While the current proofโ€‘ofโ€‘concept stops after initial execution and does not attempt privilege escalation, it demonstrates that the first stepโ€”gaining executionโ€”is already achievable with minimal effort.

From a defensive standpoint, the researchersโ€™ advice is stark: avoid giving untrusted code to any AI agent that can directly interact with your host, keys, or secrets. This recommendation feels counterintuitive for teams that adopted these tools precisely to automate thirdโ€‘party code vetting, yet it follows logically from the findings. If organizations choose to continue using autonomous modes, they must implement strict monitoring to detect when an agent launches a binary or script that originated solely from a documentation file.

Practical mitigations include employing sandboxed environments for agent execution, though sandboxes are not foolproof. Historical vulnerabilities such as CVEโ€‘2026-39861 have shown that even Claude Codeโ€™s own sandbox can be escaped through techniques like symlink attacks. Therefore, sandboxing should be viewed as a layer of defense-in-depth rather than a guaranteed safeguard. Complementary controlsโ€”such as restricting the agentโ€™s file system access, disabling automatic execution of scripts found in documentation, and requiring explicit approval for any binary launchโ€”can substantially reduce risk.

Detection strategies should focus on anomalous behavior patterns: an agent suddenly spawning processes that are not part of the projectโ€™s build system, network connections originating from unexpected binaries, or file writes outside the designated workspace. Logging the agentโ€™s decisionโ€‘making process, especially the classification of commands as โ€œsafe,โ€ can provide forensic clues when an attack succeeds. Security teams might also consider implementing allowโ€‘lists for knownโ€‘good scripts and binaries, treating any deviation as a potential indicator of compromise.

In conclusion, the Friendly Fire revelation serves as a wakeโ€‘up call that the security posture of AI coding assistants must evolve alongside their capabilities. While automation offers tremendous productivity gains, it cannot be trusted blindly when the stakes involve execution privileges on critical systems. Organizations should revisit their risk assessments, enforce leastโ€‘privilege principles for agent workloads, and invest in continuous monitoring and user education. By balancing automation with vigilant oversight, development teams can harness the power of AI agents without turning them into unintended gateways for attackers.