Least Privilege for AI Agents: Scoped Credentials and Capability Design
Design least-privilege AI agents with scoped credentials, resource-bound grants, controlled delegation, explicit elevation, and credential lifecycle checks.
Abhishek Raj · · 8 min read
Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.
Least privilege for AI agents means limiting what the executing system can do, even when its model proposes something broader. A prompt that says “only read approved files” is useful guidance. A credential that can delete every file still grants deletion authority. The enforceable boundary sits in the executor, authorization service, and protected resource.
This guide develops a hypothetical procurement assistant. Its proposed grant records, durations, and policies illustrate one design; they are not a tested implementation or a standard token format.
Describe authority as a bounded capability
Start with a permission inventory for the task rather than a catalog of available integrations. Our procurement assistant needs to read one purchase request, find approved supplier records, and draft a purchase order. Sending the order to a supplier is a separate business action.
A useful proposed capability has several dimensions:
| Dimension | Illustrative restriction | What a broad alternative would allow |
|---|---|---|
| Action | Read supplier status | Change supplier payment details |
| Resource | Suppliers referenced by this request | Enumerate the entire supplier directory |
| Tenant | Authenticated organization | Select an organization from model input |
| Purpose | Prepare this purchase order | Reuse access for unrelated investigations |
| Time | Current run until its deadline | Continue after the task ends |
| Effect budget | One approved order submission | Send repeated orders |
Not every dimension is representable in an OAuth scope. Some require application policy, resource attributes, or an operation ledger. The important design question is which component enforces each restriction. A field named purpose has no security value if every downstream service ignores it.
AWS IAM guidance frames least privilege around actions, resources, and conditions, and recommends temporary workload credentials rather than distributing long-lived access keys where roles can be used. Those platform mechanisms are examples of enforceable restrictions, not an agent-specific authorization model. AWS IAM security best practices.
Separate tool visibility from execution permission
Hiding a tool can reduce accidental selection, but visibility is not authorization. An attacker may invoke the backend directly, an old worker may retain a tool reference, or another integration may expose the same operation.
In the proposed architecture, the model sees a task-specific tool catalog. Every invocation passes through an executor that derives identity from authenticated server context. The executor checks the requested action against the current grant and then calls the protected service, which performs its own authorization.
The model may provide an order identifier. It must not provide the authoritative tenant, impersonated user, or approval status. Those values come from trusted execution records. If an order identifier belongs to a different tenant, the service rejects the request regardless of how plausible the model's explanation sounds.
Keep this distinction explicit in agent tool contracts: descriptions guide selection; schemas constrain structure; authorization controls access. None substitutes for the others.
Scope credentials to their intended recipient
OAuth scopes and token audiences answer different questions. Scope describes requested privileges within the authorization system's vocabulary. Audience restricts where the token is intended to be accepted. Neither automatically restricts access to a particular purchase request unless the receiving service enforces that relationship.
RFC 9700 recommends minimizing access-token privileges and restricting tokens to a particular resource server, or a small set when necessary. It requires the resource server to reject a token intended for another audience. A successful signature check alone therefore does not establish that a token is acceptable to this service. OAuth security best current practice, section 2.3.
For our example, a token accepted by the supplier lookup service should not become an order-submission credential merely because both services belong to the same organization. Prefer separate grants or a policy-enforced exchange when crossing that boundary. Keep tokens out of the model transcript; the executor can attach them after validating a proposed operation.
MCP's security guidance explicitly rejects token passthrough and describes risks from accepting tokens issued for other resources. It also recommends progressively requesting permissions instead of treating every advertised scope as necessary. These requirements concern the protocol and authorization flow; business-level purchase restrictions still belong to the application. MCP security best practices.
Make delegation attenuate authority
Delegation should produce an equal or narrower authority set, never quietly expand it. If a coordinator can read three supplier records, its research worker should not receive access to every supplier plus order-submission rights.
One illustrative grant record could look like this:
{
"grant_id": "grant_example_27",
"parent_grant_id": "grant_example_12",
"run_id": "run_example_81",
"principal_id": "worker_example_4",
"allowed_actions": ["supplier.read"],
"resource_ids": ["supplier_example_A", "supplier_example_B"],
"expires_at": "2026-11-10T12:15:00Z",
"policy_version": "procurement-example-v3"
}
This is an application record, not an OAuth token example. A trusted grant service must validate parent authority, store the record, and prevent untrusted changes. The worker cannot expand its resource list by editing JSON. If the upstream supplier API only offers broad organization-wide access, a narrow facade can enforce the application restrictions, but its broad underlying credential remains a sensitive dependency.
RFC 8693 defines OAuth token exchange, including delegation and impersonation semantics. It supplies a protocol for requesting tokens, not a guarantee that an authorization server will enforce your intended attenuation policy. The specification also notes that exchanged tokens do not inherently maintain a tight lifecycle linkage with their input tokens. Revocation propagation is deployment-specific. OAuth token exchange.
Record both the initiating principal and acting workload when the authorization system supports that distinction. Otherwise an audit trail may show a service account without identifying which user task caused the operation.
Elevate at the business-action boundary
Suppose the assistant has prepared an order for supplier A. It now needs to send the order. The original read grant is insufficient, so the executor pauses for the application's authorization process.
In this illustrative policy, the reviewer approves an immutable proposal containing supplier identity, normalized line items, total, currency, delivery destination, and an operation identifier. The grant service issues authority for that exact submission after checking the reviewer's permissions. A different supplier or changed total creates a new proposal rather than reusing the old authorization.
At execution time, the service checks that the proposal remains current and the grant has not expired. It commits the order using a stable action identity. Approval does not remove the need for idempotent agent actions: a retry after a lost response must recover the same order outcome, not submit another order.
Now consider a malicious supplier document that tells the agent to update payment details first. The model might propose that action. The proposed read grant and order-specific submission grant both exclude it. The denied operation becomes an observable security event; the system does not ask the model whether the instruction looks trustworthy enough to override policy.
Manage the entire credential lifecycle
Short-lived access limits exposure, but it does not solve every recovery problem. A worker may still possess a valid token after its run is canceled. An authorization cache may retain a recently revoked grant. A queued operation may arrive after the deadline.
For this proposed design, check task cancellation and grant status at the executor boundary immediately before dispatch. Define whether the protected service supports revocation, introspection, or only token expiry, and document the resulting exposure window. Avoid promising immediate revocation when the actual mechanism is eventual propagation or expiration.
Keep refresh authority narrower than a general login session where possible. Automatically refreshing a token after cancellation defeats a short access-token lifetime. Bind refresh eligibility to the active run and current policy, and ensure background credential renewal cannot resurrect a completed task.
Separate cleanup from rollback. Deleting a credential prevents some future calls; it does not reverse an order already sent. Incident recovery must reconcile external effects as well as disable future access.
Prove denied access stays denied
Build negative tests before expanding autonomy. For the procurement example, exercise an out-of-tenant supplier, an unlisted resource, a write attempted with read access, an expired grant, a canceled run with an unexpired token, and a child grant requesting more authority than its parent.
Test the same cases through every relevant entry point, including direct service calls. Also test changes over time: revoke permission between planning and execution, deliver a queued call after expiry, and retry an old approved proposal after its contents changed.
Inspect protected records and logs, not only the assistant's final answer. The acceptance condition is that forbidden effects never occurred and permitted effects have an attributable authorization chain. Log grant identifiers, policy versions, decision reasons, and operation identities without recording bearer credentials.
Frequently asked questions
Is a read-only agent automatically low risk?
No. Read access can reveal confidential data, cross tenant boundaries, or feed information to an external destination. Restrict resources and output channels as well as mutation permissions.
Should every tool have its own OAuth scope?
Not necessarily. Group operations when they share a meaningful authority boundary, then enforce resource and business constraints separately. Excessively broad groups hide risk; excessively fragmented scopes can make consent and maintenance harder.
Can one coordinator credential be shared with all workers?
That makes worker compromise inherit the coordinator's reach. Prefer workload identity and narrowed grants where the infrastructure supports them. When broad shared credentials remain unavoidable, treat that as an explicit architectural limitation and constrain access through an enforced facade.
Source reference list
Related reading
- AI Agent Tool Design: Schemas, Contracts, and Error Semantics
Design reliable AI agent tools with precise schemas, bounded permissions, structured results, and error contracts that handle retries and uncertain outcomes.
- Idempotency for AI Agent Actions: Preventing Duplicate Side Effects
Prevent duplicate AI agent actions with stable intent identities, immutable request fingerprints, durable ledgers, and recovery for uncertain outcomes.
- Human-in-the-Loop Agents: Designing Useful Approval Gates
Design human-in-the-loop agent approvals with immutable proposals, qualified reviewers, expiry, durable resumption, and checks against changed resource state.