AI agents become useful when they can do more than generate text.
They can:
Read files
Query databases
Create tickets
Send emails
Call APIs
Modify repositories
Deploy applications
Execute workflows
That capability is also the security problem.
An agent that can access every available tool effectively becomes an identity with broad privileges.
The traditional approach is often:
User
↓
AI Agent
↓
All Available Tools
A safer architecture is:
User
↓
AI Agent
↓
Capability Policy
↓
Allowed Tools
↓
Allowed Operations
↓
Allowed Resources
This article explores how to implement that model for AI tool plugins using capability-based security.
The central principle is simple:
An AI agent should receive only the capabilities required for the current task.
This is closely aligned with current security guidance from OWASP and Microsoft, which recommends least-privilege tool access, scoped permissions, server-side authorization, and explicit controls for sensitive operations.
What Is Capability-Based Security?
Capability-based security represents authority as an explicit capability.
Instead of saying:
Agent = Administrator
we define:
Agent
├── read_orders
├── create_ticket
└── read_customer_profile
The agent does not automatically receive everything associated with an administrator role.
Its authority is the collection of capabilities explicitly granted to it.
A useful model is:
Capability
=
Action
+
Resource
+
Constraints
For example:
read_customer
+
customer/123
+
read-only
is significantly narrower than:
customer_database
+
full_access
Why AI Agents Need Fine-Grained Capabilities
Traditional applications usually have deterministic control flow.
For example:
if (user.CanDeleteOrder)
{
DeleteOrder(orderId);
}
An AI agent introduces another decision-maker:
User request
↓
LLM
↓
Tool selection
↓
Tool arguments
↓
Application
The model may choose:
Which tool?
Which parameters?
Which sequence?
How many times?
That makes tool authorization especially important.
OWASP recommends granting agents the minimum tools required for their specific task and implementing per-tool permission scoping, including distinctions such as read-only versus write operations.
Capability Security vs Role-Based Access Control
RBAC answers:
"What role does this identity have?"
Capability security answers:
"What exact authority has been granted?"
Both approaches can be useful.
| Model | Example | Granularity |
|---|---|---|
| RBAC | Agent = SupportAgent | Coarse |
| ABAC | Department = Support + Region = EU | Medium |
| Capability | Read ticket 123 | Fine |
| Resource capability | Read /reports/2026/q1 | Very fine |
In an AI system, capabilities can be derived from RBAC or ABAC policies.
The important point is that the final tool invocation should still be authorized server-side.
The Basic Architecture
A secure tool architecture can look like this:
User
|
v
AI Application
|
v
Agent/LLM
|
v
Capability Policy
|
+--------+--------+
| |
Allowed Denied
| |
v X
Tool Gateway
|
v
Tool Server
|
v
Resource
The model should not be the final authority.
The authorization layer should be.
Never Use the System Prompt as Authorization
A weak implementation might say:
You are a support agent.
Never delete customer records.
Only read customer information.
That is useful as behavioral guidance.
It is not authorization.
A prompt can be influenced by:
User input
Retrieved documents
Tool output
Web pages
Other agents
OWASP specifically recommends server-side enforcement because prompt instructions should not be relied upon to restrict tool access.
The secure architecture is:
LLM says:
"Call delete_customer"
↓
Authorization layer
↓
Does this agent have
delete_customer capability?
↓
NO
↓
Reject
Define Capabilities Explicitly
A capability can be represented as a strongly typed object.
For example, in C#:
public sealed record ToolCapability(
string Tool,
string Operation,
string Resource,
string Effect);
Then define:
var capabilities = new[]
{
new ToolCapability(
"customer",
"read",
"customer:*",
"allow")
};
This is only a starting point.
Production systems should normally use a structured authorization model rather than ad-hoc strings.
Add Constraints
A capability should be more specific than:
customer.read
Consider:
customer.read
region = EU
department = support
or:
order.update
orderId = 12345
fields = status
This creates a capability such as:
Update order status
for order 12345
rather than:
Update any order
Capability Object
A more detailed C# model could be:
public sealed record Capability(
string Tool,
string Action,
string ResourceType,
IReadOnlySet<string> AllowedResources,
DateTimeOffset ExpiresAt);
Example:
var capability = new Capability(
Tool: "orders",
Action: "read",
ResourceType: "order",
AllowedResources: new HashSet<string>
{
"order:12345",
"order:12346"
},
ExpiresAt: DateTimeOffset.UtcNow.AddMinutes(10));
Now the authorization decision can consider:
Tool
Action
Resource
Expiration
Use Deny by Default
The safest starting policy is:
No capability
↓
No operation
Not:
Everything allowed
↓
Try to block dangerous operations
OWASP's MCP security guidance explicitly recommends least privilege and deny-by-default authorization for agent/tool systems.
For example:
public bool IsAllowed(
Capability capability,
string tool,
string action,
string resource)
{
if (capability.ExpiresAt <= DateTimeOffset.UtcNow)
return false;
if (!string.Equals(
capability.Tool,
tool,
StringComparison.Ordinal))
return false;
if (!string.Equals(
capability.Action,
action,
StringComparison.Ordinal))
return false;
return capability.AllowedResources.Contains(resource);
}
The important behavior is:
Unknown
→ Deny
Expired
→ Deny
Wrong tool
→ Deny
Wrong action
→ Deny
Wrong resource
→ Deny
Separate Read and Write Capabilities
Do not combine:
customer.read
customer.write
customer.delete
into:
customer.full_access
Instead:
customer.read
customer.update
customer.delete
should be independent capabilities.
This allows:
Support Agent
↓
customer.read
while:
Customer Administrator
↓
customer.read
customer.update
and:
Privileged Workflow
↓
customer.delete
has a separate authorization path.
Separate Sensitive Tools
High-risk tools should not sit in the same unrestricted tool collection as ordinary read operations.
For example:
General Agent
├── search_documents
├── get_customer
└── get_order
Privileged Agent
├── refund_order
├── delete_customer
└── deploy_application
OWASP recommends separate tool sets for different trust levels and explicit authorization for sensitive operations.
Add Human Approval for High-Risk Capabilities
Some capabilities should require an additional control.
For example:
read_customer
↓
Automatic
update_customer
↓
Policy check
delete_customer
↓
Policy check
+
Human approval
Sensitive actions can include:
Delete
Refund
Transfer money
Send external email
Change permissions
Deploy production
Rotate credentials
The confirmation should happen outside the model's reasoning.
The user should see:
Action:
Delete customer
Resource:
Customer 12345
Reason:
Requested by current workflow
Approve?
[Yes] [No]
OWASP recommends explicit user confirmation for destructive, financial, and data-sharing operations.
Do Not Ask the LLM to Approve Its Own Action
This is unsafe:
Agent:
"Should I delete the customer?"
LLM:
"Yes."
Agent:
"Delete customer."
The same decision-maker is both requesting and approving the operation.
Instead:
Agent
↓
Authorization Service
↓
Human Approval
↓
Tool
Short-Lived Capabilities
Capabilities should normally have limited lifetimes.
For example:
ExpiresAt =
DateTimeOffset.UtcNow.AddMinutes(10);
This limits the impact of leaked or stale authority.
Microsoft's current guidance for least-privilege AI agents recommends scoped access and short-lived credentials, while OWASP's MCP guidance similarly recommends narrow scopes and ephemeral credentials where possible.
Avoid Permanent Agent Permissions
Avoid:
Agent A
↓
Permanent database.write
Prefer:
Task starts
↓
Capability issued
↓
Task executes
↓
Capability expires
This makes authority proportional to the task.
Bind Capabilities to an Identity
A capability should not be treated as an anonymous permission.
It should be associated with:
User
Agent
Application
Session/task
Tenant
For example:
public sealed record CapabilityContext(
string UserId,
string AgentId,
string TenantId,
string TaskId);
Then the authorization layer can evaluate:
Who?
Which agent?
Which tenant?
Which task?
Which capability?
Which resource?
Multi-Tenant AI Systems Need Tenant Boundaries
Consider:
Tenant A
↓
Agent A
↓
Customer data
Tenant B
↓
Agent B
↓
Customer data
A capability such as:
customer.read
is not sufficient.
It should be constrained by tenant:
customer.read
tenant = tenant-a
The authorization layer must never trust:
tenantId
because it came from the model.
The server should derive tenant identity from authenticated context.
Prevent Cross-Tenant Resource Access
An unsafe tool might accept:
{
"tenantId": "tenant-b",
"customerId": "123"
}
and trust both fields.
A safer implementation derives the tenant from the authenticated principal:
var tenantId =
userContext.TenantId;
var customer =
await repository.GetCustomerAsync(
tenantId,
customerId,
cancellationToken);
The agent supplies:
customerId
but not the authoritative tenant identity.
Capability-Based Tool Contracts
Tool schemas should also reflect authorization boundaries.
Instead of:
{
"name": "execute_sql",
"description": "Execute SQL against the database"
}
prefer domain-specific operations:
{
"name": "get_customer",
"description": "Read a customer record by ID"
}
The second tool has a much smaller capability surface.
OWASP recommends avoiding unrestricted tools such as arbitrary shell access and instead exposing narrowly scoped tools with explicit allowed operations and resources.
Avoid Generic execute_command
This is dangerous:
execute_command(command)
because the capability becomes:
Run arbitrary operating-system commands
A safer design might expose:
get_build_status
restart_test_service
read_deployment_logs
Each operation can have its own authorization policy.
Avoid Generic Database Tools
This:
execute_sql(sql)
creates a large capability.
Prefer:
get_customer
list_orders
get_order_status
If a specialized reporting workflow truly requires SQL, isolate it behind:
Read-only database
+
Restricted schema
+
Query validation
+
Timeout
+
Resource limits
Tool Authorization Middleware
Authorization should happen immediately before execution.
A simplified C# middleware might look like:
public async Task<ToolResult> ExecuteAsync(
ToolRequest request,
ToolContext context,
CancellationToken cancellationToken)
{
var decision =
await authorization.AuthorizeAsync(
context,
request,
cancellationToken);
if (!decision.Allowed)
{
return ToolResult.Denied(
decision.Reason);
}
return await toolExecutor.ExecuteAsync(
request,
cancellationToken);
}
The critical property is:
Authorization
↓
Tool execution
not:
LLM
↓
Tool execution
↓
Authorization later
Once the tool has executed, authorization is too late.
Authorization Must Be Server-Side
The client can send:
{
"tool": "refund_order",
"approved": true
}
That does not mean the request is authorized.
The server should determine:
Authenticated identity
+
Current policy
+
Capability
+
Resource
+
Action
and make its own decision.
OWASP identifies reliance on client-provided identity or authorization context as a major MCP authorization weakness.
Policy Decision Point
For larger systems, centralize authorization.
Agent
↓
Tool Gateway
↓
Policy Decision Point
↓
Allow / Deny
↓
Tool
Join the conversation! Your thoughts help the community grow.