Subscribe to the Non-Human & AI Identity Journal

What should teams do when an AI agent can access repositories and secrets?

Restrict the agent to a scoped runtime, separate it from the host, and review whether its access is still justified after the task ends. If the agent can read files outside the repository or reach external systems, it should be treated as a high-risk NHI subject to tighter containment and review.

Why This Matters for Security Teams

When an AI agent can read repositories and reach secrets, the risk is not just data exposure. The agent can chain tool calls, infer sensitive patterns, and take actions that outlive the task that created them. Static RBAC is often too blunt for this class of workload because the agent’s behavior is goal-driven, not fixed. Current guidance from the OWASP Agentic AI Top 10 and NIST AI Risk Management Framework points toward runtime evaluation, containment, and explicit accountability rather than broad standing access.

NHI Management Group research shows the issue is already material: The State of Secrets in AppSec reports that 43% of security professionals are concerned about AI systems learning and reproducing sensitive information patterns from codebases. That concern becomes operational when an agent has both repository visibility and secret access, because it can expose credentials, modify code, or call external systems in ways humans did not anticipate. In practice, many security teams encounter agent abuse only after a secret has already been used or exfiltrated, rather than through intentional access review.

How It Works in Practice

The safest pattern is to treat the agent as a high-risk NHI and give it only the minimum runtime it needs for a specific task. That means isolating it from the host, limiting filesystem and network reach, and issuing short-lived credentials only for the task window. In agentic environments, the identity primitive should be workload identity, not a shared service account. Cryptographic proof of what the agent is can come from mechanisms such as SPIFFE/SPIRE or short-lived OIDC tokens, while authorization is evaluated at request time using policy-as-code.

That approach matters because the agent’s access pattern is not stable. A code review agent might need read access to one repository, but an automation agent may also invoke build tooling, inspect logs, or contact an issue tracker. The right control is not “grant developer access forever.” It is “authorize this action, for this repo, for this time, under this context.” The CSA MAESTRO agentic AI threat modeling framework and OWASP Non-Human Identity Top 10 both reinforce this direction: constrain the identity, constrain the tool surface, and revoke what is no longer needed.

  • Use just-in-time credentials with short TTLs and automatic revocation at task completion.
  • Separate the agent runtime from the host and from other workloads.
  • Segment repository access from secret retrieval, and log every secret read.
  • Require real-time policy evaluation for tool calls, not broad pre-approved entitlements.
  • Review whether the agent still needs access after each task, not just at onboarding.

This becomes especially important in workflows where the agent can write code, execute commands, or trigger deployments, because those paths create escalation opportunities that are difficult to predict in advance. These controls tend to break down when the agent operates in a shared CI/CD runner with persistent tokens and unrestricted network access, because one compromise can pivot into repositories, secret stores, and downstream systems.

Common Variations and Edge Cases

Tighter containment often increases operational overhead, requiring teams to balance speed of delivery against blast-radius reduction. That tradeoff is real in developer tooling, CI pipelines, and autonomous remediation agents, where full isolation can slow feedback loops. Best practice is evolving, but there is no universal standard for how much repository breadth an agent should receive when its task spans multiple codebases or services.

One common edge case is read-only access that still becomes dangerous because secrets are embedded in configuration, test fixtures, or logs. Another is an agent that never sees a secret directly but can request one from a vault and immediately use it through a tool chain. NHI Management Group’s Analysis of Claude Code Security and Moltbook AI agent keys breach both show why secret exposure and agentic tool access must be reviewed together, not as separate problems.

Teams should also be careful with long-lived service identities used for automation. Current guidance suggests replacing them with ephemeral, context-aware authorizations wherever possible, especially when the agent can reach external systems or create follow-on actions. If the environment cannot support task-scoped identity, short TTLs, and enforced egress limits, the safer answer is to remove secret access entirely until those controls exist.

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, CSA MAESTRO and OWASP Non-Human Identity Top 10 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.

Framework Control / Reference Relevance
OWASP Agentic AI Top 10 A2 Addresses agentic tool misuse and runtime authorization failures.
CSA MAESTRO T1 Covers threat modeling for autonomous agents with external tool access.
NIST AI RMF GOVERN Supports accountability and oversight for high-risk AI agent behavior.
OWASP Non-Human Identity Top 10 NHI-03 Relevant to rotation and containment of non-human credentials.
NIST CSF 2.0 PR.AC-4 Supports least-privilege access management for machine identities.

Apply least privilege, segment access, and review standing permissions on a fixed schedule.