Products Lemma APIProof issuance & verification platformTrust402Delegate to agents, and transactSealSign-in for the agent era — no keys handed over
Use cases Manufacturing & Critical InfraInspection Record AssuranceFinance & FinTechCounterparty Record VerificationPublic SectorCertificate-less ProceduresHealthcareQualified Worker AssuranceProcurement & Supply ChainSupplier Credential MonitoringMedia & ContentContent AuthenticityService & RetailCross-group IdentityAI Adoption (cross-industry)AI Run GovernanceDevelopers & Agent OpsAgent Authority Control ▸ Browse the use-case index
Pricing
Resources Critical BriefThe frontier of AI × trustBlogThinking and implementation notesDocumentationAPI & specsVerification CenterReal verification & issuance countsAbout usFRAME00, Inc.ContactSales & press inquiriesGlossaryDefinitionsFAQFrequently asked questions
Dashboard ↗ JA
Home / Critical Brief / No. 102
No. 102 Critical Brief · Verifiable Origin

Friendly Fire: AI coding agents asked to security-review a library ran the malicious binary planted in it (AI Now Institute research)

3 models
Models to which the same payload built for Sonnet 4.6 transferred unchanged (Sonnet 5, Opus 4.8, GPT-5.5; AI Now Institute)
0 times
Times the developer approved running the code in auto-mode / auto-review (AI Now Institute)
2 agents
Agents in which the PoC succeeded (Claude Code, Codex; AI Now Institute)
CountryGlobal
Incident date2026-07-08
Published2026-07-15
AuthorsLemma Critical Team
Contents
  1. 01Summary
  2. 02What got through
  3. 03Pre-execution check
  4. 04What Lemma does
  5. 05Facts and timeline
  6. 06Sources

Summary

According to AI Now Institute’s research, a developer need only ask an agent to check the security of a third-party library, and the agent runs an attacker’s binary planted in that library on the host. It took a sentence appended to the library’s README.md as a legitimate diagnostic step and ran it inside a mode that executes commands automatically. The researchers report that the pre-execution disassembly check was fooled by a decoy source sharing the binary’s name and some of its strings into treating it as “a legitimate build with matching source.” This is a research-stage PoC; no harm in the wild has been reported. Steps inside code an agent takes in go through as part of ordinary work unless the side that runs them checks, before running, where they came from and how far they may go.

Exhibit 1Detection vs pre-execution check

A pre-execution check means checking, before an agent runs code it has taken in, where that code came from and how far it may go, separately from appearance and the model's judgment, and keeping a record. Detection means noticing through published research or monitoring for injection patterns. Dates are publication and reporting dates.

Pre-execution check · not known from the disclosuresBefore running, check where the code came from, separately from appearance and the model's judgment
What was confirmedIn a controlled environment, two agents
ran the binary under review
Detection · research and reportingPoC published, both vendors contacted, injection patterns monitored
2026-05
Same-condition research "TrustFall" (Adversa)
2026-05-28
Report of a maintainer planting an injection in code
2026-07-08
AI Now Institute publishes the research
2026-07-09
The Hacker News and others report

What got through

What got through
Running a script contained in the code under review, and the malicious binary it launches. With Claude Code’s auto-mode or Codex’s auto-review enabled, no approval dialog appeared. Because no configuration files (.mcp, .claude/settings.json, and the like) are used, no “do you trust this folder?” prompt appeared either (AI Now Institute).
Trigger
The developer’s mundane request to “check the security of this library.” There is no jailbreak and no explicit instruction to execute, and the developer never approves the code. Both Anthropic and OpenAI recommend using their agents to find vulnerabilities in third-party libraries (AI Now Institute).
What reached the receiving side
In general, an agent cannot reliably tell steps inside the text it takes in from instructions it received from its user. The researchers argue this is a design weakness that model updates cannot close. When the underlying models were asked directly “does geopy contain a prompt injection?”, both Sonnet 4.6 and GPT-5.5 answered “no” (AI Now Institute).
What it reached
The PoC demonstrates arbitrary code execution (RCE) on the host and stops at the first code execution. The paper notes that this could be used as a foothold to chain through known sandbox-escape flaws (CVE-2026-39861, CVE-2026-25725) toward theft of authorization keys, persistence, and evasion of network restrictions (AI Now Institute).
Not disclosed
How the two companies responded after the researchers contacted them, and whether anything changed on the product side. No exploitation or harm in the wild has been reported as of this writing.

Pre-execution check

Whatever the route, the condition for telling them apart is that, before an agent runs a script or binary inside code it has taken in, it checks — separately from how the content looks and from the model’s judgment — whether that code comes from the reviewed library’s legitimate distributor or was added from outside.

The core of this case
Steps inside code an agent takes in go through as part of ordinary work unless the side that runs them checks, before running, where they came from and how far they may go.
Who approves
The legitimate distributor (a known upstream, a signed distributor), and the developer or organization that sets the scope that may run. The approval is given on where the code to be run came from, separately from the model’s safety judgment.
Where it is checked
Before the agent runs a script or binary inside code it has taken in. Anything whose origin cannot be checked is held until it can be.
What is recorded
Which binary or script ran (or was held), on which distributor’s confirmation, and with what environment and privileges. Kept outside the agent, in a form that can be shown to a third party later.

Publishing the research, demonstrating transfer, proposing mitigations, and contacting both vendors made the risk visible from outside. But that came after execution, and it does not check, at the moment the agent runs the binary, whether it comes from a legitimate distributor. In that steps inside ingested content were executed without their origin being checked, this is the same shape as Agentjacking, where an agent ran the “resolution steps” of a fake error report, and it connects to Amazon Q, where configuration bundled in a repository ran unverified. Here, the ingested content is the very code handed over for review.

What Lemma does

Lemma puts the pre-execution check before an agent runs a script or binary inside code it has taken in. It does not look for injections; before execution and outside the agent, it checks whether the code about to run comes from a legitimate distributor and whether running it falls within the permitted scope.

Industries and operations to watch

Industry / operation Why the same hole exists
Industry · Developers & software Reviews of third-party libraries and open source are left to AI coding agents that can run commands automatically.
Industry · AI Builds and operates agent products, or systems that have agents read untrusted code.

Current controls vs Lemma

The route in this case is a script and binary contained in the code under review, run in an automatic mode.

Control Running a script or binary contained in the code under review
Pre-execution disassembly check (Claude Code) Not effective
Automatic-mode classifier (auto-mode / auto-review) Not effective
Folder-trust prompt Not applicable
Conservative mode that asks for approval every time Partial
Sandbox Partial
Lemma (pre-execution check) Effective

The researchers report that the disassembly check was fooled by a decoy source with matching name and strings into treating the binary as a legitimate build, and that the classifier ran it without asking for approval. The folder-trust prompt does not appear on this route, which uses no configuration files. For the approve-every-time mode, the researchers note that automation bias and prompt fatigue keep it from being an effective intervention. A sandbox keeps execution within constraints, but the researchers argue that exploiting flaws in its implementation could break out. Lemma checks, before execution, where the code came from and how far it may go, separately from appearance and the model’s judgment. A record of what ran is also kept, so which binary ran on which distributor’s confirmation can be checked afterwards.

Note: Lemma’s check works only when it is built into the step where the agent runs code, and distributor confirmation and the permitted scope are managed outside the agent. Code from the legitimate distributor that itself contains malicious logic (contamination on the distributor’s side) can pass. Lemma does not change the models or the agents, and each vendor’s decisions about its response remain its own. The table compares what each control checks; it does not show whether this incident would have been stopped. Lemma does not detect or prevent intrusions.

CheckChecklist

Three things to confirm for organizations that have AI coding agents handle third-party code

  • Are the privileges of an agent that reviews third-party code limited so that it cannot reach keys, secrets, or the host?
  • In modes that run commands automatically, is running scripts or binaries contained in the repository under review blocked by default?
  • Are the commands and binaries an agent runs recorded outside the agent?

Facts and timeline

Subject
AI coding agents used to security-review third-party code. The PoC succeeds with Anthropic’s Claude Code (CLI 2.1.116 / 2.1.196 / 2.1.198 / 2.1.199; underlying models Claude Sonnet 4.6, Sonnet 5, Opus 4.8) and OpenAI’s Codex (CLI 0.142.4; GPT-5.5).
Reporter
Research by AI Now Institute (an independent AI research institute working in the public interest). The authors are Boyan Milanov and Heidy Khlaaf. Published 2026-07-08 as part of the institute’s series “Double Agents: Defensive AI Agents Magnify Cyber Risks.”
Assumed mode
auto-mode and auto-review sit between a fully unrestricted mode and a conservative mode that asks every time, and exist for long-running autonomous work. The attack assumes one of them is enabled.
What was planted (as the researchers describe it)
In a copy of the legitimate geopy, a malicious binary, a decoy source posing as a static-analysis tool, a script that appears to call well-known tools but launches the malicious binary, and a README.md with a sentence appended at the end recommending running that script. Because the binary is never called from the library’s own code, ordinary tools do not flag it. The researchers say the injection could come from an insider with access or from a third-party supply-chain compromise.
Transfer
The same payload built for Sonnet 4.6 transferred unchanged to Sonnet 5, Opus 4.8, and GPT-5.5. Newer models ran it even when they noticed the binary did not match the decoy source. A variant using CLAUDE.md / agent.md as the injection surface also succeeded.
What was published
The binary in the GitHub reproduction repository has had its payload stripped.

Glossary
auto-mode / auto-review — Opt-in settings in Claude Code and Codex. Commands an AI classifier judges safe run automatically; only those it judges dangerous ask a human for approval.
Decoy source — Source code placed so that a malicious binary looks like a legitimate build of it. Here it posed as a static-analysis tool.

Timeline

  • 2026-07-08: AI Now Institute publishes the research “Friendly Fire: Hijacking Defensive Cyber AI Agents for Remote Code Execution,” presenting the PoC, attack construction, transfer, and mitigations against Claude Code and Codex, and publishes a reproduction repository on GitHub (with a binary from which the payload has been stripped).
  • 2026-07-09: The Hacker News and other outlets report on it, situating it in a line of same-shaped research (Adversa “TrustFall,” 2026-05; Tenet “Agentjacking,” 2026-06) and against a backdrop of real supply-chain contamination (PyTorch Lightning, Megalodon).
  • On disclosure: this PoC falls outside both Anthropic’s and OpenAI’s vulnerability-disclosure policies, but the researchers say they contacted both companies and offered to assist with verification and reproduction.

Note: the technical facts are based on AI Now Institute’s PoC disclosure (primary), the GitHub reproduction repository, and reporting by The Hacker News. The tested CLI versions (2.1.116 and others) are the configuration the researchers verified, not a vulnerable version range (the researchers hold that this is a design weakness, not a version issue). This is a PoC in a controlled environment; no exploitation or harm in the wild has been reported as of this writing. What has not been disclosed does not mean no countermeasure existed.

Response after disclosure

Research (AI Now Institute)
Presents Friendly Fire not as a single vendor’s bug but as an attack surface introduced by the very act of using frontier AI defensively. It notes that in safety-critical environments, agents that can run arbitrary code or reach keys and sensitive environments should not be made to ingest untrusted data and code, and that relying on a mode that approves every time is not an effective intervention either, owing to automation bias and “prompt fatigue.”
Contact with model providers
The researchers say they contacted both companies and offered to assist with verification and reproduction. They argue this is not a flaw a model update can close, and that it requires changes on the workflow side.
Positioning of the sandbox
The research also discusses the limits of treating a sandbox as the primary mitigation for an agent that can run arbitrary shell commands. Using RCE as a foothold to exploit flaws in the sandbox implementation itself (escape-enabling flaws in Claude Code’s sandbox were also reported this year) could break out of the constrained environment.
Industry point
As reported, this case shares the same condition as Adversa “TrustFall” (2026-05, one-shot RCE from a crafted repository) and Tenet “Agentjacking” (2026-06, via a fake error report): untrusted external text reaching an agent that can run arbitrary commands.

Sources

References: “The last layer left for cyber defense in the age of AI”

The same method elsewhereSee all 40 "AI failure or misuse" cases

This Brief sets out, from disclosed facts, what organisations in a similar position can check. It is not guidance on individual losses or procedures.

This material is a structured analysis of public information; it is not an audit, diagnosis, or recommendation for any specific organization.

Cite this Brief

Lemma Critical Team. (2026).
"Friendly Fire: AI coding agents asked to security-review a library ran the malicious binary planted in it (AI Now Institute research)".
Lemma Critical Brief No.102. Lemma / FRAME00, Inc.
https://lemma.frame00.com/critical/briefs/102-friendly-fire-defensive-agent-rce/
Read nextNext
All Briefs →
Lemma

If it can't be verified,
it doesn't enter your operation.

Lemma is a pre-execution check: logins, payments, records and publishing that look genuine are checked before they run, with cryptographic proofs the receiving side verifies without asking the issuer. Detection stays; the check sits in front of it.