Authentication and Access Control for Agent Systems
Principles (verified, from Anthropic's secure deployment guide)
Agents generate actions dynamically and can be influenced by content they process (prompt injection). So:
- Security boundaries: keep sensitive resources (credentials) outside the boundary containing the agent. Example: a proxy outside the agent's environment injects the API key into requests; the agent can call the API but never sees the credential. Valuable for multi-tenant systems and untrusted content.
- Least privilege: mount only needed directories (prefer read-only); restrict network to specific endpoints via a proxy; inject credentials via proxy; drop Linux capabilities in containers.
- Defense in depth: container isolation, network restrictions, filesystem controls and request validation at a proxy, combined to fit your threat model.
- A command permission gate is not a sandbox; sandbox mode restricts filesystem and network access for Bash commands (verified).
Permission rules
- Rule types: allow, ask, deny. Evaluated in order deny, then ask, then allow; the first match wins and specificity does not change the order. A broad
denysuch asBash(aws *)blocks calls even if a narrower allow exists. - A deny rule that is a bare tool name removes the tool from Claude's context entirely; a scoped rule (
Bash(rm *)) leaves the tool and blocks matching calls. - Hooks:
PreToolUsedecisions followdeny>defer>ask>allow(Domain 1.5). - Managed settings let an organisation enforce policy: lists combine, "locks" apply the strictest value, restriction allowlists take the list from the highest-ranked source; a managed file can make Claude Code ignore permission rules from user, project and local files and
--allowedTools(verified). - Permission modes range from
defaulttodontAsk(deny anything that would prompt; good for locked-down CI) tobypassPermissions(isolated containers and VMs only) (verified).
Identity and secrets (verified plus design guidance)
- Prefer short-lived, scoped credentials. In GitHub Actions, workload identity federation exchanges the workflow's OIDC token for API access so no long-lived secret is stored; otherwise store keys as repository or organisation secrets and never commit them (verified).
- Use separate identities per agent or service so activity can be attributed and revoked independently; the API platform provides organisation, workspace and service-account administration (existence verified; consult the admin docs for details).
- MCP remote servers authenticate with OAuth; tokens are stored securely and refreshed;
headersHelpercan supply headers at connection time (verified). ${VAR}expansion keeps secrets out of.mcp.json(verified).
Access control for what agents can reach (design guidance)
- Enforce the caller's permissions on data the agent retrieves (do not let an agent read what the requesting user cannot).
- Gate write and irreversible actions behind approval (D5.1).
- Audit every tool call (hooks, logs, telemetry) (D3.4).
Exam traps
- Giving the agent the API key instead of a proxy.
- Assuming an allow rule can override a deny rule.
bypassPermissionsoutside an isolated environment.- Long-lived shared credentials across agents.
- Treating the permission gate as a sandbox.
References
- Securely deploying AI agents — checked Oct 16, 2026
- Permissions — checked Oct 16, 2026
- Managed settings — checked Oct 16, 2026
- Claude Code GitHub Actions — checked Oct 16, 2026
- MCP in Claude Code — checked Oct 16, 2026
Check your understanding
Order of evaluation among allow, ask, deny rules?Show answerHide answer
Answer
Deny, then ask, then allow; first match wins.How can an agent call an API without ever seeing the key?Show answerHide answer
Answer
A proxy outside its environment injects the credential.How does GitHub Actions avoid storing a long-lived secret?Show answerHide answer
Answer
Workload identity federation (OIDC token exchange).