Skip to content

Least privilege for AI agents: how to scope tool permissions

Grant per agent and per tool, draft grants from real traffic, limit arguments, set impact and provenance rules, require approval for the irreversible.

The AgentFox team8 min read

A refused tool call in AgentFox: the agent holds a grant for the tool, but the amount passed is above the limit on it.

The model is the wrong unit of trust

Least privilege for AI agents is the same idea as for any other principal: give it the access its job needs and nothing more. The difference is where the decisions are made. An agent decides which tool to call by reading text, and some of that text was written by strangers: a web page, a customer's email, the result of another tool. Whoever writes that text can, some of the time, choose the call. So “the model would never do that” is not a permission model. The permission has to sit outside the model, where the text cannot reach it.

That is also the practical answer to the lethal trifecta: an agent with private data, untrusted content and a way to send data out. You rarely get to remove one of the three. You can decide, per agent, exactly which sending tools exist and with which arguments.

One grant per agent, per tool

The unit is an agent and a tool. A support agent holds grants for the order lookup and the ticket update; it holds nothing for refunds, so a refund call is refused before it reaches the payment system, whatever the model was told. A tool nobody granted is not a permission that was forgotten; it is a refusal, and it is recorded as one.

Granting a tool to one agent
agentfox permit grant support-triage orders.lookup --yes
agentfox permit grant support-triage tickets.update --yes
# MCP tools are named per server, so two servers' search tools stay apart
agentfox permit grant support-triage mcp:github/search_issues --yes

Grant a whole server or a wildcard only when every tool behind it should be callable. The shortcut is where the privilege creeps back in.

Draft the grants from real traffic

Nobody knows an agent's real tool use from its code alone. Run it in observe mode first: every call is checked and recorded, nothing is blocked, and the agent's page lists the tools it tried that nobody allowed. Allow each one that should have been, or all of them, and the draft is done from what the agent actually does rather than what someone thought it did. The scan of the repository fills in the tools it found but nobody allowed yet, for the ones that have not been exercised. The walkthrough is on the tool access page.

Limit the arguments, not just the tool

A grant for payments.transfer says the agent may move money. A limit says how much. Most real damage is a legitimate tool with an illegitimate value: a refund for the full balance, a query over every row, a message to an address the customer never gave. Each grant takes constraints on arguments, and a call outside them is refused with the reason spelled out.

A refusal from a limit, as the audit log records it
{
  "tool": "payments.transfer",
  "verdict": "block",
  "rule_id": "capability.constraint_violated",
  "reason": "agent:payments-ops holds a grant for 'payments.transfer', so this is not a missing permission. The grant allows amount below 1000, but this call passed 25000."
}

Impact tiers and where a value came from

Two more dimensions keep the grants short. The first is impact: every tool is read-only, writes, high impact or irreversible, guessed from its name and description and worth checking by hand, because a tool that moves money but is marked read-only is not protected. The second is provenance: where each argument value came from. A person typed it, or it came from a retrieved document, another tool's output, or another agent. The two combine into one table.

  • Read-only tools go through.
  • A write is held for approval if the value came from another tool's output or worse.
  • High-impact and irreversible tools are held unless the user typed the value.
  • A value copied out of a lower-impact tool's output into a higher-impact tool is refused outright, because that is the shape of an escalation.

If a flow like that is intended, say an address from your own CRM, you mark that tool's output trusted, once, and the rule stands for everything else. This is the mechanism behind the result in detection is a speed bump: on AgentDojo's 588 attacks the containment holds with every detector off, because the attacks need a value from untrusted text to reach a tool that acts.

Approval for what cannot be undone

Some calls should wait for a person every time: a transfer, a deletion, a message to a customer. Set the grant to ask first, and the call waits on the approvals queue until someone approves or denies it, bound to the exact arguments, so an approval cannot be reused for a different amount. Approval is the control of last resort, not the first: a queue that gets a hundred requests a day gets rubber-stamped.

What it costs, measured

Least privilege is not free, and the honest number is on our benchmark page: with the default grants, AgentFox finished 24 of AgentDojo's 97 normal tasks without a person approving a step, where LLM Guard's scanner finished 42. The attacks it stopped went 0 of 588 against 86. That is the trade. It moves with the grants: wider grants and trusted sources recover tasks, and the benchmark page shows the settings and what each one costs in attacks stopped.

A checklist

  1. Every agent has a named identity and its own grants. No shared “the agent”.
  2. Grants were drafted from observed traffic, then reviewed by a person.
  3. No wildcard grant on a server or tool family that includes a write.
  4. Every tool that moves money, deletes or sends has an impact tier set by hand.
  5. Argument limits exist on every tool where the value is the risk.
  6. Irreversible tools require approval, bound to the exact arguments.
  7. Values from documents and tool output cannot reach high-impact tools without a person.
  8. Every refusal is in the audit log with its reason, and someone reads the refusals weekly.

Frequently asked questions

Isn't the model's own judgement enough to avoid misusing a tool?

Not against an attacker. The model decides what to call based on text it reads, and that text can be written by anyone whose document, web page or tool output the agent sees. Least privilege puts the decision about what may be called with a person, before the agent runs.

Do I have to write the grants by hand?

No. Run the agent in observe mode first. Every call it makes to a tool it was not granted is listed as tried but not allowed, and you allow each one that should have been, or all of them. Argument limits are then added where the risk is.

What about agents that hand work to other agents?

A call is checked under the agent that makes it, and an agent that delegates cannot hand on more than it holds. A triage agent that reaches a refund tool only through a refunds agent is tested, and governed, through that path.

Try AgentFox on your own agent

One command finds your agents. It starts in watch mode, so nothing is blocked until you say so.

uvx agentfox scan