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.