Sub topic 1
What Least Privilege Means and Why Agents Need It
Prerequisites
Assume you understand basic LLM tool calling, APIs, authentication tokens, and access-control permissions. You should be able to read short Python and JSON examples.
Least Privilege for Agents
The principle of least privilege gives a component only the permissions required for its current task. An agent should receive the smallest useful set of tools, data, and credentials. Those permissions should also be limited by resource, operation, time, and rate.
This matters more for agents because a model chooses actions from uncertain inputs. A normal application may follow a fixed path. An agent can select a tool, arguments, and sequence of calls. If its permissions are broad, one mistaken or manipulated decision can produce broad damage.
How Model Output Becomes a Tool Call
A typical runtime separates model output from execution. The model requests a named tool with arguments. Application code checks the request, invokes an implementation, and returns the result to the model.
def search_docs(query: str) -> str:
return f"results for {query}"
TOOLS = {"search_docs": search_docs}
def run_tool_call(name: str, args: dict, allowed: set[str]) -> str:
if name not in allowed:
raise PermissionError(f"{name} is not allowed")
return TOOLS[name](**args)
result = run_tool_call(
"search_docs",
{"query": "rotate API keys"},
allowed={"search_docs"},
)
print(result)The allowed set is an authorization boundary. It must be enforced by ordinary code, not merely described in the system prompt.
Threat Model: Injection and Confused Deputies
Prompt injection occurs when untrusted content, such as a web page or document, tells the model to ignore its task and perform another action. If the agent can read private records and send external messages, injected text may turn those permissions into data theft.
A confused deputy is a trusted component tricked into misusing its authority for someone else. The model does not need to be malicious. It may follow hostile instructions that appear in retrieved content.
> callout warning > Treat retrieved documents, tool results, and user-provided text as untrusted data. Do not let them redefine authorization policy.
Excessive Agency
Excessive agency has three forms:
- Too much functionality: tools unrelated to the task are available.
- Too many permissions: a necessary tool can access unnecessary resources.
- Too much autonomy: high-impact actions run without confirmation.
Reduce the blast radius by removing unused tools, narrowing resource access, and requiring approval for irreversible actions.
Exercise
An agent only answers documentation questions. Which permission should you remove first: read-only documentation search or production database deletion?
Show answer
Remove production database deletion. It is unrelated to the task and creates unnecessary impact if the agent is manipulated.