Designing least-privilege tools for AI agents, step by step
A practical walk-through of designing one AI agent tool with least privilege: narrow inputs, the user's identity, scoped tokens, log-only rollout, tightening.
Westerwick4 min read

On this page
Most advice on AI agent security stops at principles: give the agent as little access as possible. That's right, but it leaves the practical question unanswered. What does a well-designed tool actually look like?
This piece walks through designing one tool with least privilege, step by step. The example is a support agent that needs to check an order's status. The principles behind it, and why prompt instructions aren't a control, are in our companion piece, giving an LLM agent tools without giving it the company.
Step 1: Make the tool do one thing
The tempting design is a general tool: "run a database query" or "call the orders API". OWASP, the security standards community, warns against this: "Avoid the use of open-ended extensions where possible" and build tools with narrow functionality instead3.
So the tool is get_order_status, and it does exactly that. AWS's guidance for agents explains why narrow tools help beyond security: "Narrow, atomic agents with explicit input contracts and structured output schemas make the unpredictable parts of the model more observable, testable, and containable"1. Offering the model a defined set of tools "limits the model's action space to operations relevant to the agent's function"1.
Step 2: Accept as little as possible
Design the tool's inputs as tightly as its purpose.
- One parameter: an order number, in a fixed format.
- No free text that could smuggle in extra instructions or query fragments.
- Validate before anything runs. AWS recommends you "validate inputs before the LLM is called so malformed or out-of-scope requests don't reach the model"1. The same applies to every tool call: reject anything that isn't a well-formed order number.
And return as little as needed: the status and expected delivery date, not the whole customer record.
Step 3: Don't let the model say who the customer is
This is the step most designs miss. If the tool accepts "customer ID" as a parameter, a manipulated model can simply ask about someone else's orders.
Instead, the tool works out who is asking from the signed-in session, not from anything the model supplies. It then checks that the order belongs to that person. The model chooses which order to look up. The system decides whether this user may see it.
Step 4: Act as the user, with a key made for this job
When the tool calls the order system, whose credentials does it use? Two patterns are dangerous: a powerful shared service account, and passing the user's own sign-in token straight through to every system.
AWS describes a better pattern it calls "act-on-behalf", where "each downstream target receives a separate, least-privileged token scoped specifically for that service"4. Passing the user's original token along risks what security teams call a confused deputy, a system tricked into using its authority for someone else4.
The Model Context Protocol (MCP), an open standard for connecting agents to tools, builds the same rules in. A tool server "MUST NOT pass through the token it received from the MCP client"5, tokens must be issued specifically for that server5, and authorisation servers "SHOULD issue short-lived access tokens"5.
On AWS, the underlying role for the tool gets read access to the order records it needs and nothing else. AWS defines least privilege as allowing specific actions "on specific resources under specific conditions"6, and its agent guidance warns that using a wildcard for convenience "is the single most common reason least-privilege quietly degrades into broad access over time"2.
The model decides which order to ask about. The system decides whether you're allowed to see it.
Step 5: Put a rule check in front of the tool
Between the agent and the tool, add a gate that checks each call against written rules. On AWS, Amazon Bedrock AgentCore Gateway can do this with AgentCore Policy, which follows "deny-by-default" semantics4: anything not explicitly allowed is refused.
For our example, the rules might say: support agents may call get_order_status during business hours, and a single user may make at most a set number of calls per minute. A gateway can also hide tools a given user shouldn't have, which AWS notes improves reliability by "reducing erroneous tool-selection decisions"4.
Step 6: Watch first, then enforce
Don't switch strict rules on blind. AWS recommends starting in a LOG_ONLY mode, which "lets you validate that every policy rule behaves as expected before switching to ENFORCE mode"4. Run real traffic, check what would have been blocked, fix the rules, then enforce.
Keep an off switch too. A single deny rule should be able to stop a tool immediately if something goes wrong.
Step 7: Tighten from real usage
After a few weeks, compare what the tool's role is allowed to do with what it actually did. IAM Access Analyzer can look at recorded activity and generate "a fine-grained policy that you can use"6, based only on the actions actually used. Remove everything else.
Then log every call, and set a rate limit. OWASP recommends both: logging and monitoring tool activity, and rate-limiting "to reduce the number of undesirable actions that can take place within a given time period"3.
What to do next
- Pick one tool your agent uses and write down its exact job in one sentence.
- Remove any parameter that identifies the user. Take identity from the session instead.
- Give the tool its own role, with no wildcards, reading only what it needs.
- Roll out rule checks in log-only mode first, then enforce.
- Review real usage after a month and cut anything the tool never used. Our Act demo shows the user's side of this: an agent that looks up an order freely but needs approval to change it.
Sources
- 1.AGENTREL02-BP01 Design agents for specific and atomic tasksAWS Well-Architected Framework, Agentic AI Lens
- 2.AGENTREL02-BP02 Limit agent permissions to minimum required accessAWS Well-Architected Framework, Agentic AI Lens
- 3.LLM06:2025 Excessive AgencyOWASP GenAI Security Project
- 4.Secure AI agents with Policy and Lambda interceptors in Amazon Bedrock AgentCore gatewayAWS Machine Learning Blog · 1 June 2026
- 5.Authorization (Model Context Protocol specification, 2025-06-18)Model Context Protocol
- 6.Security best practices in IAMAWS Identity and Access Management User Guide


