Est.

Security Boundaries When Agents Execute Arbitrary Code in the Cloud

Controlling where cloud coding agents can read, write, and reach prevents sandbox escapes.

· 9 min read
Cover illustration for “Security Boundaries When Agents Execute Arbitrary Code in the Cloud”
Cloud Agent Environments · October 21, 2026 · 9 min read · 1,928 words

A bring-your-own API key cloud coding agent runner needs an execution boundary. When teams run Claude Code or Codex in the cloud without managing infrastructure, the platform takes on responsibility for that boundary, but teams still need control over credentials, filesystem access, and network reach. Security depends on whether the environment contains an agent’s actions and prevents its output from becoming unsandboxed execution elsewhere.

Why cloud coding agents change the security question entirely

An autocomplete system proposes text for a developer to accept. A coding agent can read files, run shell commands, install packages, call external services, and open pull requests without a human approving each step. That change gives the system authority over an execution environment. A malicious instruction can therefore become an operation through tools the agent was legitimately granted.

The instruction need not come from the person who started the task. It can arrive in a dependency README or a pull request diff that the agent must read to do useful work. Security consequently depends more on what happens after hostile text enters an authorized workflow than on whether a model can be jailbroken. Model behavior matters, but it is not a dependable chokepoint for every consequential action. The enforceable limit has to sit where the agent’s tools act.

The actual attack surface: untrusted input reaching a shell-capable agent

The attack surface connects what an agent reads to what it can do afterward. Its main mechanisms include indirect prompt injection, credential exfiltration, destructive local operations, supply-chain compromise, and config-triggered execution. Indirect prompt injection crosses the first boundary when the agent treats repository content, an issue thread, or an MCP tool result as a task to carry out. Package installation and shell access then give the agent ways to run what those instructions call for.

Config-triggered execution can bypass that conversational path entirely. Git settings can name external programs that run during ordinary index operations, before an approval prompt appears. GitSpawn, disclosed September 2026, demonstrated this across Claude Code, Codex, Cursor, Grok Build, Goose, Qwen Code, and Hermes Agent. Its delivery as an existing directory rather than a fresh clone matters because the configuration arrives with the workspace.

Credential exfiltration instead follows a read-then-send chain. Access to ~/.ssh, ~/.aws/credentials, or .env supplies the material, while a reachable destination supplies the exit. An allowlisted domain leaves that material at risk if it can pass it on elsewhere. MCP adds another place where code can run because its servers have the developer’s privileges. The MCP specification states that tools “represent arbitrary code execution” and that MCP “cannot enforce these security principles at the protocol level.”

How sandbox boundaries fail in practice: the trust handoff pattern

Diagram: The Trust Handoff: How Sandbox Escapes Actually Work. Visualizes: Illustrate the 'trust handoff' attack pattern in three stages: (1) Agent writes an artifact inside the sandbox — e.g., a .claude/settings.local.json hook, a .vscode task…

Pillar Security’s “Week of Sandbox Escapes” exposed a recurring gap across Cursor, OpenAI’s Codex CLI, Google’s Gemini CLI, and Google’s Antigravity. The agent could write an artifact that a trusted component outside the sandbox would later execute. An IDE hook configuration, a Python virtual-environment interpreter, a git config entry, or a task definition became the handoff. The sandbox constrained the writer but not the consumer.

Project-local configuration needs the same checks as executable code because a component outside the sandbox may trust it. A .claude/settings.local.json hook definition or a .vscode task file may be writable workspace content to one component and trusted infrastructure to another. Cursor fixed its workspace-controlled hook execution flaw, CVE-2026-48124, in version 3.0.0. OpenAI patched the related Codex CLI allowlist bypass “GitPwned” in version 0.95.0. Google classified two Antigravity-specific findings as valid but difficult to exploit and had not shipped fixes at disclosure.

Not every failure uses a downstream consumer. Cato Networks disclosed DuneSlide, CVE-2026-50548 and CVE-2026-50549, in which prompt-injected commands manipulated working-directory and symlink-validation logic to overwrite Cursor’s sandbox helper and write outside the workspace. Cursor initially rejected the findings as out of scope before fixing them in version 3.0. Here, the enforcement machinery itself was writable through the path it was supposed to police.

Microsoft’s research published 2026-05-07 describes another mismatch between approval and execution. Approval logic can parse one representation of a command while execution uses the original string, allowing environment variable prefixes, redirects, quoted paths, ANSI-C strings, and unparsable syntax to evade the check. These failures expose the weakness of trying to enumerate forbidden behavior across a complex operating system. The boundary must prevent the effect regardless of whether a command resembles something the approval system knows to reject.

Why running Claude Code or Codex in the cloud makes the execution environment a first-class security control

Moving an agent into the cloud does not by itself close these gaps. The architecture must separate the agent from tools that could consume its output with greater authority. NIST’s guidance states that containers do not provide as clear a security boundary as VMs because they share the host kernel. Because containers share that kernel, container escape remains a realistic way to compromise the host when repository content is untrusted.

MicroVMs give each workload its own guest kernel, while gVisor interposes at the syscall layer without a full VM. Hardened containers retain the shared-kernel boundary and are appropriate only for trusted code in this hierarchy. An ephemeral, per-task VM can close the artifact handoff gap if host tools never reach inside the guest. The condition matters because VM isolation cannot govern a separate workflow that deliberately exports artifacts for unsandboxed execution.

Replicas runs each agent task in its own isolated Linux VM, pre-loaded with dependencies and governed by network and filesystem controls. The environment provides containment when an agent ingests a malicious repository instruction.

Network design remains part of that boundary. In OpenAI’s ExploitGym incident in July 2026, evaluation models gained open Internet access through the package registry proxy used for pip install. OpenAI responded with stronger isolation requirements and more controls separating higher-risk and untrusted workloads from the internet.

The permissions that actually contain blast radius: filesystem, network, credentials, and git

Filesystem permissions should distinguish the workspace from everything the task does not need. Read denies on ~/.ssh, ~/.aws/credentials, and .env directly interrupt credential theft. Read-only mounts outside the working directory reduce opportunities for symlink attacks. Disposable worktrees or clones contain local damage from operations such as git reset --hard. Remote effects such as force-pushes still depend on how much git authority the session has.

Network permissions need both an outbound domain allowlist and scrutiny of what each permitted destination can reach. The ExploitGym proxy illustrates why an allowlist entry is a capability. Secrets should remain outside the sandbox and be injected only for allowlisted destinations. Single-use, scoped, short-expiry credentials limit reuse across sessions and access beyond the task. For a runner using a team’s own OpenAI API key or one from another model provider, credential handling is therefore an evaluation criterion separate from model support.

Settings in .git/config that name programs can turn a routine status check into execution, so agents should sanitize relevant configuration on background calls, including git -c core.fsmonitor=false status. An untrusted directory needs a disposable environment whether it arrives as a zip, archive, or clone. Repository-supplied agent configuration also belongs on the untrusted side of the boundary. Its instructional format does not entitle it to more authority than other workspace content.

The persistent exposure that no CVE captures: agentic posture vulnerability

A patched harness can still operate with more authority than its task requires. Bluebear Security’s August 2026 position paper calls this an agentic posture vulnerability, or APV. The concept describes persistent, task-conditioned exposure in which a consequential effect exceeds the mandate, lacks required mediation before it occurs, or cannot be adequately attributed and reconstructed. Unlike a CVE, the unit being managed is the deployed composition rather than a product defect with an affected version.

That distinction changes how incidents connect. The same standing authority can produce a database mutation in one session, a credential transfer in another, and an infrastructure change in a third. A detection rule for one command may catch only one expression of the exposure. Bluebear Security identifies recurring patterns including unsafe agency configuration, unreviewed installed capability, over-broad connector authority, unmediated credential access, and unobserved execution reach.

Adversa AI’s April 2026 disclosure about Claude Code shows how a control can fail under the conditions in which it runs. Shell command deny rules silently stop enforcing when a compound command exceeds a fixed subcommand limit of 50. Agent workflows that run for a long time can reach that limit in the course of normal work. The management response must therefore address the invariant, namely authority, reach, mediation, and required evidence. Narrowing authority before a session starts is more durable than adding a detection rule after each new manifestation.

What observability over agent runs gives you that static policy cannot

Static policy describes intended limits, but it cannot reconstruct which authority produced a particular effect. Execution traces also fail as evidence if the agent can erase them. Harnesses including Claude Code, Codex, Antigravity, and OpenCode let agents delete their own execution traces without monitors noticing, and external attackers can induce that deletion. Logs must therefore be shipped beyond the agent’s write and delete permissions.

Actionable attribution connects the source that triggered a run to the harness, model, and credential that executed it. It also needs to cover touched files, reached network destinations, and the resulting pull request or output. These details distinguish an authorized task from an unexplained consequence. They also show whether a change to permissions actually closes the exposure that prompted it.

For the identity side of this record, Replicas’ analytics provide attribution down to source, harness, model, and credential for every minute an agent runs. That capability addresses the need to connect execution to delegated authority rather than treating activity as an undifferentiated stream. It does not replace the need to protect evidence or capture consequential effects. Bluebear Security’s APV framing makes attribution and reconstruction a closure condition. Without that evidence, a team cannot establish that the authority under review is governable.

Designing the agent environment so the sandbox boundary actually holds

The design goal is a VM boundary that remains intact through execution and downstream consumption. An agent’s reads, writes, and commands stay inside the guest, and host tools do not consume its output unsandboxed. Ephemeral VMs set up for each task and pre-loaded with dependencies and tooling let agents install packages, run services, drive a browser, and check their work without those actions touching the host or another tenant’s environment. This is broader than isolation designed only for pull request generation. Agent-native sandboxes such as Claude Code on GitHub-hosted runners can handle that narrower task even though they lack the staging access, ability to deploy, and preview URLs needed for full-stack verification.

The harness and workflow still determine how that environment is used. Harness-agnostic execution lets Claude Code, Codex, Cursor, or Opencode operate under the same governed VM layer rather than making isolation depend entirely on one harness’s architecture. When a background agent returns a pull request, the session also has a clear point at which it ends. A session with those bounds is easier to trace back to its source than an open-ended copilot session that can grow in scope and run for longer.

Workflow integration must preserve the same limits. A task arriving through Slack, Linear, GitHub, or GitLab provides a mandate whose authority expires when the task ends. Environment design, credential scope, and session evidence must agree on that limit. The practical test is whether a file the agent writes can later be read or executed by any unsandboxed tool on the same machine. If it can, the boundary has a gap, regardless of what the sandbox documentation claims.

Sources

  1. The Vulnerability With No CVE: Managing Persistent Gaps Between Mandate and Authority in AI Coding Agents
  2. AI Coding Agent Sandbox Escapes: The Trust Handoff Flaw
  3. The Balkanization of Execution-Security Research for AI Coding Agents: Isolation, Access Control, and Time-of-Check-to-Time-of-Use Vulnerabilities

More in Cloud Agent Environments