Teams should combine secret exclusion with network controls that operate below the application layer, so the agent cannot read sensitive material or reach arbitrary destinations. If the agent can only resolve approved hostnames and never sees tokens or SSH keys, prompt injection becomes much harder to turn into exfiltration.
Why This Matters for Security Teams
AI agents are not just chat interfaces. Once an agent can call tools, read repositories, or reach internal services, it can turn a single prompt injection into credential theft, source code leakage, or misuse of privileged APIs. The practical risk is not only malicious intent; it is also accidental overreach when the agent is given more visibility than it needs. Guidance from the OWASP Agentic AI Top 10 and the NIST AI Risk Management Framework both point toward containment, traceability, and least privilege as core design goals.
Security teams often underestimate how quickly an agent can chain ordinary permissions into exfiltration. If a model can read a config file, browse an object store, or make unrestricted outbound requests, then secret leakage may happen without any obvious exploit. The control objective is therefore simple: prevent the agent from seeing secrets in the first place, and constrain every path that could carry data out. In practice, many security teams encounter exfiltration only after an integration has already shipped with broad tool access and no outbound guardrails.
How It Works in Practice
Effective prevention starts with data minimisation. Agents should not receive raw secrets, long-lived API keys, private keys, SSH material, or unrestricted source code access unless the task absolutely requires it. Where access is necessary, use short-lived, scoped credentials and brokered access rather than embedding tokens in prompts, logs, or tool outputs. This is where identity and NHI governance matters: the agent itself becomes a non-human identity that must be provisioned, monitored, and revoked like any other privileged workload identity.
Containment then shifts to the network and execution layers. Teams typically combine egress allowlisting, DNS controls, proxy enforcement, and destination validation so the agent can only reach approved services. If the agent uses retrieval or code tools, those tools should return only the minimum necessary fields, with redaction applied before the model ever sees the response. For adversarial behaviour patterns, the MITRE ATLAS adversarial AI threat matrix is useful for mapping prompt injection and tool abuse to concrete detection points.
- Keep secrets in a vault and inject them only into tightly scoped runtime contexts.
- Restrict agent tool calls to approved actions, hosts, and paths.
- Log tool usage, destination attempts, and policy denials for review.
- Redact sensitive fields before any retrieval result reaches the model.
- Use short-lived credentials so compromise has a narrow blast radius.
For teams building more advanced agent workflows, the CSA MAESTRO agentic AI threat modeling framework helps structure trust boundaries between the model, tools, and external systems. These controls tend to break down when agents are wired directly to production data stores and outbound internet access is still permitted for convenience.
Common Variations and Edge Cases
Tighter exfiltration controls often increase operational overhead, requiring organisations to balance developer speed against data-loss risk. That tradeoff becomes sharper in coding assistants, incident-response bots, and autonomous research agents, where some level of repository or telemetry access is genuinely useful. Best practice is evolving here, and there is no universal standard for how much context an agent should be allowed to hold at any one time.
One common edge case is indirect leakage through logs, screenshots, traces, or tool responses that were not originally designed as secret-bearing channels. Another is the agent that cannot directly access a secret vault but can ask another service to disclose it on its behalf. In those environments, policy must cover both direct and mediated access, and operators should treat every tool as a potential exfiltration path. The NIST AI Risk Management Framework is helpful for assigning ownership and verifying that the controls remain effective after model or workflow changes.
For agent ecosystems with multiple vendors, model routers, or shared memory, the OWASP Top 10 for Agentic Applications 2026 is a strong reference point for design reviews. The harder cases are regulated environments with legacy code paths, because secrets are often duplicated across config files, CI variables, and observability pipelines.
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, MITRE ATLAS, CSA MAESTRO and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | A03 | Agent tool abuse and data leakage are core agentic AI risks. |
| NIST AI RMF | GOVERN | Governance is needed to assign ownership and policy for agent behaviour. |
| MITRE ATLAS | AML.T0001 | Prompt injection and tool abuse map to adversarial AI exfiltration patterns. |
| CSA MAESTRO | MAESTRO models trust boundaries for agentic workflows and tools. | |
| OWASP Non-Human Identity Top 10 | NHI-01 | Agents need constrained non-human identity and secret governance. |
Limit tool scope, sanitize outputs, and block unsafe agent actions before they reach secrets.
Related resources from NHI Mgmt Group
- How should teams govern AI agent access when downstream systems still require secrets?
- How should security teams handle secrets in AI-generated code?
- How do security teams decide whether an AI agent should keep access to regulated data?
- Who is accountable when an AI agent in CI/CD exposes secrets or pushes unauthorized code?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 19, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org