# 28.4 Least privilege for tools, data and network (/building-ai-workers/guardrails-and-agent-security/least-privilege)

---
type: Document
title: "28.4 Least privilege for tools, data and network"
description: "Who may propose a payment, why approving is never a scope, how one approval pays once, and which tools, data and network the worker keeps."
status: stable
order: 328.04
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T10:59:25Z
chapter: '28'
part: III
expert_status: builder-only
concepts: [ "28.4" ]
last_verified: '2026-11-30'

sources:
  - id: anthropic-managed-agents-risks
    title: Security risks and sandbox boundaries, Claude Managed Agents (Anthropic, accessed 2026-11-30)
    resource: https://platform.claude.com/docs/en/managed-agents/secure-deployment-risks
  - id: anthropic-mitigate-jailbreaks
    title: Mitigate jailbreaks and prompt injections (Anthropic, accessed 2026-11-30)
    resource: https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/mitigate-jailbreaks
  - id: claude-agent-sdk-secure-deployment
    title: Securely deploying AI agents (Claude Agent SDK, Anthropic, accessed 2026-11-30)
    resource: https://code.claude.com/docs/en/agent-sdk/secure-deployment
  - id: claude-agent-sdk-permissions
    title: Configure permissions (Claude Agent SDK, Anthropic, accessed 2026-11-30)
    resource: https://code.claude.com/docs/en/agent-sdk/permissions
  - id: claude-code-permissions
    title: Configure permissions (Claude Code, Anthropic, accessed 2026-11-30)
    resource: https://code.claude.com/docs/en/permissions
  - id: claude-code-prompt-caching
    title: How Claude Code uses prompt caching (Anthropic, accessed 2026-11-30)
    resource: https://code.claude.com/docs/en/prompt-caching
generated:
  at: 2026-11-30T10:59:25Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:d6ce3f28a2cf8e492a60bae1b426b7cc6466e35e83d70c3b9763db2c55009f4b
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** In a small family shop, a helper writes the checks for the week's suppliers. But a check is worth nothing until the owner signs it, and the bank looks at the signature, not the helper's word. The helper's key opens the storeroom, not the office. And the shop's bank account is not on the helper's phone, so a stranger who calls cannot ask the helper to send money from it. In this section, writing a check is proposing a payment, the signature is a person's approval, the bank is the connector, and every key the helper does not hold is a privilege the worker does not have.

**What you will learn.** You practice this in Lab 28, Tasks 3 and 4.

- What is least privilege, and which tier is it?
- Who may propose a payment?
- Why is approving not a scope?
- How does one approval pay only once?
- Which tools does the orchestrator keep?
- What data may the worker see?
- Where can data still leave?

**Why it matters.** Anthropic gives the reason in one line: "Apply the principle of least privilege so that a successful injection can do minimal damage".[^anthropic-mitigate-jailbreaks] The layers of [28.3](layers-of-defense.md) make a fooled model less likely. Least privilege decides what a fooled model can reach.

**At work.** Two events from the overview end here. One is the 403 at 10:15. The other is the 9:20 note that no tool can carry out.

### What is least privilege, and which tier is it?

**Least privilege means each part gets only the access its job needs.** Anthropic: "don't give Claude access to secrets it doesn't need, run tools in sandboxed environments, and scope permissions as narrowly as possible."[^anthropic-mitigate-jailbreaks] The place you apply it decides the tier. A limit in the connector, such as a scope, an approval or a field it never returns, meets every call, whichever route it came by. A limit in the runtime, such as its tools, hosts or sandbox, meets only the calls that come through that runtime.

### Who may propose a payment?

**A person whose role carries `ap:pay`. Proposed: an `owner` or an `admin`.** [18.7](../securing-connectors/permission-per-tool.md) gave the first tool that acts its own scope, `ap:pay`, "which no role has until someone decides who may move money". This chapter decides. `ap:pay` means "may propose a payment", and Brightline's map of roles to scopes becomes:

| Role | Scopes |
| --- | --- |
| `owner`, `admin` | `ap:read`, `ap:vendors.read`, `ap:pay` |
| `member` | `ap:read`, `ap:vendors.read` |
| `auditor` | `ap:read` |

The connector gains two tools. `schedule_payment` needs `ap:pay` and a matching row in `approvals`. `get_approval` needs only `ap:read`, and only reads.

The model's call to `schedule_payment` carries only an invoice and an amount. The company comes from the token, and code, never the model, adds the **run key**. Before the hook decides, it writes the call's evidence line ([28.5](hooks-as-deterministic-enforcement.md)). The portal's approval page lists a call that has no approval yet as a *proposal*, but only when the run's token carries `ap:pay`. The proposer is the person whose token the run carries. That is how INV-8305 reaches Dave. Ana's 9:00 run proposes it, and the hook denies the call and writes its line. Then at 10:00 Dave approves it for one amount. The 9:40 script's calls propose nothing, because no hook runs on that route.

<!-- EDITOR: the spec does not settle how a proposed payment reaches the portal's approval page. This draft proposes that the page lists the proposals from the hook's evidence lines, so the proposal Dave approves comes from Ana's real 9:00 run, and that the proposer is the person whose token the run carries. How the lines reach the portal (the hook sends each line to the portal, or the portal reads the log) is the kit's, and depends on the staging choice in the lab. The other options: the connector records each call it refuses as a proposal, which makes the 9:40 script's call the proposal Dave approves, or the page lists every open invoice over the threshold. Either changes only this paragraph, the 9:00 row and Task 4. -->

A run carries the token of the person who started it ([23.9](../hosted-agents/three-identities-never-one.md)), so Ana's runs may propose a payment and Priya's may not. A call from Priya's run puts nothing on the approval page, and if it reaches the connector, the connector answers 403. If Priya's app tries 18.7's step-up for `ap:pay`, the sign-in server grants only her role's scopes. A role's new scopes reach each person with their next token ([18.14](../securing-connectors/a-companys-life.md)).

Dave Kowalski is an `admin`, so his token carries `ap:pay` too. Proposed: Dave never starts a payment run. He is the one who approves, and nobody approves a payment their own run proposed.

<!-- EDITOR: ap:pay as "may propose a payment", carried by owner and admin, is the spec's proposal (raised point 4), as is Dave's admin membership (point 3c). The other option: a separate role for payments, which no chapter has yet. Where Lab 18's build keeps the map of roles to scopes, a database table or the sign-in server's settings, is still to be read from Lab 18's kit (OPEN). -->

### Why is approving not a scope?

**Because a scope is carried in the run's token, and a fooled model can use anything the run carries.** If approving were a scope given to Dave, every run he started would carry it. A planted note could lead the model to approve and pay in one run, and no check could tell Dave's decision from the model's.

So an approval is a row, not a permission. The portal's server writes a row in `approvals` when a person, signed in as themselves, approves a proposal on the approval page. It writes the row only if that person is not the proposer, and only if their limit covers the amount. Each person's limit is in an approvers list in `data/settings.csv` (proposed). Over $5,000.00, only Dave Kowalski may approve. No tool and no token writes `approvals`.

<!-- EDITOR: who approves a payment of $5,000.00 or less is open (spec, raised point 5). The spec's "Changes to the base" settles only that every proposed payment needs a row from someone not its proposer, and that over $5,000.00 only Dave approves. This page says only that. The spec recommends (a), Dave approves every payment the worker proposes, as Part II already has him approve "every weekly run". The other option is (b), a second Brightline person who is not the proposer, a new story fact. -->

At the payment, the connector checks both: the token carries `ap:pay`, and a row matches the token's company, the invoice and the amount. It also refuses if the person whose token makes the call is the row's approver. Words in a run can change what the model proposes. They cannot write a row.

### How does one approval pay only once?

**The connector makes each payment's run key from the matching row's id, and uses the approval up in the same step as the payment.** A run key is the value that names one payment run, so that a second call with the same key does nothing. Code sets it, never the model, and one approval can only ever have one.

The connector also marks the row as used in the same **transaction** as the payment. A transaction is a group of database changes that happen together or not at all. So at 10:30, a second call for Dave's approval finds the row used, and does nothing.

<!-- EDITOR: the run key and its transaction are the spec's proposal (raised point 3g) and are not yet in specs/labs/part-2-facts.md. -->

### Which tools does the orchestrator keep?

**Only the ones its job needs, and none that reach outside.** On the Claude Agent SDK its tools come in three groups:

- *Built-in tools.* `tools: []` "turns off every built-in tool" ([Chapter 22 reference](../agent-sdks/reference.md)). In Lab 28, Task 2, the orchestrator lists one, `tools: ["Agent"]`, which starts its subagents, so the shell, the file tools and the web tools are gone. `allowedTools` would not do this. It only approves the tools it names, and "Other tools not listed here still exist".[^claude-agent-sdk-permissions] The init message, a run's first message, names that tool `Task`.
- *Connector tools.* The four read tools, and `schedule_payment`, which only the main loop holds. `vendor-lookup`'s only tool is still `find_vendor`.
- *A denied tool.* The connector also lists `get_approval`, which only the hook's code calls, straight to the connector ([28.5](hooks-as-deterministic-enforcement.md)). So the orchestrator writes it in `disallowedTools` by its full name, the connector's prefix included. A call the model makes to it is then denied "even in `bypassPermissions` mode and when a hook returned `allow`".[^claude-agent-sdk-permissions] Whether the model still sees the tool is a separate question. Claude Code's permissions page says a deny rule that names a whole tool "removes the tool from Claude's context entirely", and a glob such as `"mcp__*"` works "the same as a bare tool name".[^claude-code-permissions] But the Agent SDK's page promises this only "To hide a built-in tool".[^claude-agent-sdk-permissions] Claude Code's caching page adds that when tool search is active, "which is the default on supported models, the request's tool definitions don't change".[^claude-code-prompt-caching] So count on the deny, not on the model never seeing the tool.

With no shell, no file tool and no web tool, the 9:20 note asks for something no tool can do. That guard decides on one route: this runtime's list.

<!-- OPEN: the question of hiding get_approval is closed with the live quotes above, read 2026-11-30: permissions (lines 60 and 214), agent-sdk/permissions (lines 27, 84 and 121) and prompt-caching (line 173). Add them to the vendor fact sheet. Still open for a recorded run: whether a denied connector tool appears in the init message's tool list. Lab 28, Task 4's leak test checks only that a call to it is denied. -->

### What data may the worker see?

**Only the fields the job needs, cut at the connector.** `find_vendor` returns the last four digits of an account (17.7). A field the connector never returns cannot leak by any route.

The payment's bank check needs more, because a new account can end in the same four digits. Proposed: when Dave approves, the portal's server stores a **fingerprint** of the vendor's full account in the row. A fingerprint here is a one-way hash: a short code computed from the account's record, from which nobody can work the number back. At the payment, the connector computes it again and refuses if the two differ. No tool ever returns the full number.

Keys follow the same rule. For an agent that runs code, Anthropic advises a proxy "that injects the key into requests. The agent can make API calls, but it never sees the credential itself." The same guide says to "Avoid mounting sensitive host directories like `~/.ssh`, `~/.aws`, or `~/.config`", and lists `.env` among "Common files to exclude or sanitize before mounting".[^claude-agent-sdk-secure-deployment] The orchestrator runs no code for the model, so it needs none of the guide's four ways to isolate code: "Sandbox runtime", "Containers", "gVisor" and "Virtual machines".[^claude-agent-sdk-secure-deployment]

### Where can data still leave?

**Through any host you allowed, and through the worker's own reply.** A host list (23.7) closes every host not on it, and none of the hosts on it. Anthropic warns that "limiting the environment's hosts does not stop the agent from using a credential on a host you allowed."[^anthropic-managed-agents-risks] The Agent SDK's guide says the same of its proxy: "Within your proxy's allowlist, the agent can send data to any allowed domain. Allow only the domains the agent needs."[^claude-agent-sdk-secure-deployment]

No network rule covers the answer itself: "An agent can still put data it is allowed to read into its own reply or tool output."[^anthropic-managed-agents-risks] So the last guard against data leakage is the first one: data the worker never reads, it cannot leak. In Lab 28, Task 4, a test checks that the reply to the 9:20 note holds no full account number, and that the run made no outside request.

**The operating rule:** give each runtime only the tools its job needs, give each role the fewest scopes, and make each approval a row that no token can write. Keep full account numbers and keys where no tool returns them.

**Do this now.** Ask your coding agent to list who can reach what. Copy this line:

> List every tool the model can call in this project's orchestrator, and the scope the connector asks for each. Then list every role and the scopes it maps to. Mark each tool the job does not need, each role that holds a scope it never uses, and any way a tool could send data to a host other than the connector's. Change no file.

[^anthropic-mitigate-jailbreaks]: Mitigate jailbreaks and prompt injections, Anthropic.
[^claude-agent-sdk-permissions]: Configure permissions, Claude Agent SDK, Anthropic.
[^claude-code-permissions]: Configure permissions, Claude Code, Anthropic.
[^claude-code-prompt-caching]: How Claude Code uses prompt caching, Anthropic.
[^claude-agent-sdk-secure-deployment]: Securely deploying AI agents, Anthropic.
[^anthropic-managed-agents-risks]: Security risks and sandbox boundaries, Claude Managed Agents, Anthropic.
