Least privilege is an old idea — give a component only the access it needs, nothing more — and it's the single most effective thing you can do for an LLM agent. Not because it stops prompt injection (nothing fully does), but because it decides how much a successful injection is *worth*. An over-privileged agent turns a bad paragraph of text into a bad action. A least-privileged one turns the same paragraph into nothing.
Privilege, for an agent, is its tools
For a traditional service, privilege means its credentials and network access. For an agent, it's all of that plus its tools — the shell, the file reader, the HTTP client, the MCP servers, the ability to open a PR. Each tool is a capability the model can invoke on text it may not fully control.
So scoping an agent means two questions, asked per tool:
- Does the agent need this tool at all? The cheapest tool to secure is the one you removed.
- Does it need the tool's full reach, or a slice of it? A file tool scoped to
src/is a different risk from one that can read/.
The two columns are the same agent. The left one can be made to do real damage by a single injected instruction; the right one can't, because the capability simply isn't there. The injection is identical — the privilege is not.
Concrete scoping moves
- Drop unused tools. Audit the tool list against what the agent actually does. Idle tools are pure attack surface with no upside.
- Scope file access to a directory, and explicitly deny credential-bearing paths —
.env,.git/config, key files, home-directory dotfiles. Assume any readable file is readable by an injection. - Make tools read-only where you can. A review agent reads; it rarely needs to write. Read-only is a hard ceiling on damage, not a speed bump.
- Remove network egress from tools that don't need it. No egress means injected instructions can't exfiltrate, however clever they are.
- Gate the writes that remain. Whatever write or destructive capability survives the cut should require human approval, not auto-run — the approval-gate pattern from prompt injection defenses that actually work.
- Scope credentials to match. A tool with an admin token is privileged even if the tool itself looks narrow. Give it the smallest-scope credential that works.
The deny-list trap, again
It's tempting to keep a broad tool and "just block the dangerous stuff." It doesn't hold. Deny-lists enumerate the bad cases you thought of; injections find the one you didn't. Allow-lists enumerate the good cases, which are fewer and which you control.
deny-list: allow everything EXCEPT rm, curl, wget, nc, ...
→ bypassed by the equivalent you forgot
allow-list: deny everything EXCEPT read_file("src/**")
→ the attacker is limited to what you chosePrefer deny-by-default with a small, explicit allow-list every time.
Why this is the highest-leverage control
Most agent-security advice — trust separation, output validation, input filtering — lowers the *probability* of a successful injection. Least privilege lowers the *impact*. Probability controls degrade as attackers adapt; an impact control doesn't care how the injection got in, because there's nothing on the other side to exploit.
Probability controls are an arms race. Impact controls are a ceiling. Build the ceiling first.
That's why least privilege is the floor the other defenses sit on, not an alternative to them.
How OpenRouting helps
OpenRouting inventories the tools and permissions in your agent setup during a scan and flags where privilege is broader than the task needs: unused tools, unscoped file or shell access, write-capable tools without approval, and credentials wider than their tool. The result is a short, specific list of "this is more powerful than it needs to be" — which is exactly the list least privilege asks you to work through. See how it works for where this fits in a scan.
Ship the narrow version. You can always widen a tool deliberately later; you can't un-leak what a wide one already reached.