By NHI Mgmt Group Editorial TeamBased on Cymulate: “When a Web Search Becomes a Backdoor: Remote Code Execution in Codex CLI via Prompt Injection and Binary Hijacking on Windows” (May 20, 2026)

TL;DR: A prompt injection delivered through web.run can plant node.bat in Codex CLI for Windows and trigger host-level code execution outside the sandbox on the next launch, without additional user interaction, according to Cymulate research. Agentic coding tools now need host isolation and execution controls, not just model-side guardrails.


At a glance

What this is: Cymulate shows how a web search in Codex CLI on Windows can become a host execution path when prompt injection plants a runtime-named batch file that later runs outside the sandbox.

Why it matters: This matters because AI coding tools now create new execution and governance boundaries for workstation hardening, file-system monitoring, and agent approval flows.


Context

A host execution gap appears when an AI tool can influence the local operating system outside the boundary its sandbox is meant to enforce. In this case, the problem is not just prompt injection or not just binary hijacking, but the combination of external content ingestion, file creation, and Windows executable search order inside an agentic CLI workflow.

For identity and access programmes, the issue matters because agentic coding tools behave like privileged software with indirect access to credentials, file systems, and developer workspaces. That puts them closer to NHI governance than a simple application security issue, because the control question is who or what can instruct the agent to act, and where those actions are allowed to land.


Key questions

Q: What breaks when an AI coding agent can write files that host tools later trust?

A: The sandbox boundary breaks in practice, even if the agent process itself never escapes. Host tools such as task runners, Git helpers, and IDE extensions may treat agent-created files as trusted configuration and execute them. The result is indirect code execution, which means the real control gap is trust in the artefact, not containment of the process.

Q: Why do prompt-injected agent workflows create host-level risk even when sandboxing is enabled?

A: Because sandboxing only helps if every meaningful action stays inside it. When the agent can read external content, write to the filesystem, and influence a later startup path, the attack survives the sandbox boundary and activates during host execution. The risk comes from chaining otherwise ordinary steps into a delayed code execution path.

Q: What do security teams get wrong about AI coding agent abuse on Windows?

A: They often focus on model refusal or prompt filtering and miss the OS layer. On Windows, executable search order, workspace write permissions, and child-process monitoring can matter more than the prompt itself. If those controls are weak, a seemingly harmless search interaction can become a persistent execution primitive.

Q: Should organisations run AI coding agents on developer laptops or in isolated environments?

A: Isolated environments are the safer default when the agent can ingest untrusted content and write to local paths. Developer laptops usually mix credentials, source code, and trusted execution locations, which expands the blast radius of any injected instruction. The practical trade-off is simple: fewer host dependencies means fewer ways to turn a prompt into code execution.


Technical breakdown

How prompt injection reaches an agentic CLI through web search

Codex CLI's web.run flow retrieves search results and then loads the page content into the model context. That creates a trust boundary problem: the system treats externally sourced text as actionable context, even when it originated on a public page controlled by an attacker. The injection does not need direct shell access. It only needs to be indexed by search and then processed by the agent, which is why ordinary documentation, comments, or answers can become delivery vehicles.

Practical implication: Treat external content ingestion as an execution path, not just a reading path, and constrain when agents are allowed to consume it.

Why Windows executable search order turns a planted file into code execution

On Windows, Codex resolves node.exe and node.bat by name rather than by an absolute path. If a file with that name exists in the current working directory, Windows search order can select it before the intended runtime path. That means a file created by the agent earlier in the session can become a later execution primitive. The sandbox is bypassed because the execution happens in the host process context during startup, not inside the restricted worker.

Practical implication: Force absolute-path runtime resolution and block writable working directories from acting as execution search locations.

Why sandboxing alone does not contain agentic code execution

Sandboxing limits file and OS access only when the agent stays inside the intended boundary. In this case, the attack chain crosses that boundary by using the agent itself to write the malicious batch file and then relying on a later host-level launch step. That makes the security failure architectural, not just a missing permission. Controls must cover file creation, process launch, and tool use together, because each stage can be separately safe while the chain remains exploitable.

Practical implication: Pair sandboxing with host allowlisting, process telemetry, and explicit approvals for file writes that can affect execution paths.


Threat narrative

Attacker objective: The attacker aims to turn a routine agent search into persistent host-level code execution on Windows.

  1. Entry occurs when a malicious public web page is indexed and then loaded through Codex CLI's web.run search-and-browse flow.
  2. Credential access is not the first objective here; the attacker uses prompt injection to make the agent create a malicious node.bat file in the workspace.
  3. Escalation happens on the next launch when Windows search order resolves the planted batch file and Codex executes it from the host context outside the sandbox.
  4. Impact is persistent arbitrary code execution on the Windows machine without further user interaction.

Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Host execution, not prompt injection alone, is the real control failure: the attack works because an AI agent can be induced to create a file that later becomes executable on the host. That means the governance gap sits between model context and OS execution, where traditional prompt filtering stops helping. Practitioners should treat agentic CLIs as execution surfaces with lifecycle control requirements, not as passive developer utilities.

Execution-path poisoning is a useful named concept for this class of failure: a malicious instruction alters the local file or path state so that a later runtime lookup resolves attacker-controlled code. This is materially different from simple prompt injection because the payload persists beyond the original interaction. Security teams should evaluate whether their current controls detect and block path-sensitive writes, not just suspicious prompts.

The sandbox boundary is only meaningful if file creation and process launch are governed together: a sandbox that contains command execution but not workspace writes still leaves a gap for delayed activation. This is especially relevant for AI coding agents because they combine external content ingestion, code generation, and local execution in one workflow. The practitioner conclusion is straightforward: sequence-based controls matter more than single-point content safety.

Windows workstation policy now needs to account for AI agent behaviour as a governance domain: if an AI coding tool can ingest web content, write files, and influence startup execution, then endpoint policy, software allowlisting, and tool-usage scope become identity-adjacent controls. That intersection between host security and NHI governance is where many programmes are still underdeveloped. The field needs to move from model safety talk to enforceable execution governance.

Prompt-injection resilience for coding agents should be measured by host impact, not by model refusal rates: a tool can appear well-behaved in the prompt layer and still be exploitable through filesystem or launch-order effects. That shifts assurance toward observable host telemetry, controlled environments, and validated abuse paths. Practitioners should assess whether their AI tool governance can stop a malicious instruction from becoming a persisted executable artifact.

From our research library:

What this signals

Execution-path poisoning: AI coding agents can turn untrusted web content into a delayed host execution problem when file creation and runtime resolution are not controlled together. That shifts assurance away from prompt filtering alone and toward endpoint policy, allowlisting, and telemetry that can see agent-created artifacts before they are executed.

The stronger the organisation's reliance on agentic CLI tools, the more important it becomes to separate content ingestion from filesystem authority. For teams that already monitor secrets and binaries, the same discipline should now extend to AI-assisted workflows, where a single session can create persistent execution risk.

Cymulate's own secrets research shows Claude Code-assisted commits leaked secrets at a rate of 3.2%, more than double the human-only baseline of 1.5%, with peaks reaching 31 secrets per 1,000 commits in August 2025. That is a reminder that agentic tooling introduces measurable exposure, not just theoretical concern.


For practitioners

  • Restrict AI coding agents to isolated execution environments Run agentic CLI tools in devcontainers, ephemeral virtual machines, WSL with limited file access, or cloud development environments so that workspace changes cannot influence the host OS.
  • Block writable workspace paths from runtime resolution Require absolute-path resolution for runtimes and prevent project directories from being searched before trusted install locations, especially for node.bat, node.exe, and node.cmd.
  • Monitor agent-created files and child processes Alert on unexpected batch file creation, unsigned binaries executing from repository paths, and process trees that originate from AI CLI sessions after web search activity.
  • Treat external content ingestion as a threat model entry point Add prompt injection to the threat model wherever an agent consumes web pages, repositories, issues, or documents, and require human approval for file-system or shell-affecting actions.
  • Vet and restrict AI CLI usage across the organisation Inventory which AI coding tools are present, restrict installation to approved endpoints, and make unresolved execution risks part of procurement and risk acceptance decisions.

Key takeaways

  • The core failure is a host execution gap, where a prompt-injected agent can create a file that later runs outside its sandbox.
  • This article shows how web content ingestion, workspace writes, and Windows search order can combine into persistent code execution.
  • The practical control response is to isolate agentic tools, restrict execution paths, and monitor agent-originated filesystem changes.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-04 — Insecure AuthenticationThe attack uses untrusted context and runtime resolution to trigger execution outside intended trust boundaries.
NHI-06 — Insecure Cloud Deployment ConfigurationsThe sandbox and environment controls are misaligned with the agent's execution path on Windows.
Recommendation — Harden agent startup and trust boundaries so unverified context cannot influence execution. Constrain agent runtime environments so filesystem writes cannot affect host execution paths.
OWASP Agentic AI Top 10ASI02 — Tool MisuseThe agent is induced to use its file-write capability as part of the attack chain.
ASI09 — Human-Agent Trust ExploitationThe injected content exploits the agent's tendency to trust and act on external instructions.
Recommendation — Restrict tool permissions so agent output cannot create executable artifacts without approval. Treat external content as adversarial input and gate agent actions that change local state.
MITRE ATT&CKTA0006;TA0008 — Credential Access; Lateral MovementThe article explicitly maps the chain toward host execution, credential access, and persistence.
Recommendation — Map AI agent abuse chains to ATT&CK techniques and detect host execution from agent processes.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe issue hinges on whether the agent can create files and influence execution through granted permissions.
Recommendation — Review and limit the permissions that let AI tools write or launch host-executable files.
CIS Controls v8CIS-5 — Account ManagementThe recommended response includes restricting tool use and removing excessive host-level access.
Recommendation — Limit AI tool access to approved accounts and remove unnecessary local execution privileges.

Key terms

  • Prompt Injection (Agentic): An attack where malicious instructions are embedded in content that an AI agent reads, causing the agent to execute unintended actions using its own legitimate credentials. A primary vector for agent goal hijacking and identity abuse.
  • Binary Hijacking: Binary hijacking is an attack where a trusted application executes an attacker-controlled file instead of the intended binary. On Windows, this often happens through search-order behaviour, current-directory precedence, or name-based lookup, which makes runtime paths and working directories security-critical.
  • Agentic CLI: An agentic CLI is a command-line tool that uses an AI model to choose actions, call tools, and interact with the local environment on a user's behalf. Unlike a chat interface, it can create files, run commands, and influence host state, which requires explicit governance and containment.
  • Execution Path Governance: Execution path governance is the control of which files, directories, and resolution rules may lead to code being executed. It matters when agents can create or modify workspace files, because a later launch can turn those artifacts into active code if host resolution is not tightly constrained.

Deepen your knowledge

The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, agentic AI identity, machine identity security, and secrets management. It helps security and identity practitioners build the control models needed for agent-driven environments.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 1, 2026.
Updated on October 13, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org