Introduction: AI Agents Are Changing the Security Landscape
We are entering a new phase of enterprise AI adoption. AI applications are evolving from systems that generate responses into autonomous agents capable of interacting with enterprise applications, accessing databases, executing code, calling APIs, and taking actions on behalf of users.
This shift introduces a fundamental security challenge.
Traditional AI security focuses heavily on what a model can say. Agentic AI security must also focus on what a model can do.
For example, an enterprise AI agent might retrieve sensitive customer records, modify CRM data, execute infrastructure operations, or initiate financial transactions. A prompt injection, compromised tool, or overly permissive integration can therefore result in unauthorized actions and data exposure.
As engineering leaders, we must design AI systems where agent actions are authenticated, authorized, isolated, observable, and auditable.
Below are nine essential security areas that every engineering team should consider when building production-grade AI agents, along with recommended practices, technologies, and a practical enterprise reference architecture.
AI Agent Security Best Practices: Summary and Recommended Tools
The following table provides a consolidated view of the nine security areas and recommended technologies.
| Security Area |
Required Best Practices |
Suggested Tools / Frameworks |
| 1. Agent Identity |
Assign every agent a distinct identity.
Enforce user, agent, and resource-level
permissions with least-privilege access.
|
Keycloak, Microsoft Entra ID,
AWS Bedrock AgentCore Identity
|
|
2. Tool Authorization / Policy
|
Validate tool-call arguments, execution
context, and user permissions before
authorizing tool execution.
|
LangGraph middleware,
Open Policy Agent (OPA)
|
|
3. Agent-to-Tool / MCP Authorization
|
Use approved MCP servers, tool allowlisting,
scoped credentials, and trusted
tool definitions.
|
Docker MCP Gateway, agentgateway
|
| 4. Secrets Management |
Keep API keys and secrets out of prompts,
agent context, and source code.
Use scoped, short-lived credentials.
|
Infisical, OpenBao,
cloud secrets managers
|
| 5. Data Security |
Enforce tenant isolation, document-level
ACLs, data classification, and
sensitive-data redaction.
|
Existing backend ACLs,
Data Loss Prevention (DLP)
|
|
6. Prompt Injection Defense
|
Treat RAG content and tool outputs as
untrusted. Prevent external instructions
from controlling privileged actions.
|
NVIDIA NeMo Guardrails,
Meta Prompt Guard 2
|
| 7. Runtime Isolation |
Sandbox code execution, restrict filesystem
access, enforce resource limits, and
default-deny network egress.
|
Docker Sandboxes (sbx),
NVIDIA OpenShell
|
| 8. Observability |
Trace tool calls, authorization decisions,
and agent actions without exposing
secrets or sensitive data.
|
OpenInference, OpenTelemetry (OTel),
Langfuse
|
| 9. Threat Modeling |
Map the architecture to MAESTRO layers
and document cross-layer attack paths
and trust boundaries.
|
CSA MAESTRO, OWASP Agentic AI Security
|
Note: The tools and frameworks listed above represent selected technologies that engineering teams can consider when implementing AI agent security controls. These are not exhaustive recommendations, and the appropriate choice will depend on existing infrastructure, cloud environment, security requirements, and operational maturity. Wherever possible, organizations should leverage established enterprise security capabilities rather than introducing additional tools unnecessarily
1. Agent Identity and Access Management
- Security Area
- AI agents are increasingly acting as independent software identities, performing operations on behalf of users and automated workflows.
- Without distinct identities and clearly defined permissions, agents may inherit excessive privileges or access resources outside their intended scope.
- Authorization should consider three principals: user identity, agent identity, and resource permissions.
- Best Practices
- Assign every agent a unique, verifiable identity.
- Enforce user, agent, and resource-level authorization for every privileged operation.
- Use short-lived credentials, scoped permissions, and workload identities.
- Propagate authenticated user and tenant context throughout agent execution.
- Apply least privilege so an agent cannot access resources unavailable to the requesting user.
- Reuse existing enterprise identity infrastructure instead of building a parallel authentication system.
- Recommended Tools
- Keycloak: An open-source identity and access management platform supporting OAuth 2.0, OpenID Connect, identity federation, and role-based access control. Useful for organizations that want self-hosted authentication and identity management.
- Microsoft Entra ID: Microsoft's enterprise identity platform providing authentication, single sign-on, workload identity management, and integration with enterprise access controls. Suitable for organizations already using Microsoft Azure and Microsoft 365.
- Amazon Bedrock AgentCore Identity: An AWS-managed identity capability designed to help AI agents access external services through managed authentication and credential flows. Particularly relevant for agent platforms built on AWS.
Engineering takeaway: An agent's permissions should represent the intersection of its assigned capabilities and the authority delegated by the requesting user.
2. Tool Authorization and Policy Enforcement
- Security Area
- AI agents can dynamically select and invoke tools based on model-generated decisions.
- However, an LLM's decision to invoke a tool does not establish permission to execute it.
- Every privileged tool call must be evaluated through an independent authorization mechanism.
- Best Practices
- Intercept tool calls before execution and validate their arguments against trusted schemas and business rules.
- Evaluate authorization using the user identity, agent identity, requested tool, target resource, and execution context.
- Apply deterministic policies rather than relying on LLM-generated authorization decisions.
- Enforce default-deny behavior for tools and actions without explicit permissions.
- Require human approval for sensitive operations such as payments, deleting resources, or modifying production infrastructure.
- Record authorization decisions for auditability without logging secrets.
- Recommended Tools
- LangGraph / LangChain Middleware: Provides execution hooks that can intercept agent tool invocations, validate inputs, apply authorization checks, and introduce human-in-the-loop approval workflows. Useful for integrating security checks into agent orchestration.
- Open Policy Agent (OPA): An open-source policy engine that evaluates authorization decisions independently from application business logic. Policies can define which agents may invoke particular tools, access resources, or perform operations under specified conditions.
Engineering takeaway: The LLM proposes an action; the policy enforcement layer decides whether that action is permitted.
3. Agent Tool Authorization Gateway
- Security Area
- The Model Context Protocol (MCP) standardizes how agents connect to external tools, APIs, and data sources.
- While MCP simplifies integrations, connecting agents to untrusted or overly permissive servers expands the attack surface.
- Production systems need governance over which MCP servers and tools agents are allowed to access.
- Best Practices
- Maintain an approved registry of trusted MCP servers.
- Allowlist tools according to agent roles and business use cases.
- Validate tool definitions, schemas, and server configurations before deployment.
- Use scoped credentials and enforce authentication for downstream connections.
- Introduce a centralized MCP gateway to manage routing, access control, and observability.
- Monitor for unauthorized tools, unexpected capability changes, and suspicious tool usage.
- Continue enforcing backend API authorization even when requests originate from an approved MCP gateway.
- Recommended Tools
- agentgateway: An open-source AI-native gateway supporting MCP, agent-to-agent (A2A), and LLM traffic. It provides capabilities such as authentication, authorization, traffic policies, rate limiting, and observability across AI integrations.
- Docker MCP Gateway: A centralized gateway for running and managing MCP servers. It supports server lifecycle management, tool selection, credential handling, and isolation of containerized MCP servers. Useful for controlling agent-to-tool integrations.
Engineering takeaway: Treat MCP servers as integration boundaries requiring the same scrutiny as external APIs. A trusted MCP connection does not automatically make every tool action trustworthy.
4. Secrets and Credential Management
- Security Area
- AI agents interact with databases, cloud services, enterprise APIs, and external applications that require credentials.
- Exposing these credentials inside prompts, agent memory, logs, or source code creates opportunities for credential leakage and unauthorized access.
- Secrets must be handled by trusted infrastructure rather than the language model.
- Best Practices
- Never embed API keys, passwords, access tokens, or private keys directly into prompts or agent context.
- Store secrets in centralized secrets-management platforms.
- Prefer short-lived, dynamically issued credentials over long-lived static keys.
- Scope credentials to the minimum required resources and operations.
- Use credential brokers or trusted execution components to perform authenticated tool calls.
- Automate secret rotation and maintain access audit trails.
- Prevent sensitive credentials from appearing in agent traces or tool responses.
- Recommended Tools
- Infisical: An open-source secrets-management platform with centralized secret storage, access controls, machine identities, audit logging, and rotation capabilities. Suitable for cloud-native applications and AI agent workloads.
- OpenBao: An open-source secrets-management platform for securely storing, distributing, and managing sensitive credentials. Supports policies and dynamic-secret workflows and is useful for self-hosted secrets infrastructure.
- AWS Secrets Manager: A fully managed AWS service for storing, retrieving, and rotating application credentials and API secrets. Suitable for AWS-native agent platforms.
- Azure Key Vault: A Microsoft Azure service for securely managing secrets, encryption keys, and certificates. Well suited to organizations operating within the Azure ecosystem.
Engineering takeaway: Give an agent access to an authorized capability without exposing the underlying credential to the LLM.
5. Data Security and Tenant Isolation
- Security Area
- Enterprise AI agents frequently retrieve information from internal knowledge bases, vector databases, relational databases, and document repositories.
- Retrieval-Augmented Generation (RAG) introduces additional data access paths that can accidentally bypass established application permissions.
- Multi-tenant applications must ensure agents cannot retrieve data belonging to other customers or unauthorized users.
- Best Practices
- Enforce tenant isolation across retrieval, memory, document storage, and tool execution.
- Apply document-level Access Control Lists (ACLs) during retrieval and resource access.
- Preserve existing backend authorization rather than replacing it with model-generated filtering.
- Classify data into appropriate sensitivity categories, such as public, internal, confidential, and restricted.
- Redact or minimize sensitive information before sending it to models, external services, or telemetry systems.
- Implement row-level or resource-level permissions where applicable.
- Validate that vector search results respect the requesting user's access rights.
- Recommended Tools
- Existing Backend ACLs and Authorization Services: Reuse application-level and database-level permission systems to enforce tenant, document, and resource access. These remain the authoritative security controls for enterprise data.
- Data Loss Prevention (DLP) Solutions: Identify and protect sensitive information, including personally identifiable information, payment data, credentials, and confidential business content. DLP capabilities can be integrated into data retrieval and output-processing pipelines.
Engineering takeaway: A document being available in a vector database does not mean every agent is authorized to retrieve it.
6. Prompt Injection Defense and Content Trust
- Security Area
- Prompt injection occurs when malicious instructions embedded in untrusted content attempt to influence an AI agent's behavior.
- These instructions can originate from documents, webpages, emails, RAG results, MCP responses, or external APIs.
- In agentic systems, successful prompt injection can influence tool selection and privileged actions, not just the generated response.
- Best Practices
- Treat all retrieved content and tool outputs as untrusted data.
- Maintain clear separation between system instructions, user requests, and external content.
- Apply input and output screening to identify suspicious instructions and potential data leakage.
- Prevent retrieved documents from modifying agent policies or granting tool permissions.
- Use structured tool interfaces instead of directly executing model-generated commands.
- Combine detection mechanisms with deterministic authorization and least-privilege tool access.
- Include adversarial prompt-injection scenarios in automated security testing.
- Recommended Tools
- NVIDIA NeMo Guardrails: An open-source framework for adding programmable guardrails to LLM-powered applications. It supports controls around interactions, model inputs and outputs, and selected tool-related workflows.
- Meta Llama Prompt Guard 2: A lightweight security classifier designed to detect prompt-injection and jailbreak attempts in text. It can help screen untrusted content before that content reaches an agent's reasoning context.
Engineering takeaway: Prompt-injection detectors are supporting defenses, not authorization boundaries. Even if malicious content reaches the LLM, independent security controls must prevent unauthorized actions.
7. Runtime Isolation and Sandboxed Execution
- Security Area
- Some AI agents can execute shell commands, run Python scripts, install dependencies, modify files, or interact with operating-system resources.
- Model-generated code may contain unsafe operations, unexpected dependencies, or unauthorized network requests.
- Executing this code directly on a privileged host creates substantial security risks.
- Best Practices
- Execute agent-generated code inside isolated sandboxes.
- Restrict filesystem access to approved working directories and mounted resources.
- Apply default-deny network egress with explicitly allowlisted destinations.
- Enforce CPU, memory, storage, and execution-time limits.
- Run agent workloads with unprivileged identities wherever possible.
- Use ephemeral environments to reduce persistence of malicious or unintended changes.
- Consider stronger isolation, including microVM-based environments, for high-risk workloads.
- Keep host credentials and sensitive infrastructure resources inaccessible to the sandbox.
- Recommended Tools
- Docker Sandboxes (
sbx): Docker's sandboxing solution for AI coding agents, providing isolated execution environments with controlled filesystem, network, and tooling access. Useful for development agents and automated code execution. - NVIDIA OpenShell: A security-focused runtime for autonomous AI agents that combines sandboxed execution with policy-based restrictions on filesystem, process, network, and credential access. Useful for governing agents that execute complex workflows.
Engineering takeaway: Assume agent-generated code may be unsafe, and design the execution environment to contain its impact.
8. Observability, Auditability, and Security Monitoring
- Security Area
- AI agent workflows are dynamic and may involve multiple reasoning steps, retrieval calls, tool executions, policy evaluations, and external API interactions.
- Traditional application logs often lack the information needed to reconstruct an agent's actions.
- Production environments require end-to-end visibility into agent behavior and security decisions.
- Best Practices
- Trace agent execution across LLM calls, RAG retrieval, tool invocations, and downstream APIs.
- Record authorization decisions, policy denials, and human approval events.
- Associate activity with agent identity, user identity, tenant, session, and request identifiers.
- Capture tool arguments and responses only when necessary, using redaction or safe metadata instead of sensitive payloads.
- Monitor abnormal tool usage, access failures, and unusual execution patterns.
- Establish appropriate telemetry retention and access policies.
- Integrate security-relevant events with existing monitoring and incident response systems.
- Recommended Tools
- OpenInference: An open-source set of semantic conventions and instrumentation for AI applications. It standardizes how LLM calls, retrieval operations, and tool interactions are represented in traces.
- OpenTelemetry (OTel): An open-source observability framework that provides standardized APIs and tooling for distributed tracing, metrics, and logs across services.
- Langfuse: An LLM engineering and observability platform for capturing agent execution traces, debugging workflows, evaluating model behavior, and analyzing LLM applications.
Engineering takeaway: Every privileged agent action should be attributable, traceable, and auditable without compromising sensitive information.
9. Threat Modeling and Security Governance
- Security Area
- Agentic AI introduces security risks across multiple interconnected layers, including foundation models, agent frameworks, retrieval systems, execution environments, tools, and external services.
- A vulnerability in one layer can propagate through other parts of the architecture.
- Threat modeling must account for interactions between these components rather than assessing each component independently.
- Best Practices
- Perform threat modeling during the initial architecture design phase.
- Identify trust boundaries between the LLM, orchestration layer, data retrieval, tool gateway, and backend services.
- Map architectural components to recognized agentic AI threat models.
- Document cross-layer attack paths, including prompt injection leading to tool misuse or unauthorized data access.
- Assess new threats whenever tools, integrations, or agent permissions change.
- Incorporate threat-model findings into engineering backlog priorities and security acceptance criteria.
- Review security controls throughout the deployment lifecycle.
- Recommended Frameworks
- CSA MAESTRO: The Cloud Security Alliance's Multi-Agent Environment, Security, Threat, Risk, and Outcome framework. It provides a seven-layer threat-modeling approach for identifying vulnerabilities and cross-layer attack paths in agentic AI systems.
- OWASP Top 10 for Agentic Applications: A security guidance framework identifying major risks associated with autonomous AI agents, including agent goal hijacking, tool misuse, identity and privilege abuse, unexpected code execution, and insecure agent communication.
Engineering takeaway: Securing individual components is insufficient. Teams must understand how threats propagate across the entire agent architecture.
Putting It Together: A Practical Enterprise AI Agent Security Architecture
The nine security practices discussed above are most effective when implemented as interconnected platform controls.
A practical execution path might look like this:
User Request → Identity Verification → Agent Orchestration → Tool Policy Evaluation → Approved Tool/MCP Gateway → Protected Backend Services
Across this execution path, the platform should enforce:
- Identity and authorization to control who and what can access resources.
- Data and secrets protection to prevent unauthorized information exposure.
- Prompt-injection defenses and runtime isolation to contain untrusted behavior.
- Observability and threat modeling to provide continuous assurance and accountability.
The most important architectural decision is to keep security enforcement outside the model's discretionary reasoning process.
The LLM can plan, recommend, and request actions. Trusted application infrastructure must control whether those actions are permitted.
My Recommended Implementation Strategy for Engineering Teams
When building an enterprise AI platform, trying to implement every possible security product at once is rarely the most effective strategy.
I prefer approaching agent security incrementally, with clear production readiness gates.
Phase 1: Establish the security foundation
Start with authenticated agent identities, tenant-aware data access, tool allowlisting, backend authorization, and centralized secrets management. These controls should be in place before granting agents access to sensitive systems.
Phase 2: Secure integrations and execution
Introduce MCP governance, deterministic tool authorization, sandboxed execution, and stronger controls for high-impact operations.
Phase 3: Build visibility and validation
Integrate distributed tracing, authorization audit events, prompt-injection testing, and security evaluations into the development and deployment lifecycle.
Phase 4: Continuously improve security posture
Use MAESTRO and OWASP guidance to assess evolving threats. Review agent privileges, test negative authorization scenarios, monitor policy failures, and automate security checks through CI/CD.
Before production release, teams should demonstrate that an agent cannot retrieve an unauthorized document, invoke an unapproved tool, bypass backend permissions, expose credentials, or access prohibited network destinations.
These are measurable engineering outcomes—not just security policy statements.
Final Thoughts: Secure AI Agents by Design, Not by Prompt
As AI agents become more capable, their security architecture becomes just as important as their reasoning capabilities.
One of the biggest mistakes we can make is assuming that strong system prompts, a capable foundation model, or a guardrail library will be sufficient to secure an autonomous system.
They are useful components, but they are not substitutes for established security engineering principles.
Identity management, least-privilege authorization, secrets protection, data isolation, secure execution, and comprehensive observability remain fundamental.
What changes with agentic AI is the number of trust boundaries and the speed at which the system can act across them.
As an Engineering Manager working in AI/ML, I believe the long-term success of enterprise agents depends on treating security as a core platform capability from day one.
The goal is not to eliminate agent autonomy. It is to establish clearly defined boundaries within which that autonomy can operate safely.
Build intelligent agents, but make their permissions explicit, their actions verifiable, and their execution environments secure.
That is how we move from promising AI agent prototypes to trustworthy enterprise AI systems.
References and Further Reading