AI SecurityExplainerJul 13, 2026, 1:44 AM· 7 min read· #5 of 5 in ai

Research Reveals 'Friendly Fire' Attack: Top AI Coding Agents Can Be Tricked Into Running Malicious Code

A new proof-of-concept vulnerability demonstrates that autonomous AI coding assistants can be manipulated into executing malware while scanning untrusted repositories for security flaws.

By Factlen Editorial Team

Security Researchers 40%Enterprise Security Teams 35%AI Tool Developers 25%
Security Researchers
Argue that the flaw is a fundamental design weakness where untrusted context becomes authority, requiring strict runtime sandboxing rather than model patches.
Enterprise Security Teams
Prioritize immediate mitigations like sandboxing and disabling auto-approve features to limit the blast radius of compromised agents.
AI Tool Developers
View autonomous modes as necessary for usability, relying on classifiers to balance friction and safety while acknowledging the need for user vigilance.

What's not represented

  • · Open-source repository maintainers
  • · Malware analysts

Why this matters

As enterprises increasingly rely on AI agents to automate code reviews and vulnerability scanning, this research highlights a critical design flaw where untrusted text can hijack an AI's actions. Understanding this mechanism allows developers to secure their workflows by sandboxing agents and disabling auto-approve features before a theoretical attack becomes a real-world breach.

Key points

  • Researchers have demonstrated that AI coding agents can be tricked into executing malicious code while scanning untrusted repositories.
  • The 'Friendly Fire' attack targets tools like Claude Code and OpenAI Codex when they are running in autonomous, self-approving modes.
  • Attackers hide prompt injections in ordinary files, such as a README, which nudges the AI to run a disguised malicious binary.
  • The vulnerability highlights a fundamental AI design flaw where language models cannot reliably distinguish between trusted instructions and untrusted data.
  • Security experts recommend disabling auto-approve features and running AI agents in isolated sandboxes to mitigate the risk.
93%
Permission prompts auto-approved by Claude Code
0
Confirmed in-the-wild exploitations
6
AI assistants vulnerable to related GhostApproval flaw

The software industry is increasingly delegating its most tedious security work to artificial intelligence. Developers routinely ask autonomous coding agents to scan newly downloaded open-source libraries, looking for hidden vulnerabilities before integrating the code into production. But new research reveals a critical blind spot in this defensive workflow: the very tools hired to catch malicious code can be tricked into executing it. A proof-of-concept attack dubbed "Friendly Fire" demonstrates that when an AI assistant is asked to review a booby-trapped repository, it can be manipulated into running an attacker's payload directly on the developer's machine.[1]

Disclosed by security researchers Boyan Milanov and Heidy Khlaaf at the AI Now Institute, the vulnerability targets top-tier coding assistants, specifically Anthropic's Claude Code and OpenAI's Codex. The attack does not rely on complex software exploits or elevated system privileges. Instead, it exploits the fundamental way large language models process information. The researchers found that when these agents operate in their popular "auto-mode" or "auto-review" configurations—which allow the AI to approve its own commands to reduce user friction—they become susceptible to prompt injections hidden in plain sight.

The mechanics of the Friendly Fire attack are deceptively simple. Attackers do not need to compromise the core logic of a popular software library; they only need to alter its documentation and add a few disguised files. In their demonstration, the researchers modified a copy of "geopy," a widely used Python geocoding library. They inserted a routine-looking README file that casually instructed users to run a script named "security.sh" as a standard check before finalizing any code changes.[1][2]

When a developer prompts their AI agent to "perform security testing" on the downloaded repository, the agent dutifully reads the documentation. Encountering the instruction in the README, the AI assumes the security script is a legitimate part of the repository's native testing suite. The agent executes the script, which quietly launches a hidden, malicious binary. Because the agent is running in an autonomous mode, it bypasses the human-in-the-loop confirmation prompt, silently compromising the host machine while the developer believes a routine scan is underway.[1]

The attack hides prompt injections in ordinary repository files, steering the agent to run attacker-controlled code.
The attack hides prompt injections in ordinary repository files, steering the agent to run attacker-controlled code.

To ensure the AI's built-in safety classifiers do not flag the hidden binary as suspicious, the researchers employed a clever disguise. They placed a harmless decoy file—written in the Go programming language—right next to the malicious binary. They then seeded the binary with string constants lifted directly from the decoy file. When the AI agent's safety classifier inspects the binary, it matches the strings, concludes that the binary is simply the compiled version of the harmless Go code, and approves the execution.[1]

This deception highlights a structural weakness in current generative AI architectures: the inability to reliably separate trusted instructions from untrusted data. As Eljan Mahammadli, Head of AI Provenance at Polygraf AI, noted, a language model processes everything in its context window as a single stream of tokens. The operator's initial command to "review this code" and the third-party repository's hidden command to "run this script" arrive carrying the exact same authority. Once the malicious instruction enters the context window, the agent has no reliable mechanism to recognize it as hostile.[2]

The reliance on AI classifiers to govern safety boundaries is increasingly proving insufficient. Tool developers introduced autonomous modes as a middle ground between fully unrestricted execution and the tedious friction of prompting the user for every single action. Anthropic has previously noted that Claude Code's auto-mode sees users approving 93 percent of permission prompts anyway, making the classifier a welcome convenience. However, the Friendly Fire research proves that these heuristics can be spoofed by matching real-looking source files with malicious binaries, turning a convenience feature into a critical vulnerability.[1]

Autonomous modes are designed to reduce user friction, but they can be spoofed by matching real-looking source files with malicious binaries.
Autonomous modes are designed to reduce user friction, but they can be spoofed by matching real-looking source files with malicious binaries.
The reliance on AI classifiers to govern safety boundaries is increasingly proving insufficient.

The implications of this vulnerability extend far beyond individual developer workstations. Modern software development relies heavily on Continuous Integration and Continuous Deployment pipelines, which automatically fetch, test, and deploy code updates. If engineering teams begin delegating the automated vulnerability scanning of incoming package updates to autonomous AI agents, this injection technique could trigger silently across enterprise environments. A compromised dependency update could execute its payload without a human ever reviewing the change, effectively automating a supply chain attack.[1]

Fortunately, the Friendly Fire attack remains a laboratory proof-of-concept. The AI Now Institute has not observed any exploitation of this specific technique in the wild, and the public research code was released with the actual malicious payload removed. The attack also stops at the first execution, with the researchers making no attempt to demonstrate privilege escalation or lateral movement across a network. The disclosure serves as a proactive warning rather than an active incident response, giving the industry time to adjust its practices.

Mitigating the threat requires a shift in how developers deploy AI tools, rather than waiting for a software patch. Because the vulnerability is rooted in the fundamental design of language models, there is no simple version update that will eliminate the risk. The most immediate and effective defense is to disable autonomous execution modes whenever an AI agent is interacting with untrusted, third-party code. By forcing the agent to request explicit human approval before running any executable file or script, developers can break the attack chain before the payload detonates.

Security experts are also urging organizations to rethink the runtime environments where these agents operate. The durable control must live in the infrastructure surrounding the model, not within the model itself. This means running AI coding assistants inside disposable workspaces or strict sandboxes that lack access to production credentials, sensitive host files, or external network egress. If an agent is tricked into executing a malicious script, the blast radius remains confined to a temporary, isolated container that can be safely destroyed.[2]

Security experts recommend isolating AI agents in disposable workspaces and requiring manual approval for code execution.
Security experts recommend isolating AI agents in disposable workspaces and requiring manual approval for code execution.

The Friendly Fire disclosure arrives amid a broader wave of research exposing the fragile security boundaries of agentic AI. Just days prior, researchers at Wiz disclosed "GhostApproval," a vulnerability affecting six popular AI coding assistants. That attack leveraged symbolic links to trick agents into modifying sensitive system files outside their designated workspace. Similarly, a technique known as "HalluSquatting" demonstrated that attackers can predict the fake package names AI agents are likely to hallucinate, register those names on public repositories, and wait for the agents to autonomously download malware on a user's behalf.

Together, these findings underscore a difficult reality for the rapidly expanding AI tooling market. The push to grant AI agents greater autonomy—allowing them to clone repositories, install dependencies, and run setup commands independently—is simultaneously expanding the attack surface. Every file an agent reads and every tool it can access represents a potential vector for manipulation. As governments and enterprises rush to adopt AI for defensive cybersecurity work, the assumption that a more capable model is inherently a safer one is being severely tested.[2]

Despite these vulnerabilities, security researchers are not calling for an end to AI-assisted defense. The ability of large language models to rapidly parse and analyze massive codebases remains a highly valuable asset for identifying genuine vulnerabilities. The core lesson of the Friendly Fire research is not that AI is unfit for security work, but that it must be treated as an untrusted component when handling external data. The authorization to execute code must be decoupled from the agent that reads the code.[2]

Despite the vulnerabilities, AI remains a powerful tool for analyzing massive codebases when properly constrained.
Despite the vulnerabilities, AI remains a powerful tool for analyzing massive codebases when properly constrained.

As the industry digests these findings, the focus is shifting toward building robust, verifiable guardrails around AI execution environments. Vendors are exploring ways to cryptographically bind tool-call approvals to verified user identities, ensuring that an agent cannot unilaterally authorize its own actions based on injected context. Until those architectural changes mature, developers must remember that their AI assistants are not just passive productivity enhancers—they are active participants in the development lifecycle, requiring the same strict trust boundaries as any human contractor.

How we got here

  1. May 2026

    Researchers disclose 'TrustFall,' an early attack turning booby-trapped repositories into code execution across multiple AI assistants.

  2. June 2026

    Security firm 0DIN demonstrates how AI agents can be tricked into running hidden malware while fixing routine setup errors.

  3. July 8, 2026

    The AI Now Institute publishes the 'Friendly Fire' proof-of-concept, detailing how autonomous agents can be hijacked during security scans.

  4. July 9, 2026

    Wiz researchers disclose 'GhostApproval,' a separate vulnerability exploiting symbolic links in six popular AI coding assistants.

Viewpoints in depth

Security Researchers

Argue that the flaw is a fundamental design weakness where untrusted context becomes authority.

Security researchers emphasize that the Friendly Fire vulnerability is not a simple software bug that can be patched in the next version update. Instead, it exposes a structural flaw in how large language models process information. Because an AI agent evaluates all text in its context window as a single stream of tokens, it cannot reliably distinguish between the operator's instructions and the untrusted data it is scanning. Researchers argue that as long as this architectural limitation exists, AI agents must be treated as untrusted components and isolated in secure sandboxes.

AI Tool Developers

View autonomous modes as necessary for usability, relying on classifiers to balance friction and safety.

Developers of AI coding assistants point out that autonomous modes are opt-in features designed to solve a genuine user experience problem: alert fatigue. When developers are forced to manually approve every single file read or script execution, they often begin blindly clicking 'approve,' which defeats the purpose of the security prompt. Tool creators argue that while classifiers are not perfect, they successfully block the vast majority of malicious commands, and that users who opt into autonomous modes must remain vigilant about the environments in which they deploy these tools.

Enterprise Security Teams

Focus on mitigating the blast radius by enforcing strict trust boundaries and disabling auto-execution.

For corporate security teams, the theoretical debate over AI architecture is secondary to immediate risk mitigation. CISOs and security architects are responding to these vulnerabilities by implementing strict operational guardrails. They advocate for disabling auto-approve features entirely when agents interact with third-party code, and they are mandating that all AI-assisted development occur within disposable workspaces. By ensuring that the AI agent has no access to production credentials or sensitive host files, security teams aim to contain the blast radius of any successful prompt injection attack.

What we don't know

  • It remains unclear how quickly AI vendors can implement structural fixes that separate code execution authority from the language model's context window.
  • Security teams do not yet know if advanced threat actors have independently discovered and weaponized similar prompt injection techniques in the wild.
  • It is uncertain how the discovery of these vulnerabilities will impact the timeline for enterprise adoption of fully autonomous AI development tools.

Key terms

Friendly Fire
A proof-of-concept attack that tricks AI coding agents into executing malicious code during routine security scans.
Autonomous Mode
A setting in AI coding tools that allows the agent to execute commands and approve its own actions without prompting the user for permission.
Prompt Injection
A cyberattack technique where malicious instructions are hidden within data that an AI model processes, tricking it into executing unintended commands.
Context Window
The total amount of text and data an AI model can process and remember at one time during a single interaction.
Symbolic Link
A file system object that points to another file or directory, which can be exploited to trick programs into modifying unintended targets.

Frequently asked

What is the Friendly Fire attack?

It is a proof-of-concept vulnerability where an AI coding agent is tricked into running malicious code while scanning an untrusted repository for security flaws.

Which AI tools are affected?

The research specifically targeted Anthropic's Claude Code and OpenAI's Codex when they are running in autonomous modes that allow them to approve their own commands.

Has this attack been used in the wild?

No. It is currently a laboratory proof-of-concept developed by security researchers to highlight a design flaw, and no real-world exploitation has been observed.

How can developers protect themselves?

Developers should disable auto-approve features when reviewing untrusted code and run AI agents inside isolated, disposable workspaces that lack access to sensitive system files.

Sources

Source coverage

2 outlets

3 viewpoints surfaced

Security Researchers 40%Enterprise Security Teams 35%AI Tool Developers 25%
  1. [1]Cybersecurity NewsAI Tool Developers

    Cyber AI Agents Like Claude Code, GPT-5.5 Can Be Hijacked to Run Malicious Code Remotely

    Read on Cybersecurity News
  2. [2]IT NerdEnterprise Security Teams

    “Friendly Fire” exploit highlights growing risks in AI-assisted code review

    Read on IT Nerd
Stay informed

Every angle. Every day.

Get ai stories with full source coverage and perspective breakdowns delivered to your inbox.