TL;DR: Repository content can steer coding agents into leaking context, following injected instructions, running destructive commands, or introducing unsafe dependencies before a pull request exists, according to DeepKeep. That shifts security from merge-time review to runtime control over prompts, tools, and approvals.
At a glance
What this is: NHI Mgmt Group's analysis, drawing on DeepKeep's blog post: Agentic coding agents can be manipulated through repository content and runtime tools before a pull request is created, so merge-time review alone is too late.
Why it matters: Security teams need controls for prompt exposure, tool use, dependency intake, and write access because coding agents operate with developer and delivery-system privileges before code review starts.
Context
Agentic coding systems read repository files, execute commands, install packages, call MCP tools, and make changes that affect code, CI, and infrastructure. That creates a security boundary long before a pull request is opened, because the agent can already have seen sensitive material or acted on untrusted content.
Repository text can function like input, instruction, and supply chain all at once. A malicious issue, comment, or rules file can shape model behaviour, while untrusted dependencies and tool outputs can expand the blast radius if they are treated as trusted context. Agentic AI Security Guide applies here because the problem is not just code quality, but governed action under delegated access.
Key questions
Q: How do coding agents become exposed through repository content?
A: Coding agents become exposed when repository files, issues, comments, and tool responses are treated as trusted context. That material can contain hidden instructions, secrets, or misleading references that change what the agent reads, installs, or writes. The control problem is context governance, not just source code review.
Q: Why do agent approvals need to bind exact commands and targets?
A: Because an agent approval should authorise one specific action on one specific target, not a broad class of future actions. Binding exact commands and targets prevents prompt injection, command substitution and privilege creep, and makes revocation and audit trails unambiguous. Approval should record the executable, arguments, repository, environment and destination system.
Q: How should teams sandbox AI coding agents?
A: Teams should sandbox AI coding agents in isolated workspaces with no direct production access, tightly scoped network routes and task-scoped credentials. The sandbox should restrict filesystem paths, shell commands and outbound connections, and should require human approval before code is merged or deployed. That limits lateral movement if the agent is manipulated.
Q: What is the best way to secure package installation in coding agents?
A: Secure package installation by forcing the agent to verify dependency provenance before it installs anything. Use pinned versions, signed packages where available, checksum validation and allowlisted registries, and deny arbitrary shell installation commands. The agent should install only from approved sources and should not inherit broad repository or system-level write access.
Technical breakdown
How repository content becomes a control channel
An agent does not just read code. It also consumes adjacent repository artefacts such as issues, comments, documentation, configuration files, and tool responses, which can all carry instructions or misleading context. That means the repository behaves like a semi-trusted input channel, not a static source tree. If retrieval, ranking, or summarisation treats all fetched material as equal, an attacker can steer the agent with content that looks ordinary but is designed to influence downstream actions. See the AI Coding Agents Security Guide.
Practical implication: Treat repository reads as a policy boundary and filter untrusted material before it reaches the model.
Why hook-based controls matter in the agent lifecycle
Coding-agent risk changes at each step of the run. A pre-context checkpoint can redact sensitive inputs, a pre-tool hook can block unsafe commands, a post-tool hook can inspect outputs before they become model evidence, and a pre-write hook can stop dangerous changes from reaching CI or infrastructure files. This is an execution problem as much as a content problem, because the dangerous step is often the action the agent is about to take, not the text it first saw.
Practical implication: Place controls at read, tool, and write boundaries rather than relying on a final pull request review.
How untrusted dependencies become an agent supply-chain risk
Coding agents can suggest or install packages that are outdated, unsafe, or fabricated, and that makes dependency handling a supply-chain issue, not just a developer convenience issue. Hallucinated package names and installer scripts can introduce hidden execution paths, while lookalike packages can exploit an automated workflow that trusts model recommendations. The risk is amplified when the agent can modify manifests, install dependencies, or run setup commands without independent verification.
Practical implication: Verify package provenance and review every new dependency before allowing the agent to install or pin it.
Threat narrative
Attacker objective: The attacker wants the coding agent to make unsafe changes or reveal sensitive data while appearing to operate inside normal development workflows.
- Entry occurs when a malicious repository artefact, such as an issue, pull request comment, README, or rules file, is consumed as trusted context by the coding agent.
- Credential and instruction abuse follow when the agent acts on that context, installs an untrusted package, or runs a command that exposes secrets or changes controls.
- Impact appears when the agent writes unsafe code, weakens CI, or alters infrastructure and authentication files before human review catches the change.
Breaches seen in the wild
- PHP Git server compromise 2021: Commits faked in two PHP maintainers' names put a backdoor in php-src; the pushes used php.net passwords, likely from a leaked user database.
- Uber breach 2016: An AWS key posted to Uber's private GitHub repositories let intruders copy data on 57 million people; Uber paid $100,000 and hid it for a year.
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
Repository content has become a runtime attack surface, not just a code review artefact. Agentic coding systems treat repository material as context for action, which means issues, comments, docs, and rules files can all influence execution. That widens the governance problem from source control integrity to context integrity. Practitioners should assume that untrusted text can shape tool use before any merge request exists.
Merge-time review is too late for agentic coding risk. Once an agent has read sensitive files, installed packages, or executed a command, the security decision has already been made. The real control point is earlier: authorisation of prompts, tools, and file access. Teams that keep treating the pull request as the first meaningful checkpoint are governing the output, not the behaviour.
Agentic coding introduces prompt-to-merge drift. The system may begin with a narrow request and end with a broad operational change because the agent can expand scope through retrieved context, tool output, and write access. That creates a governance gap between the request owner and the runtime effect. Organisations need a policy model that binds each action to an explicit approval boundary, not a loosely related task.
Developer credentials and CI credentials now need separate assumptions. The same workflow can touch local shell access, repository write access, deployment configuration, and infrastructure definitions. A compromise in one layer does not stay local when the agent can carry context and action across layers. Security teams should treat these as distinct privilege planes and constrain each one independently.
Agentic coding needs an identity model for actions, not just users. The important question is no longer only who opened the session, but which principal authorised each command, package install, and write operation. That aligns with agent identity governance because the runtime decision surface has become part of access governance. Without that model, accountability collapses into a single opaque transcript.
From our research library:
- Internal repositories are 6x more likely to contain secrets than public ones (32.2% vs 5.6%), contradicting the assumption that private repos are safe, according to the State of Secrets Sprawl 2026.
- Only 44% of developers are reported to follow security best practices for secrets management, exposing a significant developer behaviour gap, according to the State of Secrets in AppSec.
- Read next: Agentic AI Security Guide
What this signals
Prompt-to-merge drift: agentic coding changes the unit of governance from a pull request to the sequence of reads, tool calls, and writes that happen before it exists. That means runtime policy has to sit in front of execution, not behind review.
Security teams should expect more attacks that target rules files, dependency choice, and tool selection because those are efficient ways to steer an agent without touching the final diff. The safer posture is to treat every agent step as separately authorisable and auditable.
Developer behaviour remains part of the control surface, especially where repository content and package choice are concerned. Only 44% of developers are reported to follow security best practices for secrets management, exposing a significant developer behaviour gap, according to the State of Secrets in AppSec.
For practitioners
- Gate repository context before model access Redact secrets, internal endpoints, and sensitive files before prompts or retrieved material reach the agent, and treat documentation and issue text as potentially adversarial.
- Authorise every tool invocation separately Require explicit approval for shell commands, MCP calls, package installation, network access, and filesystem writes when the action changes scope or target.
- Isolate coding agents from broad credentials Run agents in ephemeral sandboxes with task-scoped credentials, minimal repository permissions, and controlled egress so a single run cannot reach production assets.
- Review rules files as policy inputs Audit AGENTS.md, CLAUDE.md, .cursorrules, and similar files with the same discipline used for CI configuration because they can persist instructions across runs.
- Verify dependencies outside the model loop Pin approved versions, inspect installation scripts, check publisher identity and registry source, and block any package the agent proposes without independent review.
Key takeaways
- Agentic coding shifts the attack surface into repository context, tool use, and dependency handling before merge review begins.
- Runtime controls matter because a coding agent can already have leaked context, installed unsafe software, or executed an unsafe command before anyone sees the pull request.
- The practical response is to govern prompts, tools, credentials, and write access as separate control points rather than relying on code review alone.
Related NHI Mgmt Group resources: Agentic AI Identity Guide · Agentic AI Security Guide · Zero Trust for AI Agents · AI Coding Agents Security Guide
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, OWASP API Security Top 10 and MITRE ATT&CK define the specific risk controls and attack patterns relevant to this term.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | ASI03 — Identity & Privilege Abuse | Agentic coding risk here centers on over-scoped runtime authority and untrusted action paths. |
| Recommendation — Constrain agent permissions and bind each privileged action to an explicit approval boundary. | ||
| OWASP Non-Human Identity Top 10 | NHI-02 — Secret Leakage | The post warns that prompts and repository context can expose secrets before a pull request exists. |
| NHI-07 — Long-Lived Secrets | Task-scoped credentials are the alternative to agents operating with broad standing access. | |
| NHI-05 — Overprivileged NHI | Coding agents are non-human actors whose permissions should be narrowed to the task at hand. | |
| Recommendation — Filter repository context for secrets before model access and revoke any exposed credentials immediately. Replace persistent credentials with short-lived, task-scoped access for agent runs. Reduce agent permissions to the minimum set needed for the current run. | ||
| OWASP API Security Top 10 | API2 — Broken Authentication | Tool calls and MCP actions depend on correct identity and authorisation checks at runtime. |
| Recommendation — Enforce strong authentication and authorisation on every agent tool invocation. | ||
| MITRE ATT&CK | TA0006;TA0008 — Credential Access; Lateral Movement | The article describes credential exposure and movement from repo context into wider development systems. |
| Recommendation — Map agent misuse to credential access and lateral movement during detection engineering. | ||
Key terms
- Agentic Coding: Agentic coding is software development in which AI agents generate, modify, and test code with limited human direction. In security terms, it creates a new NHI control surface because the agent may hold tool access, secrets, and repository permissions, requiring tight IAM, logging, approval gates, and policy enforcement.
- Prompt Injection (Agentic): An attack on applications built on large language models, where crafted text in a prompt or in content the model reads, such as a document, web page or email, overrides the intended instructions. OWASP lists it as LLM01:2025. It becomes most dangerous when an agent can call tools, because the injected instruction can run actions using the agent's own legitimate credentials.
- MCP: Model Context Protocol, an open way for AI agents to connect to tools and data sources. It improves interoperability, but it also introduces a shared integration layer that must be governed carefully because the protocol can widen access across many systems at once.
- Task-Scoped Credential: A task-scoped credential is a secret or token limited to one specific job, workflow, or short time window. It reduces the chance that an AI agent or automation process can reuse access outside its intended purpose, which is essential when the system can operate continuously or autonomously.
Deepen your knowledge
NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, workload identity, and secrets management. It helps security practitioners connect delegated runtime access to the controls that govern it.
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