Independent analysis by NHI Mgmt GroupSource article: Pillar Security, “The Week of Sandbox Escapes Day 5: GitPwned: Allowlist to RCE” (July 20, 2026)

TL;DR: Codex CLI’s second sandbox escape shows how a supposedly safe git allowlist can be turned into arbitrary file write and remote code execution, because git show --output can overwrite .git/config and trigger attacker-controlled diff tools on the next git diff, according to Pillar Security. The lesson is that deterministic guardrails must constrain invocations, not trust model behaviour or command names.


At a glance

What this is: NHI Mgmt Group's analysis, drawing on Pillar Security's research: Codex CLI's second sandbox escape showed that a supposedly safe git allowlist could be turned into arbitrary file write and remote code execution through git show --output.

Why it matters: For IAM and NHI practitioners, the lesson is that model behaviour is not a control boundary, and allowlists must govern the full invocation surface when AI agents can act with user privilege.


Context

A safe-command allowlist only works when the command name and its arguments are equally constrained. In this case, a model-generated git invocation could still write into .git/config, which means the real security boundary was never the sandbox alone but the combination of command semantics, file access, and downstream execution.

AI coding agents expand the identity problem because they act with delegated user privilege while processing untrusted instructions and content. When that delegation is trusted at the command-name level, the organisation has effectively granted a non-human identity the ability to reshape its own execution context.

This is a sandbox escape story, but the underlying governance issue is broader: deterministic controls must validate what an agent is trying to do, not just which tool name it uses. That starting position is becoming increasingly typical as AI assistants move from suggestion engines into active execution paths.


Key questions

Q: What breaks when AI coding agents rely on command allowlists for safety?

A: Allowlists break when a command’s arguments can change it from harmless to dangerous. A trusted binary name does not prove a trusted outcome if flags can redirect output, overwrite configuration, or trigger later execution. Security teams should assess the full invocation path, not just the command label, and remove any tool from the safe path if its parameters can alter file state or runtime behaviour.

Q: Why do command allowlists fail when AI agents can generate arguments?

A: Because the risk sits in the argument space, not only in the command name. A model can choose a permitted command and still attach options that change behaviour from benign to destructive. In AI-assisted execution, the control must validate both the tool and the exact flags before the command runs.

Q: What are the signs that an AI agent conversation is becoming unsafe?

A: Look for repeated reframing, slow escalation toward sensitive actions, probing for tool access, and requests that narrow from a legitimate task into higher-risk operations. Those signals matter because they show the session is changing direction, even if no single prompt is clearly malicious on its own.

Q: Should organisations trust model refusal to block malicious agent actions?

A: No. Model refusal is probabilistic, so it cannot be treated as a reliable control boundary. Organisations should assume the model will sometimes comply with harmful instructions and design deterministic controls that still prevent harmful writes, privilege changes, and downstream execution.


Technical breakdown

Why command-name allowlists fail in agentic execution

A command allowlist is a coarse control: it assumes some binaries are safe in every context. That assumption breaks down when a command accepts flags that change it from read-only to write-capable. Here, git show looked harmless to the policy engine, but --output and --format let it write attacker-controlled content to a repository file. In an AI agent workflow, the model can select the command and the arguments, so security has to evaluate the invocation, not the binary name. The control failure is not the shell, but the trust model around command semantics.

Practical implication: Treat command arguments as part of the security decision, not just the executable name.

How file-write primitives become execution paths

The attack chain depends on turning a file-write primitive into a configuration injection. Writing to .git/config is powerful because Git reads that file on later operations. Once the attacker places an external diff tool in the config, a routine git diff becomes a code execution trigger. This is a classic example of persistence through configuration abuse, where the initial action does not execute code directly but plants state that causes execution later. In agentic environments, that means any writeable control file can become a latent execution surface.

Practical implication: Block agents from writing to configuration files that can alter later tool behaviour.

Why model refusal cannot be treated as a security boundary

Model refusal is probabilistic, not deterministic, and that matters operationally. A workflow that depends on the model refusing a malicious instruction is already brittle, because the same prompt can produce different outcomes across runs. Security controls must therefore assume the model may comply with harmful instructions at some point and still contain the impact. In this case, the sandbox and approval flow were bypassed because the allowlist trusted the command path. That is a governance failure, not an AI quality issue.

Practical implication: Design controls so a compliant model still cannot cross the trust boundary.


Threat narrative

Attacker objective: The attacker wanted durable code execution on the developer host by abusing trusted Git behaviour after a configuration write.

  1. Entry occurred when the agent consumed untrusted documentation that contained an injected instruction to run git show with attacker-chosen arguments.
  2. Credential access was not needed because the attacker abused a safe-listed command to write directly into .git/config under the user's privileges.
  3. Escalation happened when the malicious config added an external diff tool, turning a later git diff into attacker-controlled code execution.
  4. Impact was remote code execution in the developer environment, demonstrated by launching Calculator and confirming the payload fired on routine Git use.

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

Invocation, not command name, is the control boundary: this case shows that AI agent governance fails when policy stops at the binary name. A non-human actor can still weaponise a permitted command through flags that alter state, so the security model has to evaluate arguments, file targets, and downstream effects. Practitioners should treat invocation analysis as part of agent authorisation, not an optional hardening layer.

Configuration files are latent execution surfaces: the write to .git/config was not the end of the attack, it was the persistence mechanism. Any agent that can write to files later consumed by trusted tooling can convert ordinary workflow state into code execution. This is exactly the kind of hidden trust dependency that agentic AI security programmes need to map explicitly.

Model refusal is not a dependable safeguard: the article makes clear that the model may refuse or comply depending on the run, which means behavioural uncertainty cannot be the last line of defence. Secure AI agent design should assume malicious prompts will sometimes succeed at the model layer and contain them with deterministic controls that do not depend on refusals.

Agentic execution abuse: the real failure mode here is a non-human identity being allowed to reshape its own operating context. That is an identity governance issue as much as a sandbox issue, because delegated runtime authority must be bounded by what the agent may do, not by what the model usually chooses to do. Practitioners should align agent authorisation with the actual blast radius of each invocation.

Allowlist trust debt compounds quickly: once one trusted command can write into configuration and trigger later execution, the surrounding policy starts to inherit hidden assumptions. That makes the pattern difficult to scale safely across developer tools, MCP-style toolchains, and other AI-assisted execution paths. Security teams should expect this class of failure to recur wherever safe-listed tools can mutate state.

From our research library:

What this signals

Agentic execution needs authorisation at the invocation layer: the practical lesson is that safe-listed tools cannot be governed by name alone once an AI agent is choosing flags and targets. If the invocation can change state, the policy engine has to reason over the full command line and the file system effects before execution.

Deterministic containment is the only defensible control model: relying on model refusal creates a security dependency on probabilistic behaviour, which is not a stable governance assumption. Teams running coding agents should define which files, hooks, and callbacks are off-limits even when the underlying command appears benign.

Agentic AI identity starts with blast-radius control: the same delegated identity that can suggest changes may also be able to persist them through configuration files if its permissions are too broad. That makes the security question less about whether the model behaves and more about what the agent can still do when it does not.


For practitioners

  • Harden allowlists around invocations, not binaries Require argument-level inspection for every safe-listed command and block flags that change read-only tools into write-capable tools, especially where AI agents can generate the invocation.
  • Remove write access to execution-sensitive config files Prevent agents from writing to files such as .git/config, shell profiles, or tool configuration that can redirect later execution into attacker-controlled code.
  • Constrain agent actions with deterministic policy checks Enforce policy on the final system call or file target, so model refusal or prompt classification is never the only thing standing between safe and unsafe behaviour.
  • Review developer tooling for hidden execution hooks Map commands that can trigger external tools, hooks, or callbacks after a seemingly harmless write, then treat those paths as privileged execution surfaces.

Key takeaways

  • This sandbox escape shows that allowlisting a command name is not enough when arguments can turn a read-only tool into a write primitive.
  • The attack path used .git/config as a persistence and execution bridge, which means configuration files can become latent control surfaces in agentic workflows.
  • Agent governance should be built around invocation control, file-target restrictions, and deterministic containment rather than trust in model refusal.

Standards & Framework Alignment

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

OWASP Agentic AI Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI03 — Identity & Privilege AbuseThe article centres on an AI agent abusing trusted command privileges beyond intended scope.
ASI02 — Tool MisuseThe exploit works by turning a trusted tool into a hidden write and execution primitive.
Recommendation — Bind agent permissions to specific invocations and deny dangerous argument combinations before execution. Validate tool use against intended actions, not just tool approval, and block state-changing flags.
NIST AI RMFGOVERN — AI Governance and AccountabilityThe article is about governance assumptions failing around model behaviour and delegated execution.
Recommendation — Define accountability for agent actions and require deterministic controls over AI-assisted execution.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe problem is overbroad delegated authority that lets an agent alter execution context.
Recommendation — Review entitlements so agent permissions cannot write to execution-sensitive files or hooks.
MITRE ATT&CKTA0003;TA0004;TA0008 — Persistence;Privilege Escalation;Lateral MovementThe chain uses config persistence to move from file write to code execution under user privilege.
Recommendation — Map the workflow to persistence and privilege escalation tactics and hunt for config-file abuse.

Key terms

  • Allowlist: An allowlist is a controlled set of approved origins, methods, or headers that are permitted to interact with a resource. In CORS, it is the practical mechanism that prevents accidental openness while still allowing deliberate cross-origin access when the business need is valid.
  • Sandbox Escape: A sandbox escape is when code breaks out of its intended isolation boundary and gains access to host capabilities. In identity terms, it turns a constrained non-human execution path into a privileged runtime that can touch files, secrets, or downstream systems.
  • Invocation Control: The practice of governing the exact command, arguments, context, and target of an action rather than just the tool label. It is essential for AI agents because the same command can be harmless or dangerous depending on how it is invoked.
  • Configuration-Triggered Execution: A pattern where a file write does not execute code immediately but alters configuration so a later trusted process runs attacker-controlled logic. This is a common persistence bridge in developer tools, shells, and automation pipelines.

Deepen your knowledge

NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, agentic AI identity, and workload identity in a practitioner-focused format. It helps security teams translate identity control ideas into governance decisions for real environments.
NHIMG Editorial Note
Published by the NHIMG editorial team on July 22, 2026.
Updated on October 13, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org