Tool Permissions, Approvals and Abuse Risks
Assume the model may one day ask for the wrong thing. Permissions decide how much that matters.
Give each agent only the tools and data its task needs, and never more than the person it acts for. Decide permissions in code on every call, including access to the specific record. Require approval for high-impact actions and bind it to the exact action. Restrict where tools can send data and what addresses they can fetch, because a manipulated agent will use whatever it is allowed to use.
What you will learn: risk-ranking tools, least privilege and identity, deny-by-default policy, approval design, tool abuse and exfiltration paths, and protecting fetch tools.
Prerequisites: Agent Tools, Function Calling and Tool Registries and Designing Tool Schemas and Contracts.
Why permissions matter more for agents
Conventional software does what its code says. An agent chooses actions from text, including text written by strangers that it reads along the way. You cannot rely on instructions alone to prevent misuse. The OWASP Top 10 for Agentic Applications, published in December 2025, lists tool misuse among its main risks, covering cases where agents use legitimate tools in harmful ways.
Read, write and beyond
| Class | Examples | Minimum control |
|---|---|---|
| Read public | Search published help | Rate limit, log |
| Read private | Customer record, internal file | User identity, record check, minimal fields |
| Write reversible | Draft, label, internal note | Scope, validation, undo |
| Write consequential | Payment, deletion, account change | Limits, approval, idempotency |
| Communicate outward | Email, post, webhook | Recipient rules, preview, approval |
| Execute | Code, shell, query language | Sandbox, no secrets, restricted network |
"Read only" is not the same as "safe". A read tool can expose private data, and a request to a web address can carry information out in the address itself.
Applying least privilege
- Expose few tools, chosen for the task or workflow stage.
- Split read and write tools so they can be granted separately.
- Scope credentials narrowly, per tool, with short lifetimes.
- Keep credentials out of the model's context. Trusted code attaches them.
- Limit amount, count and target: maximum refund, daily number of messages, approved domains.
- Remove unused access after reviewing logs.
Whose authority is it?
An agent has its own identity, and often acts for a user. The effective permission should be the overlap of both, further narrowed by the task. If the agent holds a powerful service account and checks nothing about the user, anyone who can talk to it borrows that power. This is the classic confused deputy problem.
"""Deny by default; an agent never gets more than the user it acts for."""
USERS = {"maya": {"scopes": {"orders:read", "refunds:create"},
"region": "east"}}
AGENTS = {"support-bot": {"orders:read", "refunds:create", "orders:delete"},
"report-bot": {"orders:read"}}
ORDERS = {"A1001": {"region": "east"}, "A2002": {"region": "west"}}
TOOLS = {"get_order": "orders:read", "refund": "refunds:create",
"delete_order": "orders:delete"}
APPROVAL_ABOVE = 100
def decide(user, agent, tool, order, amount=0):
need = TOOLS.get(tool)
if need is None:
return "deny", "unknown tool"
if need not in AGENTS.get(agent, set()):
return "deny", "agent lacks scope"
if need not in USERS.get(user, {}).get("scopes", set()):
return "deny", "user lacks scope"
record = ORDERS.get(order)
if record is None or record["region"] != USERS[user]["region"]:
return "deny", "record not accessible"
if tool == "refund":
if amount <= 0:
return "deny", "amount must be positive"
if amount > APPROVAL_ABOVE:
return "approve", "needs a second person"
return "allow", "within limits"
cases = [("maya", "support-bot", "get_order", "A1001", 0),
("maya", "report-bot", "refund", "A1001", 20),
("maya", "support-bot", "delete_order", "A1001", 0),
("maya", "support-bot", "get_order", "A2002", 0),
("maya", "support-bot", "refund", "A1001", 40),
("maya", "support-bot", "refund", "A1001", 400),
("maya", "support-bot", "run_shell", "A1001", 0)]
for case in cases:
verdict, why = decide(*case)
_, agent, tool, order, amount = case
print(f"{agent:<12}{tool:<13}{order} {amount:>4} {verdict:<8}{why}")
Output:
support-bot get_order A1001 0 allow within limits
report-bot refund A1001 20 deny agent lacks scope
support-bot delete_order A1001 0 deny user lacks scope
support-bot get_order A2002 0 deny record not accessible
support-bot refund A1001 40 allow within limits
support-bot refund A1001 400 approve needs a second person
support-bot run_shell A1001 0 deny unknown tool
The reporting agent cannot refund even though the user could. The support agent holds a delete scope that the user lacks, so deletion is refused. A record in another region is denied despite the right scope. Large refunds go to a second person, and a tool that is not registered is rejected. All of this happens in code that the model cannot argue with. A real system would take identities from verified tokens and rules from a policy engine; see Action Guardrails and Policy Engines and Agent Identity, Authorization and Secrets.
Approvals that mean something
An approval is useful only if the person understands what they are approving and exactly that is what happens.
| Property | Question |
|---|---|
| Specific | Does it show tool, target, amount and key content? |
| Bound | Does any change invalidate it? |
| Independent | Is the approver different from the requester where required? |
| Fresh | Does it expire, and is the data rechecked? |
| Single use | Can it be replayed? |
| Recorded | Who approved what, when, based on which evidence? |
"""An approval covers one exact action, once, for a limited time."""
import hashlib
import hmac
import json
KEY = b"demo-key-kept-by-the-approval-service"
used = set()
def fingerprint(action, approver, expires):
text = json.dumps([action, approver, expires], sort_keys=True)
return hmac.new(KEY, text.encode(), hashlib.sha256).hexdigest()
def approve(action, requester, approver, now, ttl=600):
if requester == approver:
raise PermissionError("requester cannot approve their own action")
expires = now + ttl
return {"approver": approver, "expires": expires,
"mac": fingerprint(action, approver, expires)}
def execute(action, grant, now):
good = fingerprint(action, grant["approver"], grant["expires"])
if not hmac.compare_digest(good, grant["mac"]):
return "refused: action differs from what was approved"
if now > grant["expires"]:
return "refused: approval expired"
if grant["mac"] in used:
return "refused: approval already used"
used.add(grant["mac"])
return f"paid {action['amount']} to {action['payee']}"
action = {"tool": "pay", "payee": "acme", "amount": 400}
grant = approve(action, requester="bot", approver="li", now=1000)
print(execute({**action, "amount": 4000}, grant, now=1010))
print(execute({**action, "payee": "evil"}, grant, now=1020))
print(execute(action, grant, now=1030))
print(execute(action, grant, now=1040))
later = approve(action, "bot", "li", now=2000)
print(execute(action, later, now=2601))
try:
approve(action, "li", "li", now=3000)
except PermissionError as error:
print("refused:", error)
Output:
refused: action differs from what was approved
refused: action differs from what was approved
paid 400 to acme
refused: approval already used
refused: approval expired
refused: requester cannot approve their own action
Changing the amount or the payee broke the signature. The approved action ran once and could not be replayed, an old approval expired, and self-approval was refused. This demonstration keeps used approvals in memory and a key in the file. In production, the approval service holds the key, authenticates the approver and records use in durable storage with an atomic update, so that two workers cannot spend one approval.
Avoid approval fatigue
People who confirm dozens of routine prompts stop reading them. Ask less often and more meaningfully: allow low-risk actions within limits, batch similar items with the exceptions highlighted, and reserve interruption for real consequences. Track approval rate and decision time. Near-total approval within a second or two suggests that the step is no longer a control. Human-in-the-Loop and Approval Gates covers the workflow.
Delegation and background work
Permissions become harder when the user is no longer present. A scheduled agent, or one resuming after an approval, must not rely on a long-lived copy of the user's password or an unlimited token.
| Situation | Sound approach |
|---|---|
| Interactive request | Short-lived token tied to the user and the session |
| Long task | Delegation limited to named actions, with an expiry, renewed under policy |
| Scheduled job | The job's own identity with narrow rights and a named human owner |
| Agent calling another agent | Pass on equal or smaller authority, never more |
| User leaves or changes role | Check current rights at execution time and cancel pending work |
OAuth token exchange, defined in RFC 8693, is one standard way for a service to obtain a narrower token that records on whose behalf it acts, where your identity provider supports it. Whatever the mechanism, log both the agent and the person for every action, so that an investigator does not have to guess which was responsible.
Test the refusals
Permission tests that only show allowed calls succeeding prove little. For each rule, write a case that must be denied: wrong role, another tenant's record, amount just over the limit, expired approval, altered arguments and a tool that is not registered. Run these in your build so that a refactoring cannot quietly widen access. Add adversarial conversations that try to talk the agent into a forbidden action, and assert on what the systems recorded, not on what the agent said. Formal Verification and Testing Foundations shows how to state such rules as invariants.
How tools are abused
| Path | What happens | Defense |
|---|---|---|
| Injected instructions | A document tells the agent to act | Permissions independent of text; taint tracking; approval |
| Data in outbound requests | Secrets placed in a URL or message | Egress allowlist; content checks; recipient rules |
| Chaining harmless tools | Read private data, then post it | Rules across the whole task, not only per call |
| Over-broad queries | Dumping whole tables | Row limits, field limits, narrow tools |
| Resource exhaustion | Loops and fan-out | Budgets and rate limits |
| Poisoned tool definitions | A third-party tool describes itself misleadingly | Review, pin versions, trust only vetted sources |
A dangerous combination is an agent that can read private data, process untrusted content and send information outside. Where possible, remove one of the three for a given task. For example, once untrusted web content enters the context, switch off outbound messaging or require approval for it. See Excessive Agency, Exfiltration and Privilege Escalation.
Protect tools that fetch addresses
Server-side request forgery (SSRF) happens when someone causes your server to request an address of their choosing, such as an internal service or a cloud metadata endpoint that returns credentials. A fetch tool is an obvious route.
"""Check a URL before a fetch tool is allowed to request it."""
import ipaddress
from urllib.parse import urlsplit
ALLOWED = {"docs.example.com", "status.example.com", "files.example.com"}
# A fixed table stands in for DNS so the result is repeatable.
DNS = {"docs.example.com": ["93.184.215.14"],
"status.example.com": ["93.184.215.15"],
"files.example.com": ["93.184.215.16", "10.0.0.8"]}
def check(url):
parts = urlsplit(url)
if parts.scheme != "https":
return "blocked: https only"
if parts.username or parts.password:
return "blocked: credentials in URL"
if parts.port not in (None, 443):
return "blocked: port"
host = parts.hostname or ""
if host not in ALLOWED:
return "blocked: host not on allowlist"
addresses = DNS.get(host, [])
if not addresses or not all(
ipaddress.ip_address(a).is_global for a in addresses):
return "blocked: resolves to a non-public address"
return f"allowed, connect to {addresses[0]}"
for url in ["https://docs.example.com/guide",
"http://docs.example.com/guide",
"https://169.254.169.254/latest/meta-data/",
"https://docs.example.com.evil.test/",
"https://docs.example.com@evil.test/",
"https://files.example.com/report",
"https://status.example.com:8080/"]:
print(f"{url:<43} {check(url)}")
Output:
https://docs.example.com/guide allowed, connect to 93.184.215.14
http://docs.example.com/guide blocked: https only
https://169.254.169.254/latest/meta-data/ blocked: host not on allowlist
https://docs.example.com.evil.test/ blocked: host not on allowlist
https://docs.example.com@evil.test/ blocked: credentials in URL
https://files.example.com/report blocked: resolves to a non-public address
https://status.example.com:8080/ blocked: port
The guard allows only named hosts over HTTPS and rejects tricks that make a hostile address look familiar. The files host is on the list but also resolves to a private address, so it is refused. A check alone is not enough:
- Connect to the address you checked, or a second lookup may return something else (DNS rebinding).
- Do not follow redirects automatically; check each new target.
- Enforce egress rules in the network, for example through a proxy, so that a parsing mistake is not fatal.
- Block access to metadata services and use your cloud provider's protections for them.
Revocation and emergency stop
Be able to disable one tool, one agent or one user's delegation within minutes. Revoke tokens, stop queued actions and record what was in progress. Test the switch before you need it. A stop that only prevents new conversations while background tasks continue is incomplete.
Review access regularly
| Review | Evidence |
|---|---|
| Which agents hold which scopes? | Registry export |
| Which scopes were never used? | Call records |
| Which calls were denied? | Policy logs; attacks or design gaps |
| Who approved the exceptions? | Approval records |
| Do refusals still work? | Automated negative tests |
"Never delete records" in a system prompt is guidance that may be ignored or overridden. If deletion must not happen, the agent should have no way to perform it.
An assistant can search a mailbox and send mail. An incoming message asks it to forward recent invoices to an outside address. The team's rules limit sending to known contacts, require approval whenever untrusted content was read in the same task and log the denial. The attempt fails, and the log prompts a closer look.
Write the permission model down
For each tool, record its class, the scope it requires, the record-level rule, limits, whether approval applies and who owns it. For each agent, record its purpose, the tools it may use, the data it may reach and who can change those grants. Keep this as data that the executor reads, so that documentation and enforcement cannot drift apart, and review changes to it like code. A reviewer should be able to answer "what is the worst thing this agent can do?" from that file in a few minutes. If the answer is unclear or alarming, narrow the grants before adding features.
Make denials useful
A refusal should be clear enough that the agent stops trying and the user knows what to do next. "Not permitted: refunds above your limit need a team lead; I can send the request" is better than a generic failure that invites the model to rephrase and retry. Avoid revealing whether a record exists to someone who may not see it. Count repeated denials within one task and end the task after a small number, since persistence against a refusal is either a design fault or a sign of manipulation. Send the pattern to whoever monitors security, with enough context to investigate.
Denial data is also design feedback. If honest users are often refused an action they need, change the grant through review instead of letting people work around it with a more powerful account.
Common mistakes
- One shared administrator credential for all tools.
- Checking the scope but not the record.
- Trusting identity or roles supplied by the model.
- Approving a vague summary rather than the action.
- Treating read tools as harmless.
- Letting fetch tools reach any address.
- No way to revoke access quickly.
Checklist
- Tools are classified by risk.
- Access is denied unless a rule allows it.
- User, agent and record are all checked.
- Credentials never enter model context.
- Approvals are exact, expiring and single use.
- Outbound destinations are restricted.
- Fetch tools are protected in code and network.
- Revocation has been tested.
Frequently asked questions
Should an agent have its own account?
Usually yes, so that its actions can be identified and revoked. When it acts for a person, also carry that person's authority and apply both.
Which actions always need approval?
That depends on your risk decisions and legal duties. Irreversible, costly, external or rights-affecting actions are common candidates.
Can a second model review tool calls?
It can add a signal, but it can be fooled too. Keep hard limits in deterministic code.
Is an allowlist practical for web research?
Not always. If any site must be reachable, isolate the fetcher with no internal network access and no secrets, and restrict what the agent can do afterward.
References and further reading
- OWASP Top 10 for Agentic Applications
- OWASP: excessive agency
- OWASP: SSRF prevention cheat sheet
- RFC 8693: OAuth token exchange
- NIST SP 800-207: zero trust architecture
Next steps
Code Execution and Sandboxing
Contain the riskiest tool of all.
Human-in-the-Loop and Approval Gates
Design approval workflows.
Agent Threat Model and OWASP Agentic Risks
Look at the whole attack surface.