Dashboard

What Is the Principle of Least Privilege for AI Agents?

Least privilege means every user, app, or AI agent gets only the access its job requires. Here is what that looks like for three common agent setups.

Carlo Zuercher
Carlo Zuercher
Staff Engineer, Platform
27 October 20261 min read

The principle of least privilege says that every user, program, or AI agent should have only the access it needs to do its job, and nothing more. NIST's glossary puts it as restricting access "to the minimum necessary to accomplish assigned tasks", and that covers processes acting on behalf of users as well as the users themselves, which is exactly what an AI agent is.

The reason it matters is simple. Mistakes and attacks happen. When they do, the damage is limited by what the compromised thing was allowed to do. An agent that can only read one folder can only leak one folder.

Where the idea comes from

NIST's definition appears in several security standards. One version describes a security architecture that gives each entity "the minimum system resources and authorizations that the entity needs to perform its function". Note the two parts: resources, meaning what it can touch, and authorizations, meaning what it can do to them. Reading a file and deleting it are different authorizations on the same resource.

Why agents make this more urgent

A person with too much access usually behaves predictably. An AI agent does not. It follows instructions, including instructions hidden in a web page, an email, or a support ticket. That is the core of prompt injection, and it means an agent's real permissions are the permissions an attacker could use by tricking it.

So the question to ask about an agent is not "do I trust it?" The question is "what is the worst thing it could do with everything it can reach?" That worst case has a name: the blast radius of an AI agent. Least privilege is how you shrink it.

Three agents, before and after

Here are three setups that show up constantly, with the access they usually get and what a tighter version looks like.

Agent

Typical access

Least-privilege version

Coding agent in your repo

Full repo, shell, production environment variables

Feature branch only, no production secrets, read-only access to everything outside the task folder

Email assistant

Full inbox, send, delete, calendar, contacts

Read and draft only, no send, one label or folder, no delete

Support chatbot with data access

Direct database credentials with write access

A read-only view of the few tables it needs, with no customer payment fields

None of these changes make the agent less useful for its actual job. They remove capabilities the job never needed.

The coding agent

The common mistake is running an agent in a shell that already holds production credentials. Keep a separate environment file for development, and keep real keys out of the agent's reach. The post on whether an AI coding agent can leak your API keys explains how that happens, and sandboxing an AI agent shows how to contain one.

The email assistant

Mail is a high-value target because it contains password resets. Start with read-only access plus drafting. A human clicks send. If the assistant never gets delete or send rights, an injected instruction in a message cannot use them. OAuth scope creep is the usual way these permissions grow without anyone deciding to grow them.

The support bot

Give the bot a database role built for it. That role should see only the columns required to answer questions. If the bot needs an order status, it does not need a card token.

A ten-minute audit

Pick one agent you run today and answer five questions:

  1. What can it read? List folders, tables, inboxes, and accounts.

  2. What can it change or delete? List separately from the first answer.

  3. What can it spend or send? Money, emails, messages, API calls.

  4. Which of those did the task actually need? Cross out the rest.

  5. What happens if it is tricked tomorrow? Write the answer in one sentence.

The gap between answers one to three and answer four is your over-privilege. Close the gap by changing scopes, not by adding warnings to the prompt. A prompt that says "do not delete anything" is a request. A role that cannot delete is a control.

Least privilege in your own app

The same rule applies to the apps you build. If users have roles, give each role the smallest set of actions that works, and add more on request instead of starting wide. The how-to on adding role-based permissions to an AI-built app shows a practical structure for that.

What least privilege does not do

It does not stop an agent from making mistakes inside its permitted area. A coding agent with write access to your feature branch can still write bad code there. It limits the damage, it does not remove the need for review. For the wider picture, the guide to AI risks covers the other layers.

FAQ

What is the principle of least privilege in simple words?

Give each person or program the minimum access required for its task. Nothing extra, even if it would be convenient.

What is an example of least privilege?

A bookkeeper who can view invoices but cannot change bank details. Or an AI agent that can draft emails but cannot send them.

Does least privilege apply to AI agents?

Yes, and arguably more than to people, because an agent can be steered by text it reads. Its permissions are what an attacker inherits if they trick it.

How is least privilege different from zero trust?

Least privilege limits what an identity can do. Zero trust is a wider approach that verifies every request instead of trusting a network location. They work together.

How do I start applying it?

Pick one agent, run the five-question audit above, and remove one permission it never used. Repeat monthly.

How did this land?

About the author

Carlo Zuercher
Carlo Zuercher

Staff Engineer, Platform

Carlo works on the platform that turns prompts into running apps. He writes the engineering deep dives and the changelog notes worth reading.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.