Securing AI Agents: Identity, Least Privilege, and Tool Permissions
A defense-in-depth guide to limiting what autonomous AI workflows can access and change. This guide explains the core concepts, practical trade-offs, evaluation choices, and responsible implementation steps for the topic.
Key Highlights
- Give agents distinct, scoped identities and short-lived, revocable credentials.
- Enforce permissions and validate all tool calls outside the model.
- Treat retrieved content and tool output as untrusted; isolate runtime and restrict network access.
- Require approval for consequential actions and retain privacy-aware audit trails.
Give agents scoped identities
Treat an agent as a non-human principal, not as a trusted extension of its user. Give each agent or workflow an identifiable owner, a scoped identity, and permissions tied to a specific task. Avoid shared administrator credentials and long-lived secrets. Separate planning from execution so that model-generated text cannot grant itself new authority.
Authorize every sensitive action in application code. Validate tool names, schemas, arguments, object ownership, and allowed destinations on the server. A prompt that instructs a model to “stay within policy” is not an access-control boundary. Apply least privilege at the identity, API, database, file, and network layers.
Constrain tools and capabilities
Design tool access as explicit capabilities. Allow-list the minimum actions, fields, and resources required; use short-lived tokens; and require confirmation for irreversible or high-impact actions. Read-only access should be the default where possible. Rate limits, transaction limits, and idempotency keys reduce damage from loops or repeated calls.
For MCP and other tool protocols, inventory servers and tools, verify the origin and integrity of components, pin versions, review permissions before connection, and treat tool descriptions and returned content as untrusted input. A protocol standard can improve interoperability; it does not make a server safe by itself.
Defend against hostile inputs
Separate untrusted data from instructions. Retrieved documents, emails, web pages, and tool responses can contain prompt injections that attempt to redirect an agent. Use content labeling, constrained tool schemas, independent policy checks, and output validation. Do not rely on keyword filters as the sole defense.
Run agents in isolated environments with restricted egress and access to only task-specific files. Protect secrets from model context and logs. Use human approval for financial transfers, account changes, external messages, code deployment, or other actions where mistakes are difficult to reverse.
Audit, revoke, and recover
Log the identity, policy decision, tool request, approval, result, and revocation state for each action. Redact credentials and minimize retained personal data. Monitor unusual access, unexpected writes, repeated failures, and changes in tool behavior. Make credentials revocable without waiting for a model session to end.
Threat-model the full chain: user, model, orchestration layer, tool server, identity provider, data store, and external service. Test compromised tools, malicious retrieved content, model changes, and partial outages. Define an emergency stop and practice it before enabling broad autonomy.
Example: limit an agent that schedules meetings
The agent receives a short-lived identity that can read only the user’s free/busy status and create a tentative invitation. Application code validates participants and time zones; external invitees require confirmation. The tool server is allow-listed, writes are logged, and credentials can be revoked immediately if an unusual call pattern appears.
FAQs
Does an AI agent inherit a user’s permissions?
It should not automatically inherit broad user access. Use a deliberate authorization model that limits the agent to the resources and actions required for the task.
Is MCP secure by default?
No protocol alone guarantees secure servers or safe permissions. Inventory servers, validate provenance, review tools and scopes, isolate execution, and monitor access.
Can prompt instructions prevent prompt injection?
They can help express intended behavior but are not a substitute for server-side authorization, input handling, sandboxing, and approval controls.
References & Sources
- NIST — Agent Security RFI Summary https://pages.nist.gov/nccoe-ai-identity/summary-of-comments.html
- OWASP — Top 10 for LLM Applications https://owasp.org/www-project-top-10-for-large-language-model-applications/
- NIST — Zero Trust Architecture, SP 800-207 https://csrc.nist.gov/pubs/sp/800/207/final