Apache Casbin Whitepaper: Zero Trust Authorization for AI Agents
A framework for deciding what autonomous AI agents are allowed to do. Apache Casbin (Incubating), December 2026. Download the PDF
Authorization is where agent risk is decided
Organizations are moving AI agents from pilots into production. Agents now answer customers, change code, file tickets, query databases, move money and delegate work to other agents. Each of those actions is a request to some system, and each request has to be allowed or refused by something. That something is authorization.
For human users, authorization grew up around a comfortable assumption: the person making a request meant to make it. Agents remove that assumption. An agent decides at run time which tools to call and with which arguments, and the text that shapes its decision can come from anyone: the user, a web page, an email, a shared document, the output of another tool, or another agent. A model can be wrong without any attacker involved, and it can be steered by an attacker who never touches your network. The agent does not need to break any control to cause harm. It only needs to use the access it was given.
That is why the question security leaders should ask about an agent deployment is not "is the model safe?" but "what can this agent do, for whom, and who decided?" If the honest answer is "whatever its service account can do", the deployment has a blast radius equal to that service account, and every prompt injection, every confused delegation and every wrong guess by the model is measured against it.
This paper applies Zero Trust to that question. It is written for two audiences. Security and risk leaders should read the principles and Parts I and II, which describe what is different about agents and the threats that follow. Architects and engineers should continue with Parts III to V, which give a tiered capability framework, an implementation workflow and operating practices. Throughout, short notes explain how Apache Casbin, an open-source authorization library used in Go, Java, Node.js, Python, .NET, Rust, C++, PHP and other languages, supports each capability. The framework itself does not depend on Casbin; any policy engine that can meet the requirements will do.
This paper reflects the current thinking of the Apache Casbin community. It is offered as a framework for your own evaluation, not as legal, compliance or security assurance for any particular environment.
The principles behind Zero Trust authorization
Zero Trust replaces trust based on location with trust based on verification. NIST SP 800-207, Zero Trust Architecture (2020), describes it as a set of principles in which no request is trusted because of where it comes from, every access to a resource is decided per request by a policy decision point and enforced by a policy enforcement point, and access is granted with the least privilege needed. Applied to agents, those principles become four rules for authorization.
Verify every action, not every session. A login, a connected app or an OAuth consent is not a permission to do anything for the rest of the session. Each tool call, each data retrieval and each delegation is a separate request that is authorized when it is made, with the context available at that moment.
Assume the model is compromised. Design as if the model is already following an attacker's instructions, because with prompt injection it sometimes is. Controls that rely on the model's good behavior, such as instructions in a system prompt, are guidance, not enforcement. Enforcement happens outside the model, in code the model cannot rewrite.
Grant least agency. OWASP uses least agency to extend least privilege to agents: not only which systems an agent can reach, but which actions, with which arguments, how often, and for how long. An agent that summarizes email does not need to send it. An agent that refunds orders does not need to refund every amount.
Narrow, never widen. Every step in a chain of delegation, every task boundary and every piece of untrusted input can only take permissions away. An agent never holds more authority than the person it acts for, and a sub-agent never holds more than the agent that started it.
A design test: would this decision hold if the model worked for the attacker?
When you evaluate an authorization control in this paper, ask one question: if the model were actively working for an attacker, would this control still stop the action? A refund limit enforced by the payment service passes. A sentence in the system prompt saying "never refund more than 500" fails. A tool hidden from the model's tool list but still callable through the API fails. An approval request whose description was written by the agent fails, because the agent can describe a harmful action as a harmless one.
Controls that pass the test share a shape: the decision is made by deterministic code, from facts the model cannot forge (the authenticated identities, the canonical form of the requested action, the policy), at the point where the action is executed. When in doubt, prefer a control that removes a capability over one that asks the model not to use it.
Part I: Why agents break authorization assumptions
Traditional applications run predefined logic. When a user clicks Delete, the application knows what the user asked for and the authorization question is narrow: may this user delete this record? Agentic systems change five things about that question.
The intent gap. The caller is a model choosing actions to achieve a goal. It can choose the wrong record, the wrong recipient or the wrong amount with complete confidence. The request no longer proves what the user wanted.
The instruction gap. Agents read untrusted content as part of their work: tickets, emails, web pages, code comments, tool results. Any of it can contain text written as an instruction. Current models cannot reliably tell information from instructions, so the content an agent reads can decide what it does.
The delegation gap. An agent acts for someone, often through other agents. A user starts an orchestrator, which starts a coding agent, which calls a deployment agent, which calls a tool server. If each hop simply passes on its full authority, the permissions at the end of the chain are the union of everyone's, not the intersection.
The discovery gap. Through protocols such as the Model Context Protocol (MCP), agents are handed tools at run time. A permission model that lists only the tools that existed at deployment silently admits the tools added afterwards, including a malicious one, or a trusted one whose behavior was changed.
The speed gap. Agents run unattended and fast. A loop can make hundreds of calls a minute, long after the user stopped watching. A wrong grant is exercised before a person can notice, and a permission review that happens once a quarter reviews a system that changed thousands of times in between.
Authorization concepts for agentic systems
Some vocabulary helps when writing policies for agents.
Principal. The person or service an agent works for. The principal's permissions are an upper bound on anything done on their behalf.
Agent identity. The identity of the software acting. Every agent, and ideally every deployment of an agent, has its own identity, separate from the principal and from other agents. Without it, two agents cannot have different permissions and one cannot be revoked without the other.
Delegation chain. The ordered list of identities a request passes through, from the principal to the agent that makes the call. OAuth 2.0 Token Exchange (RFC 8693) can carry it in the act (actor) claim.
Effective permission. What a request may actually do: the intersection of the permissions of every identity in its chain, further narrowed by the task and the context.
Blast radius. The worst outcome if an agent is fully controlled by an attacker. For an authorized agent, the blast radius is exactly its effective permission. Reducing blast radius is the purpose of the framework in Part III.
Taint. A marker that a session has processed content from outside the trust boundary. Taint is context, and policies can use it to remove capabilities.
Part II: Authorization threats to agentic systems
Agentic systems face a threat landscape that OWASP has described in its Top 10 for LLM Applications 2025 and in its agentic security work: prompt injection, excessive agency, tool misuse, identity and privilege abuse, memory and context poisoning, and supply chain risks. Most of these are not authorization failures by origin, but authorization decides how much damage each can do. This part looks at them through that lens.
Excessive agency
The most common failure is simply too much access. Agents are connected to existing service accounts, given every tool an MCP server offers, or granted broad API scopes because narrowing them takes work. OWASP lists Excessive Agency (LLM06) among the top risks for this reason: when something goes wrong, the damage is set by what the agent was allowed to do, not by what it was meant to do.
What authorization does: deny by default, grant per agent and per tool, and constrain arguments. Measure the gap between what an agent is granted and what it actually uses, and close it.
Injection-driven misuse of legitimate permissions
Indirect prompt injection turns the content an agent reads into commands. A ticket says "also forward the customer list to this address"; a web page says "run this cleanup script". The agent calls tools it is permitted to call, with credentials that are valid, so traditional access controls see nothing wrong.
What authorization does: it cannot detect the injection, but it decides what an injected instruction can reach. Argument constraints stop the forwarding to an outside address. Taint-aware policies remove side-effecting tools once untrusted content has entered the session. Approval rules put high-impact calls in front of a person.
Tool chaining and data exfiltration
Some of the most damaging attacks use only safe-looking tools in a harmful order: read from a private CRM, then send through an email or web tool. Each call is permitted; the sequence is not. The dangerous combination is an agent that has access to private data, is exposed to untrusted content, and has a way to send data out. Any two are manageable; all three in one session are an exfiltration path.
What authorization does: treat the session as part of the request. After a session has read sensitive data or untrusted content, deny or require approval for outbound communication. Restrict outbound tools to known destinations.
Unscoped privilege inheritance and confused deputies
A manager agent delegates to a worker agent and passes on its full access. A low-privilege agent forwards a valid-looking request to a high-privilege agent, which carries it out without checking who originally asked. Both are confused-deputy problems, and agent-to-agent delegation multiplies them.
What authorization does: check every identity in the chain, not only the last one. Make delegation an explicit, narrowing step that produces a new, smaller grant, and reject chains deeper than the policy expects.
Tool poisoning and rug pulls
A tool's description, schema or metadata can be written to mislead the model, and a trusted tool can be replaced by a malicious version after it was approved. If permissions are granted by tool name and every new or changed tool is available by default, the poisoned tool inherits trust it never earned.
What authorization does: new tools are denied until granted; tools are grouped by the effect they have (read, write, send, execute, delete), not by what they claim; and the grant is reviewed again when a tool's definition changes.
Cross-user and cross-tenant data exposure
Retrieval-augmented generation puts documents into the model's context. If retrieval is not filtered by the principal's permissions, the model can quote a document the user was never allowed to read, and output filtering is too late to stop it. Shared indexes and shared memory across tenants make this worse. OWASP lists Sensitive Information Disclosure (LLM02) and Vector and Embedding Weaknesses (LLM08) for these reasons.
What authorization does: filter retrieval by the principal's permissions before results reach the model, and partition indexes, memory and caches by tenant.
Standing privileges and long-lived grants
Permissions granted to an agent "for now" tend to stay. Agents accumulate access for tasks they finished long ago, and every one of those grants is available to the next attacker who steers the agent.
What authorization does: tie grants to tasks and time, expire them automatically, and review unused permissions.
Policy tampering and approval manipulation
When the policy lives in configuration the agent can edit, or approvals are requested through a channel the agent controls, the controls can be turned off by the thing they are meant to control. An approval prompt that shows the agent's own summary of the action can be made to look harmless.
What authorization does: keep policies outside the agent's write access, version and review them like code, and show approvers the canonical action, not the agent's description of it.
Chasing each threat separately keeps defenders reactive. The next part organizes the controls into a framework that addresses all of them.
Part III: A Zero Trust authorization framework for agents
The framework has ten capability areas. Each is described at three tiers, and each tier builds on the one before it.
- Essential is the minimum for any agent that can change data or reach systems outside its own sandbox. For small teams and low-risk deployments it may be enough.
- Managed is the target for most organizations: several agents in production, agents acting for many users, or any deployment where a single compromise has business impact.
- Adaptive is for regulated industries, sensitive data, financial or infrastructure actions, and environments where the threat model includes capable adversaries. Expect today's Adaptive controls to become tomorrow's Managed controls as tooling matures.
1. Agent identity in authorization decisions
Authorization can only be as precise as the identities it sees. If every agent runs under one service account, no policy can tell them apart.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | A distinct identity for every agent | Register each agent as its own client in your identity provider. Never let agents share credentials with each other or with people. Include the agent identity in every request and every log line. |
| Managed | Principal and agent in every request | Issue tokens that name both the principal (sub) and the agent (client_id or an agent claim). Authorize on both. Reject requests where either is missing. |
| Adaptive | Full delegation chain, cryptographically bound | Carry the chain in the token (RFC 8693 act). Bind tokens to the agent's key or workload identity so a stolen token cannot be replayed elsewhere. Authorize on every identity in the chain. |
Casbin does not authenticate. It authorizes the identities your identity provider has established, so the subject of a request can be an agent, a person or any identity in a chain. Agents get their own roles with g rules, independent of the roles of the people they serve, and a request can carry the principal, the agent and the context together.
2. Permission model
The permission model determines how precise decisions can be.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Role-based access control with deny by default | Define a role per agent function. Grant each role only the tools it needs. Anything not granted is denied, including tools added later. |
| Managed | Attribute-based policies with context | Add attributes to decisions: the principal's permissions, the tenant, data sensitivity, time, and whether the session is tainted. Write guardrails that apply to all agents as deny rules that override grants. |
| Adaptive | Continuous per-action authorization with risk signals | Evaluate every action at the moment it is taken, with current risk signals (anomaly scores, threat intelligence, incident state). A change in risk takes effect on the next call, not at the next login. |
Casbin describes the permission model in a small configuration file, so RBAC, ABAC, RBAC with domains (tenants), ReBAC and priority or deny-override effects can be combined in one model and changed without changing code. With the default allow effect, a request no rule matches is denied. Conditions in rules are evaluated against the attributes of each request, and custom functions can bring in external signals. Because the enforcer runs in-process and decides typical requests in microseconds, checking every single action is practical.
3. Delegation and acting on behalf of users
The question for every agent action is not only "may this agent do this?" but also "may the person it acts for do this?"
| Tier | Capability | Implementation |
|---|---|---|
| Essential | The agent never exceeds its principal | Check each action twice: once for the agent and once for the principal. Allow it only if both checks pass. |
| Managed | Narrowing delegation between agents | When an agent delegates to another, check the action for every identity in the chain. Sub-agents receive grants that are equal to or smaller than their parent's, never larger. |
| Adaptive | Bounded, auditable chains | Limit delegation depth. Record the full chain in each decision log. Require explicit policy for any agent that may delegate at all. |
The effective permission of a chain is the intersection of its members' permissions, which is a loop of enforce calls over the chain with the same model and policy. A denial names the identity that refused, which is what an investigator needs to know.
4. Privilege scoping over time
Static permissions granted at deployment remain active indefinitely. Scoping in time limits both the blast radius and the window in which it can be reached.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Static least-privilege roles, reviewed | Define each agent's role at deployment. Review grants on a fixed schedule and remove the ones that are not used. |
| Managed | Task-scoped grants | Grant permissions to a task ("release 1.4", "ticket T-42") rather than to the agent. The agent holds them only while it works on that task. Log every grant and removal. |
| Adaptive | Just-in-time access with automatic expiry | Grant access at the moment of need, scoped to specific resources and a short duration, and revoke it automatically when the task ends or the time runs out. No standing privileges remain to be stolen. |
Casbin's conditional role manager attaches conditions to role assignments, for example a validity window, so an agent's membership in a task role ends on its own. Policies can also be added and removed at run time through the management API, so task grants can be created when work starts and deleted when it ends.
5. Tool and argument authorization
Tool names say little about risk. email.send to a colleague and email.send to an unknown domain are different actions; so are a refund of 20 and a refund of 20,000.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Tool allowlists enforced outside the model | Keep an explicit list of permitted tools per agent. Enforce it where the tool is executed, not only in the list offered to the model. Deny unknown tools. |
| Managed | Argument constraints on canonical values | Parse and canonicalize arguments before the check: resolve paths, extract hosts from URLs, normalize amounts and currencies, and map tool aliases to one name. Constrain amounts, recipients, paths, repositories, branches and tenants in policy. |
| Adaptive | Effect-based and taint-aware policies | Group tools by their effect (read, write, send, execute, delete) and write policy about effects, so a new tool with the same effect is covered. Remove side-effecting tools after untrusted input. Re-review grants when a tool's definition changes. |
Rules can match tool names with patterns such as tickets.* or *.delete, group tools by effect with a second role hierarchy, and carry conditions on arguments and context. With a deny-override effect, a guardrail such as "no agent may run shell commands" cannot be undone by a grant written later. The same policy can filter the tool list offered to the model and decide each call. Apache Casbin Gateway, the project's gateway for AI coding agents, applies this design to agents such as coding assistants: its permission settings compile to a Casbin policy, and disallowed tools are removed from requests before they reach the model provider.
6. Data authorization for retrieval and memory
What the model reads is as important as what it does. A document in the context window can be quoted, summarized or sent out.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Separate indexes or collections per audience | Keep data for different audiences in separate collections and give agents access only to the collections their principals may read. Never share memory between users. |
| Managed | Per-document filtering at retrieval time | Filter search results by the principal's permissions before they reach the model: restrict the query to what the user may read, then check each result. Keep the authorization label with every chunk when indexing. |
| Adaptive | Labels that follow the data | Propagate sensitivity labels from sources into derived data (summaries, memories, embeddings). Deny writing sensitive context into shared or long-lived memory. Expire memories derived from untrusted sources. |
Casbin can check a whole page of results in one call with batch enforcement, and can list what a user may read through their implicit permissions, which can be turned into a metadata filter for the vector store query. The project's list filtering guide describes these patterns and their trade-offs.
7. Human approval for high-impact actions
Some actions are acceptable with a person's consent and unacceptable without it. Approval is a third outcome of authorization, alongside allow and deny.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | A fixed list of actions that require approval | Identify the actions that always need a person (payments, deletions, external communication, production changes) and pause them for review. Log every approval decision. |
| Managed | Policy-driven approval thresholds | Express approval conditions in policy (amounts, recipients, data sensitivity) so thresholds change without a release. Send approvals through a channel the agent cannot write to, and show the canonical action, not the agent's description. |
| Adaptive | Risk-adaptive, verifiable approval | Require approval when risk is high (tainted session, unusual pattern) and skip it for routine actions. Bind the approval to the exact action, for example with OAuth Rich Authorization Requests (RFC 9396) or a signed approval, so an approval cannot be reused for a different call. |
Approval conditions can be written as ordinary rules for a reserved subject, so the same engine that allows and denies also says when to ask. The approval workflow itself, the notification and the record of who approved, belongs to your application or identity provider; Casbin decides when it is needed.
8. Policy lifecycle and integrity
An authorization policy is security-critical code. If an agent, or the person steering it, can change the policy, every other control is optional.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Policies in version control | Store the model and policies in version control. Require review for changes. Keep policies out of any location an agent can write to. |
| Managed | Tested policies with separation of duties | Keep a suite of requests with expected decisions, including attack cases, and run it in CI on every policy change. The people who build an agent are not the only ones who approve its permissions. |
| Adaptive | Continuous policy analysis | Compare granted permissions with permissions actually used and propose removals. Detect drift between the reviewed policy and the policy in production. Sign policy releases and verify them before loading. |
Casbin separates the model, a small text file, from the policy, which can live in files or, through adapters, in MySQL, PostgreSQL, MongoDB, Redis and many other stores. Both can be reviewed and tested like code: a policy test is a list of requests and expected results. The online editor lets reviewers try rules interactively before they are merged.
9. Decision logging and explainability
You cannot investigate an incident, show compliance or improve a policy without a record of what was decided and why.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Log every authorization decision | For each decision, log the principal, the agent, the action, the canonical arguments, the decision and a request ID that links it to the triggering user request. |
| Managed | Explained decisions across the chain | Record which rule allowed or denied each request, the full delegation chain, and who approved approval-gated actions. Make logs append-only. |
| Adaptive | Real-time decision telemetry | Stream decisions to your SIEM. Alert on spikes in denials, on approval requests from tainted sessions, and on first use of a permission. Support replaying a decision with the policy that was in force at the time. |
The explain variant of enforce returns the rule that decided a request, ready to be logged next to it. Casbin's logging can record requests and policy changes through a pluggable logger, and loggers are available for OpenTelemetry and Prometheus.
10. Revocation and response
When an agent misbehaves, the fastest effective response is to take its permissions away.
| Tier | Capability | Implementation |
|---|---|---|
| Essential | Revocation that takes effect immediately | Be able to remove an agent's permissions, or disable the agent, in one step that applies to the next request everywhere. Document who may do it. |
| Managed | Propagation across every enforcement point | Synchronize policy changes to every process that authorizes agents within seconds. Test the time from revocation to effect. |
| Adaptive | Automatic privilege reduction | When monitoring flags an agent, automatically move it to a reduced role (read-only, or approval for everything) while people investigate. Restore only by human decision. |
Policy changes made through the management API apply to the next enforce call. Watchers propagate changes between processes and servers, so a revocation in one place reaches every enforcer. Moving an agent to a restricted role is a single role-assignment change.
Part IV: Agent authorization implementation workflow
Strong authorization comes from a repeatable process, not from one-time configuration. The seven phases below take an agent from idea to production and keep it safe there.
Phase 1: Inventory agents, principals and tools
List every agent in use or planned, including agents employees adopted on their own. For each, record whom it acts for, which tools and data sources it is connected to, and which credentials it uses. Unknown agents are the largest gap in most programs, because no control in this paper applies to them.
Phase 2: Define each agent's boundaries in writing
For every agent, write down:
- Permitted actions, as specific as possible: "read tickets, read orders, refund up to 500 per order", not "help with customer service".
- Prohibited actions that must never happen, whatever else is granted: shell commands, deletions, sending data outside the organization.
- Escalation triggers: the actions that need a person's approval, with thresholds.
- Scope: the tenants, repositories, data sets and environments the agent may touch.
Then estimate the blast radius: assume the agent is fully controlled by an attacker and ask what it could do with exactly these permissions. Apply the design test. If the answer is unacceptable, narrow the boundaries before going further. Consider splitting a broad agent into several narrow ones, each with its own identity and credentials; splitting the work but sharing the credentials gains nothing.
Phase 3: Choose the enforcement points
Decide where each decision is enforced. There are usually several layers, and the important rule is that at least one of them is outside the agent's control:
| Enforcement point | Good for | Limitation |
|---|---|---|
| Agent runtime, around the tool-calling loop | Agents you build; full context such as task and taint is available | Covers only agents that use this runtime |
| Tool or MCP server | Tools shared by many agents; the server owns its resources | Needs the agent and the principal from a token issued for it |
| Gateway between agents and models or tools | Agents you did not build, such as coding assistants | Sees only what passes through it |
| Downstream API or database | The last line of defense for the data itself | Often sees only the principal unless tokens carry the actor |
Phase 4: Express the boundaries as policy
Translate the written boundaries into policy, one rule per statement where possible, so reviewers can check one against the other. Use deny rules for prohibited actions, conditions for limits, approval rules for escalation triggers, and task-scoped roles for temporary access. Keep the policy small enough that a person can read all of it.
Phase 5: Test the policy like code
Build a table of requests and the decisions you expect, and run it automatically. Include the attacks you care about: an injected refund, a message to an outside domain, a shell call through a renamed tool, a request for another tenant, a sub-agent asking for more than its parent. Every incident and every near miss becomes a new test case.
Phase 6: Deploy, synchronize and log
Load policies from a store outside the agent's reach, synchronize them to every enforcement point, and fail closed if a policy cannot be loaded or a condition cannot be evaluated. Turn on decision logging from the first day, with the matched rule and the delegation chain.
Phase 7: Review and tighten continuously
Compare what each agent was granted with what it actually used, and remove the difference. Review grants when an agent's purpose changes, when a tool is added or its definition changes, and after every incident. Treat a permission that has not been used for months as a liability.
Part V: Operating authorization at the speed of agents
Securing agents at deployment is half the work. The other half is operating authorization fast enough for systems that act in seconds and change daily.
Treat decisions as security telemetry
Authorization decisions are among the most informative signals an agent produces. A sudden rise in denials for one agent often means it is being steered somewhere it should not go. An approval request from a tainted session deserves more scrutiny than one from a clean session. The first use of a permission that an agent has held for months is worth a look. Feed decision logs into the same monitoring as the rest of your security data, and correlate them with the agent's other activity.
Measure what matters
A few metrics show whether authorization is working:
- Coverage: the share of agent actions that pass through an enforcement point. Anything below 100% is an unmanaged path.
- Standing privilege: the number of permissions held by agents outside an active task. It should trend toward zero.
- Granted versus used: permissions granted but not used in the review period. Each is a candidate for removal.
- Time to revoke: from the decision to revoke to the moment the next request is refused, everywhere. Measure it in seconds.
- Approval health: approval rates and response times. If people approve nearly everything, the threshold is too low or the requests are not informative, and approval has become friction rather than control.
Prepare the response before the incident
Decide in advance who may disable an agent or strip its permissions, how quickly, and on what evidence. Rehearse it. A tabletop exercise should include an agent being steered by injected content, an agent whose tool was replaced, and an agent that delegated its full authority to a sub-agent. In each case, the question is how long it takes from first signal to the moment the agent can no longer act, and whether the logs can show what it did before that.
Apply the same rules to defensive agents
Security teams increasingly use agents for triage and response. Those agents often hold powerful permissions: they can disable accounts, change firewall rules and revoke credentials. Govern them with the same framework: their own identities, least agency, approval for high-impact actions, and full decision logs. A compromised defensive agent is one of the most valuable footholds an attacker can get.
Alignment with standards and regulation
| Framework | How this paper relates |
|---|---|
| NIST SP 800-207, Zero Trust Architecture | The policy engine (Casbin) and the enforcement points of Part IV map to the policy decision point and policy enforcement points of the NIST architecture. |
| OWASP Top 10 for LLM Applications 2025 | Addresses LLM06 Excessive Agency directly; limits the impact of LLM01 Prompt Injection; mitigates LLM02 Sensitive Information Disclosure and LLM08 Vector and Embedding Weaknesses through retrieval authorization. |
| MCP authorization specification | MCP servers are OAuth 2.1 resource servers. Tokens identify the client (the agent) and the user, which supplies the identities this framework authorizes. |
| OAuth 2.0 Token Exchange (RFC 8693), Rich Authorization Requests (RFC 9396) | Carry delegation chains and exact action details into tokens and approvals. |
| EU AI Act | Human oversight obligations for high-risk AI systems are supported by policy-driven approval and complete decision records. |
From principles to practice
Agents introduce a new kind of caller: one that decides for itself, reads instructions from anywhere, acts for others and runs at machine speed. Zero Trust does not need to be reinvented for it. It needs to be applied at the right place, which is the authorization of every action an agent takes.
Verify every action, not every session. Assume the model may be working for someone else. Grant least agency, and let every delegation, task and piece of untrusted input narrow it further. Log every decision with its reason, and be able to take any permission away in seconds.
For security leaders: ask of every agent deployment what it can do, for whom, and who decided. If those answers are not written down and enforced outside the model, the deployment's risk is unknown. Start with an inventory and with Essential-tier controls everywhere, and set Managed as the target for anything in production.
For architects and engineers: put an enforcement point on the path of every action, authorize both the agent and the principal, canonicalize before you check, and test the policy like code. Use the design test as a standing review question: if the model worked for the attacker, would this decision still hold?
Apache Casbin is open source under the Apache License 2.0. To try the patterns in this paper, start with the hands-on guide Authorization for AI Agents and MCP Tools, and join the community on GitHub and Discord.
Appendix: A reference policy
The policy below implements several capabilities from Part III in one Casbin model: per-agent roles with deny by default, argument constraints, deny-override guardrails, effect-based tool groups, taint-aware restrictions and policy-driven approval. It was run with the Python implementation of Casbin and produced the decisions in the table. The hands-on guide shows how to wire a model like this into an agent loop and an MCP server.
[request_definition]
r = sub, tool, args, ctx
[policy_definition]
p = sub, tool, cond, eft
[role_definition]
g = _, _
g2 = _, _
[policy_effect]
e = some(where (p.eft == allow)) && !some(where (p.eft == deny))
[matchers]
m = g(r.sub, p.sub) && (globMatch(r.tool, p.tool) || g2(r.tool, p.tool)) && (p.cond == '' || eval(p.cond))
p, support-agent, tickets.*, , allow
p, support-agent, orders.read, , allow
p, support-agent, orders.refund, r.args.amount <= 500, allow
p, support-agent, email.send, r.args.to_domain == 'example.com', allow
p, any-agent, shell.*, , deny
p, any-agent, *.delete, , deny
p, any-agent, side-effect, r.ctx.untrusted_input, deny
p, support-staff, tickets.*, , allow
p, support-staff, orders.*, , allow
p, support-staff, email.send, , allow
p, approval-required, orders.refund, r.args.amount > 100, allow
p, approval-required, email.send, , allow
g, support-agent, any-agent
g, alice, support-staff
g2, orders.refund, side-effect
g2, email.send, side-effect
An action is checked for every identity in the chain (here alice, then her support agent); if all allow it, the approval-required rules decide whether a person must confirm it.
| Action by alice's support agent | Untrusted input in session | Decision |
|---|---|---|
tickets.read | no | allow |
orders.refund, amount 80 | no | allow |
orders.refund, amount 240 | no | approval required |
orders.refund, amount 900 | no | deny: exceeds the agent's limit |
orders.refund, amount 80 | yes | deny: side effects after untrusted input |
email.send to example.com | no | approval required |
email.send to attacker.test | no | deny: outside domain |
shell.exec | no | deny: no one granted it |
tickets.read | yes | allow |
References
- NIST, SP 800-207: Zero Trust Architecture, 2020.
- OWASP, Top 10 for LLM Applications 2025.
- Model Context Protocol, Authorization specification.
- M. Jones et al., RFC 8693: OAuth 2.0 Token Exchange, 2020.
- T. Lodderstedt et al., RFC 9396: OAuth 2.0 Rich Authorization Requests, 2023.
- N. Hardy, "The Confused Deputy (or why capabilities might have been invented)", ACM SIGOPS Operating Systems Review, 1988.
- Apache Casbin documentation: How it works, ABAC, RBAC with domains, RBAC with conditions, List filtering, Watchers, Logging.
Comments are powered by giscus and GitHub Discussions. They load from giscus.app and GitHub only after you click the button below.