TL;DR: Attacker-controlled repo context can turn Codex trust prompts into code execution and system compromise, according to Ent.ai, when rules files and AGENTS.md content steer an agent to run commands outside the sandbox. The security boundary shifts to pre-execution inspection and endpoint visibility because repository trust can already mean compromise.
At a glance
What this is: NHI Mgmt Group's analysis, drawing on Ent.ai's blog post: attacker-controlled repository context can convert a trusted Codex session into code execution and system compromise.
Why it matters: IAM and NHI practitioners should treat agent trust decisions, repo context, and local execution boundaries as one governance problem, because the attack happens before conventional controls can intervene.
Context
Coding harnesses are turning repository contents into executable instructions, which creates a governance problem that sits between developer workflow, endpoint security, and identity-bound access to local tools. When a trusted repo can steer an agent to run commands, the control boundary is no longer just authentication or sandbox policy, but the quality and provenance of the context the agent consumes.
The identity angle is real because these systems act with delegated authority, inherit permissions, and can trigger actions under a user's session without a separate approval path. That makes repository trust, agent delegation, and local privilege management part of the same control surface, especially when attacker-controlled config files arrive through a cloned repo. This starting position is becoming increasingly typical as coding agents accumulate more ambient trust.
The attack pattern is a concrete example of agentic code execution risk, where instruction files and repo artefacts become an indirect execution channel.
Key questions
Q: How should teams stop repo instructions from triggering agent code execution?
A: Treat repository files as untrusted input and keep agent execution separate from repository-controlled instructions. Use a allowlist of permitted command templates, run tools in a sandbox, and require human approval before any command that changes files, secrets or network state. The phrase repository context is untrusted captures the core control boundary.
Q: Why do delegated AI agents expand the impact of a single trust decision?
A: Delegated AI agents expand the impact of a single trust decision because they can act under the parent session's permissions across multiple tools, data sets and downstream actions. If the agent is compromised or over-scoped, one approval can expose files, send messages, create changes or trigger privileged workflows without a new human decision.
Q: How do malicious AGENTS.md files influence coding agents?
A: Malicious AGENTS.md files can steer coding agents by supplying hidden instructions that change tool use, code edits, file access and network calls. If the agent ingests repository instructions without trust boundaries, the file can redirect it to exfiltrate secrets, alter code or execute unsafe commands during normal development workflows.
Q: What is the best way to detect agent abuse on developer endpoints?
A: Use endpoint telemetry to detect agent abuse by correlating process launches, shell commands, file writes, clipboard access, browser activity and outbound connections from developer devices. Look for unusual command sequences, privilege escalation, access to secrets stores, or agent tool calls that do not match the developer's normal work patterns.
Technical breakdown
How repo context becomes executable instruction
Coding agents often parse local files such as rules, prompts, and task instructions before they answer the user's request. When those files are treated as authoritative context, they can shape the agent's next action, including whether to run a shell command or delegate a task. The risk is not a classic buffer overflow or memory corruption issue. It is a trust and interpretation failure, where structured text from the repository is converted into operational authority inside the agent runtime. See the OWASP Agentic Top 10 ASI05 Guide.
Practical implication: Review repository-loaded agent context as an execution path, not as documentation.
Why subagent inheritance expands blast radius
A subagent that inherits the parent agent's permissions can reuse the same filesystem, command, and network capabilities that the parent already holds. If the parent is prompted into starting a subtask from attacker-controlled instructions, the subagent becomes a privileged extension of the attack chain. That inheritance makes the attacker's path more reliable, because the malicious step does not need to win a fresh trust decision at every hop.
Practical implication: Separate subagent privileges from parent-session permissions wherever task delegation is allowed.
How attack chains persist after the first clone
The danger does not end when a repository is initially inspected. If an allow rule is tied to a command pattern rather than to the content it executes, later changes to the script can turn a once-benign action into a malicious one without revisiting the trust decision. That persistence is what makes repo-based agent exploitation resilient: the approval stays valid while the payload changes underneath it.
Practical implication: Bind approvals to immutable artifacts or hashes, not to mutable command paths.
Threat narrative
Attacker objective: The attacker wants trusted repository context to trigger execution on the victim system, then steal secrets and establish control over the host.
- Entry occurs when the victim clones a repository containing attacker-controlled agent rules and instruction files.
- Credential_access follows because the agent is steered to execute outside the sandbox and can then reach local secrets and session material.
- Escalation happens when the delegated task runs under inherited permissions and the attacker-controlled command gains full code execution on the host.
- Impact is system compromise with secret discovery, collection, and exfiltration to an external command-and-control endpoint.
Breaches seen in the wild
- CI/CD pipeline exploitation case study: Credentials in an exposed .git/config let a researcher edit a Bitbucket pipeline so it planted their SSH key on the server. No victim was named.
- EmeraldWhale Git config credential theft: Tokens in exposed .git/config files let EMERALDWHALE clone private repositories and steal more than 15,000 cloud credentials.
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
Trusted repository context has become an execution primitive: the real governance failure is not whether a sandbox exists, but whether an agent is allowed to convert untrusted repo content into authority. Once file-based instructions can trigger shell activity, security teams need to treat cloned code as executable policy, not just source material. The practical conclusion is that context ingestion must be governed before the first prompt reaches the model.
Delegated agents inherit more risk than most teams model: subagent permission inheritance turns a single trust decision into a multi-step attack path. That is a classic identity problem in a new wrapper, because the agent is acting under delegated authority with no fresh human checkpoint. Teams should align agentic code execution controls with session-scoped privilege boundaries, not with the user's expectation that a repo is merely data.
Approval tied to command patterns creates persistence debt: if an allow rule references a mutable script path, later changes can preserve the permission while changing the payload. This is the same class of governance mistake that makes overbroad access hard to unwind in identity programmes. Practitioners should require immutable references, verified provenance, and revocation paths for anything an agent can execute.
Detection has to move from command output to context lineage: the hard part is not seeing a shell command after the fact, but tracing which repository instruction caused the agent to issue it. That means the security model needs line-of-sight into repo files, delegation chains, and local execution, with no assumption that agent-to-agent communication will remain readable. The control gap is visibility across the trust boundary, and that is where defenders need to focus.
What this signals
Agent trust has to be governed as a runtime identity problem: when repository context can trigger execution, the operative question is who or what is authorised to act inside the session. That moves control from code review alone to a combination of provenance checks, delegated privilege limits, and local runtime inspection.
Context lineage will become a more important detection signal than command strings: teams that cannot trace which file, rule, or instruction caused the agent to act will keep missing the real attack path. The useful future state is to detect unsafe context before it reaches execution, not to infer intent from shell output after the fact.
Permission inheritance in agentic workflows is a named governance gap: once a subagent reuses the parent's authority, the trust boundary has already shifted. Organisations should design for explicit task-scoped authority and revocation, because inherited permissions make agent misuse harder to contain.
For practitioners
- Treat cloned repositories as executable inputs Block the assumption that repo content is inert. Require review of rules files, AGENTS.md content, hooks, and similar context files before any agent can consume them.
- Separate agent context from command authority Prevent repository-loaded instructions from directly authorising shell execution, especially where a subagent can inherit the parent session's permissions.
- Bind execution approvals to immutable artifacts Use hashes, signed references, or pinned artifacts so an approval cannot silently follow a changed script path after the first trust decision.
- Reduce local privilege on development endpoints Keep the user session least-privileged so a successful agent escape has less room to discover secrets, modify files, or reach sensitive system locations.
- Instrument agent-to-subagent activity for investigation Capture enough endpoint and harness telemetry to reconstruct which context file triggered a task handoff and which command actually ran.
Key takeaways
- Repository-loaded agent instructions can become an execution channel, so the trust boundary needs to move before the first prompt.
- The attack works because delegated agent permissions and mutable repo content combine into a reliable path to host compromise.
- Defenders need provenance checks, immutable approvals, and endpoint visibility that tie commands back to the context that caused them.
Related NHI Mgmt Group resources: OWASP Agentic Top 10 ASI05 Guide · AI Agent Sandboxing and Code Execution Guide · AI Generated Code Security Statistics · AML.T0050 Command and Scripting Interpreter
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, OWASP Non-Human Identity Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST CSF 2.0 sets the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | ASI05 — Unexpected Code Execution | Repo instructions can steer an agent into running commands outside the sandbox. |
| Recommendation — Constrain agent execution paths so repository context cannot directly authorise unexpected code execution. | ||
| OWASP Non-Human Identity Top 10 | NHI-10 — Human Use of NHI | The attack depends on a human trusting a repo so the agent can act with delegated authority. |
| Recommendation — Treat human-granted agent trust as a bounded privilege and require explicit review before execution. | ||
| MITRE ATT&CK | TA0002;TA0006;TA0011 — Execution; Credential Access; Command and Control | The chain moves from initial execution to secret theft and external exfiltration. |
| Recommendation — Map repo-triggered agent abuse to execution, credential access, and command-and-control detections. | ||
| NIST CSF 2.0 | PR.AA-05 — Access Permissions, Entitlements and Authorizations | The core issue is excessive authority granted to the agent and its delegated subtask. |
| DE.CM-06 — Monitoring for Unauthorized Personnel, Connections and Devices | Detection depends on seeing suspicious agent activity on the endpoint as it happens. | |
| Recommendation — Apply least-privilege authorization to agent sessions and delegated subagents. Monitor agent actions and local command activity for unauthorized execution paths. | ||
Key terms
- Codex: OpenAI's coding agent environment that can read repository context, interpret instructions, and execute developer tasks. In this attack pattern, the security concern is not the model alone but the surrounding trust model, because repository files can shape what the agent runs and with what authority.
- Delegated authority: Delegated authority is permission given to one identity to act on behalf of another within defined limits. In identity systems, it enables an agent, user, or service account to perform approved actions without owning the underlying rights, using scoped tokens, roles, or approvals to constrain access and accountability.
- 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.
- Endpoint Telemetry: Endpoint telemetry is the process and event data collected from managed devices to understand local activity. For shadow AI, it includes process spawns, file access, and direct outbound calls from the operating system, giving security teams visibility that network tools and SaaS logs often miss.
Deepen your knowledge
NHI Mgmt Group covers identity security, NHI governance, and agentic AI through independent research, practitioner guides, and the NHI Foundation Level course. It helps security and IAM practitioners build the governance model needed for delegated access, machine identities, and agentic workflows.
Published by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org