What you will be able to do
- Spot where an integration design puts a secret into the model's context, and move it to a client tool executor, a credential-injecting proxy or a vault placeholder
- Tell when a shared service account lets one user reach another user's data, and specify per-user delegated tokens with correct audience binding instead
- Trace how a permission mode or toolset default passes privilege to subagents and tools that read untrusted input, and specify the mode, tool list and approval gates that stop it
Key concept
The credential sets the blast radius — An agent can do anything its credentials and enabled tools allow, whatever its prompt says. You secure an integration by deciding which identity each call runs as and which permissions that identity holds. Both decisions are enforced outside the model.
1.Keep secrets out of the model's context
A secret the model can read is a secret the model can repeat. Suppose a design puts a partner API key in the system prompt and asks Claude to pass it as an api_key argument on every tool call. Then any text that can steer the model can also make it print the key: a retrieved web page, a support ticket, a tool result. Claude resists hidden instructions, but resisting them is not a guarantee. The design has to assume that some injection attempt will eventually work. Once one does, the only real protection is that the key was never in the context to begin with.
Client tools give you the place to add the secret. When Claude decides to call a tool you defined, it returns a structured tool_use block, and your application runs the operation. That executor is ordinary code with access to your secrets manager. It adds the key to the outbound partner request itself, and the tool's input schema never has a key field. Claude sees the tool interface: ship this parcel, look up this order. It never sees the credential behind it. The same rule applies to the patches that look safer but aren't. A base64-encoded copy of the key, a key wrapped in XML tags marked 'do not repeat', and a system-prompt instruction to withhold it all still leave the secret in the context. An output filter that scans for the key pattern misses encodings and partial leaks, and it only checks the final reply.
For agents that run code, the same idea moves into the network path. One option is a proxy outside the agent's container that validates requests, enforces a domain allowlist and adds credentials. Then the agent never holds the real value, the secret lives in one place instead of on every agent, and every request is logged for audit. Managed Agents vaults do this for you. In Managed Agents, the agent loop runs on Anthropic's servers while its bash and file tools run in a sandbox, which in a cloud environment is an isolated Linux container per session. The environment defines that sandbox, including its networking and the allowed hosts it can reach. A vault is the collection of credentials for one end user, and you pass its ID in vault_ids when you create a session. An environment-variable credential in a vault exists in the sandbox only as an opaque placeholder. The real secret is substituted at egress, only for the hosts the credential allows and only in the request locations it enables.
| Setting | Set it to | What it still leaves open |
|---|---|---|
| injection_location | {"header": true, "body": false}, because request bodies are often built from content the agent reads | Code can still use the key on every host the credential allows |
| networking on the credential | limited, with the exact hosts the key is for, avoiding wildcards and hosts that echo request headers | It does not open the host; the environment must also allow it |
| The key's permissions, at the service that issued it | Only the permissions the agent needs | Nothing narrower: the agent can do anything the key allows |
Placeholder substitution works only on outbound requests, and two consequences follow. First, a client that uses the stored secret to fetch a session token, as in an OAuth client-credentials grant, gets that token back into the sandbox unredacted. For exchange-based flows, do the exchange yourself and store the resulting token in the vault. Second, limiting the environment's allowed hosts does not stop the agent from using a credential on a host you did allow. Host lists and key permissions are separate controls, and you need both.
Checkpoint 1 of 8· Check yourself
A design puts a partner API key in the system prompt and has Claude pass it as an api_key argument on each tool call. Retrieved web pages and support tickets also go into the context. Which change actually removes the risk that an injected instruction gets the key printed?
Only the executor approach keeps the secret out of the model's context. Claude sees only the tool interface, and your application code adds the key. Encoding, tags, instructions, output filters and the model's own resistance all leave the key somewhere an injection can reach it.
“Credentials stay outside: The agent only sees the tool interface, not the underlying credentials”Source: code.claude.com
Checkpoint 2 of 8· Match them up
Match each control on a vaulted environment-variable credential to what it limits
Tap a term, then the definition that fits it.
The three controls are separate and none replaces another. Headers-only injection and an exact host list narrow where the secret goes. Only the service that issued the key can limit what the key is allowed to do.
“allowed_hosts scopes which hosts the secret is substituted for, and injection_location scopes which parts of the request it is substituted into.”Source: platform.claude.com
Checkpoint 3 of 8· Exam question
An agent built on the Messages API calls a partner shipping API. Developers placed the partner API key in the system prompt so Claude can pass it as an api_key argument in each tool call. A pen test extracted the key through a prompt injection hidden in a retrieved web page. How should the architect redesign credential handling?
Correct answer: A — Keep the key in a secrets manager, have the client-side tool executor add it to the partner request, and remove the key field from the tool schema.
- A. Correct: the secret is attached by deterministic code outside the model, so it never enters Claude's context. A prompt injection in a retrieved page has nothing to extract and cannot make Claude pass or reveal the value.
- B. Incorrect: the key is still in the model's context, only in a different turn. XML tags and an instruction not to repeat the block are not an access boundary, so an injected page can still get Claude to output it.
- C. Incorrect: base64 is an encoding, not protection. Claude can decode it, and since Claude must pass the value as the argument, an injection can have it emit the encoded or decoded key. The secret remains in context.
- D. Incorrect: the key is still loaded into the prompt, and an instruction plus pattern filtering are prompt-level controls with gaps, such as split, reformatted or encoded output. An injection can still reach the value, which is the failure the pen test exposed.
2.Shared service accounts versus per-user delegated tokens
A shared service account turns every user into its most privileged user. Take an MCP server that calls an HR API with one account that can read every employee record. To the HR system, every request comes from that one account, so the HR system cannot apply any one employee's access rights. Whatever a user can talk the agent into requesting, the account will fetch. None of the obvious patches change this. A per-user department list in the system prompt depends on the model choosing to refuse. Rotating the secret daily changes the secret, not the identity using it. Read-only scopes and a fixed redaction list still let any user read any record the account can read.
The fix is to carry the user's own identity through to the system that holds the data. With MCP OAuth authorization, each user grants a delegated token. The downstream system then receives that user's authorization and applies that user's rights, so a request for another department's records fails at the HR API, not in the prompt. Managed Agents uses the same per-user model: a vault is the collection of credentials for one end user, and you pass the vault reference when you create each session. That way you never lose track of which user an agent acted for.
Delegated tokens bring their own failure: tokens accepted by the wrong service. An MCP server must check that each token presented to it was issued specifically for it. A server that skips this check might accept a token minted for some other service. If it also forwards that token unmodified to downstream services, you get token passthrough, a confused-deputy problem. The downstream API wrongly trusts the token as though the MCP server had validated it. The protocol closes this gap from both ends:
- The client sends a
resourceparameter, the canonical URI of the MCP server, in both the authorization request and the token request, so each token is bound to one audience. - The server rejects tokens that were not issued for its own use.
- Access tokens travel in the
Authorization: Bearerheader and never in the URI query string. Authorization endpoints are served over HTTPS, and redirect URIs are HTTPS or localhost. - Local stdio servers do not use this OAuth flow. They retrieve credentials from the environment, so the process environment is their exposure surface.
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope",
scope="files:write",
resource_metadata="https://mcp.example.com/.well-known/oauth-protected-resource",
error_description="File write permission required for this operation"Step-up challenges like this one let a token start narrow and grow only when an operation needs more. The client should retry with the new authorization only a few times, then treat the failure as permanent. One limit holds for both shared and delegated credentials: settings around the agent never narrow what a key itself permits. Scope every key down at the service that issued it.
Checkpoint 4 of 8· Check yourself
Users of an HR assistant can read other departments' employee records. Its MCP server calls the HR API through one service account that can read every record. Which change makes the HR API itself refuse a request for another department's records?
With a shared account, the HR API sees one identity that can read everything, so rotating, vaulting or narrowing that account changes nothing per user. A per-user delegated token passes the user's identity through, so the HR API applies that user's rights and rejects the request itself.
“A vault is the collection of credentials associated with an end user.”Source: platform.claude.com
Checkpoint 5 of 8· Check yourself
A design review finds an MCP server that accepts any bearer token its authorization server signed and forwards that token unchanged to downstream APIs. What closes this confused-deputy gap?
Token passthrough happens when a server accepts tokens meant for another service and forwards them. Binding each token to one audience with the resource parameter, and having the server reject tokens not issued for it, closes the gap at both ends. Narrower scopes don't fix the wrong audience, tokens must never go in the query string, and stdio is only for local servers.
“MCP servers MUST validate that tokens presented to them were specifically issued for their use”Source: modelcontextprotocol.io
Checkpoint 6 of 8· Exam question
An HR team exposes its employee system to a Claude Agent SDK agent through a remote MCP server. The server calls the HR API with one shared service account that can read every employee record. Employees from different departments use the agent, and a security review shows any user can prompt it into returning records they are not entitled to see. What should the architect specify?
Correct answer: A — Add MCP OAuth authorization so each user grants a delegated token, and call the HR API with that token so the HR system applies the user's own access rights.
- A. Correct: with MCP OAuth authorization, each user grants a delegated token and the HR API is called as that user. The HR system then decides what the caller may read, so the shared account with blanket read access no longer sits between users and the data.
- B. Incorrect: a system prompt rule is a probabilistic control inside the model, and the credential behind the tools can still read every record. The security review showed users can prompt the agent into returning other records, and a crafted or injected request can talk the model past the rule. Authorization has to be enforced outside the model.
- C. Incorrect: daily rotation limits how long a leaked secret stays valid, but every user still reaches the HR API through the same identity with access to all employee records. The over-privilege behind the review finding is unchanged.
- D. Incorrect: read-only scopes and a fixed redaction list do not separate one department's records from another's, and a static pattern list cannot express what an individual caller is entitled to. Every user still receives whatever the shared account can read, minus the redacted fields.
3.Privilege escalation through inherited permission modes
Privilege can also escalate without any credential leaking, through the approval settings that decide whether a tool call runs. A common pattern is an orchestrator set to bypassPermissions so that unattended jobs never stall on a prompt. If that orchestrator delegates to one subagent that reads untrusted web pages and another that runs deploy commands in Bash, the bypass setting does not stay at the top level.
The four modes differ in what they approve without a person. default prompts for anything no rule already allows. acceptEdits also auto-approves file edits and common filesystem commands such as mkdir and mv inside the working directories. auto has a background classifier check shell commands and network requests instead of a person. bypassPermissions skips permission prompts altogether. Subagents inherit a parent mode of bypassPermissions, acceptEdits or auto, whatever their own definitions say. So switching the orchestrator to acceptEdits only exchanges one inherited mode for another. Bypass also disables your own checks. Calls are approved before your canUseTool callback is consulted, so the callback runs for only a handful of calls. A deploy gate written in canUseTool therefore does nothing while the parent is in bypass.
Two changes close the path, and each one works on its own. The first is to run the orchestrator in default mode. List the read-only tools by name in allowedTools so those calls are approved without stalling, and leave Bash off that list so deploy calls reach canUseTool, where you can gate them. The second is to give the research subagent an explicit tools list that leaves out Bash and every write tool. If you omit tools, the subagent inherits every tool available to subagents. With the list in place, an injected page has no deploy tool to call, whichever mode is set. Choosing which tools each agent holds is a topic in its own right; see least-privilege tool configuration.
Some remedies only look like they help. A line in the research subagent's prompt telling it to ignore instructions inside fetched pages is still model behaviour, which is not a security control. Raising maxTurns just gives an injected instruction more turns in which to act. Detection and containment of injected content are covered in prompt injection controls. The architectural rule for authorization posture is this: no agent that reads untrusted input should hold a tool on automatic approval that writes files, runs commands or changes records.
| Policy | Behaviour | Use it for |
|---|---|---|
| always_allow | Runs with no confirmation; the agent toolset default | Never on a write, command or record-changing tool in an agent that reads untrusted input |
| always_ask | Pauses the session for your approval; the MCP toolset default | Tools whose changes you cannot undo outside the sandbox, or that relayed end-user text alone should not trigger |
| auto | The server evaluates each call and runs it, denies it or pauses it | Tools that only read data, plus bash, write, edit and web_fetch where their changes can be undone |
The defaults differ for a reason. MCP toolsets start on always_ask, so a tool newly added to a server cannot run without approval. The prebuilt agent toolset starts on always_allow. Under auto, there is one more escalation path to check. The server reads user.message content as your intent, so if your application relays untrusted end-user text in that field, the end user's words can get a call allowed. Put always_ask on every tool you would not let that end user run without review.
Checkpoint 7 of 8· Check yourself
Your Managed Agents support agent reads customer tickets and holds an MCP tool that issues refunds, which you cannot reverse outside the sandbox. Your application also relays each customer's chat text in user.message events. Which permission policy belongs on the refund tool?
A refund can't be undone outside the sandbox, and under auto the server treats relayed user.message text as your intent, so a customer's words could get a refund allowed. always_ask pauses the session for your review. MCP toolsets default to always_ask, not always_allow, and a prompt instruction is model behaviour, not a security control.
“If you relay untrusted end-user input in user.message events, the server reads that input as your intent too, and it can get a call allowed.”Source: platform.claude.com
Checkpoint 8 of 8· Exam question
A platform team runs a Claude Agent SDK orchestrator with permissionMode set to bypassPermissions so unattended jobs never stall on prompts. It delegates to a web-research subagent that reads untrusted pages and to a deploy subagent that runs Bash. A review notes that subagents inherit the bypass mode, so injected page content could trigger a deployment. Choose two mitigations.(Select 2)
Correct answers: A, C — Run the orchestrator in default permission mode, pre-approving read-only tools via allowedTools, gating deploys in canUseTool.; Define the research subagent with a restricted tools list that excludes Bash and write tools, so untrusted pages cannot reach them.
- A. Correct: leaving bypass mode removes the inherited blanket approval, and pre-approving a narrow tool set plus a programmatic gate on deploys keeps jobs unattended without granting everything.
- B. Incorrect: acceptEdits is also a permissive mode that subagents inherit, and it auto-approves file edits across the whole run. It narrows nothing for the research subagent.
- C. Correct: limiting the research subagent's tool set is a structural control, so even a successful injection has no Bash or write tool to call. It shrinks the blast radius of untrusted content.
- D. Incorrect: a prompt instruction is advisory and can be overridden by a well-crafted injection. It does not remove any capability from the subagent.
- E. Incorrect: more turns only lengthen the run and give an injection more chances to act. Turn limits are not an authorization control.
Sources
(13)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Claude is inherently resilient to it, but model behavior is not a security control.”
↩︎ Keep secrets out of the model's context“For example, limiting the environment’s hosts does not stop the agent from using a credential on a host you allowed.”
↩︎ Keep secrets out of the model's context“In a cloud environment, each session gets its own isolated Linux container”
↩︎ Keep secrets out of the model's context“Limit a key’s permissions at the service that issued it, because these settings do not limit them.”
↩︎ Exam trap 2 - 2.
“Your code runs the operation and sends back a tool_result.”
↩︎ Keep secrets out of the model's context“Client tools (including user-defined tools and tools with Anthropic-defined schemas, such as bash and text_editor) run in your application.”
↩︎ Exam trap 1 - 3.
“Credentials stay outside: The agent only sees the tool interface, not the underlying credentials”
↩︎ Keep secrets out of the model's context“Credentials are stored in one secure location rather than distributed to each agent”
↩︎ Keep secrets out of the model's context - 4.
“When the agent initiates an outbound request, the opaque placeholder is substituted with the real secret at egress.”
↩︎ Keep secrets out of the model's context“the returned token arrives in the sandbox unredacted”
↩︎ Keep secrets out of the model's context“A vault is the collection of credentials associated with an end user.”
↩︎ Keep secrets out of the model's context“A vault is the collection of credentials associated with an end user.”
↩︎ Shared service accounts versus per-user delegated tokens“or lose track of which end user an agent acted on behalf of”
↩︎ Shared service accounts versus per-user delegated tokens“allowed_hosts scopes which hosts the secret is substituted for, and injection_location scopes which parts of the request it is substituted into.”
↩︎ Checkpoint - 5.https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/security-considerationsOfficial docs
“MCP servers MUST validate that tokens presented to them were specifically issued for their use”
↩︎ Shared service accounts versus per-user delegated tokens“All redirect URIs MUST be either localhost or use HTTPS.”
↩︎ Shared service accounts versus per-user delegated tokens - 6.
“If the MCP server not only accepts tokens with incorrect audiences but also forwards these unmodified tokens to downstream services”
↩︎ Shared service accounts versus per-user delegated tokens“the downstream API may incorrectly trust the token as if it came from the MCP server”
↩︎ Shared service accounts versus per-user delegated tokens - 7.
“MUST identify the MCP server that the client intends to use the token with.”
↩︎ Shared service accounts versus per-user delegated tokens“Access tokens MUST NOT be included in the URI query string”
↩︎ Shared service accounts versus per-user delegated tokens“Implementations using an STDIO transport SHOULD NOT follow this specification, and instead retrieve credentials from the environment.”
↩︎ Shared service accounts versus per-user delegated tokens“Determine required scopes by computing the union of the client’s previously requested scope set and the scopes from the current challenge.”
↩︎ Prediction - 8.
“Tool calls are approved before canUseTool is consulted, so your callback runs for only a few calls”
↩︎ Privilege escalation through inherited permission modes“Calls to a listed tool are approved before canUseTool is consulted, apart from the calls an allow rule never approves.”
↩︎ Privilege escalation through inherited permission modes - 9.https://code.claude.com/docs/en/agent-sdk/pythonOfficial docs
“Array of allowed tool names. If omitted, inherits every tool available to subagents”
↩︎ Privilege escalation through inherited permission modes - 10.
“No agent that reads untrusted input has a tool on always_allow that writes files, runs commands, or changes records”
↩︎ Privilege escalation through inherited permission modes“The agent can do anything the key allows”
↩︎ Key concept - 11.
“If you relay untrusted end-user input in user.message events, the server reads that input as your intent too”
↩︎ Privilege escalation through inherited permission modes“Each toolset kind has its own default: the agent toolset defaults to always_allow, and MCP toolsets default to always_ask.”
↩︎ Exam trap 4“If you relay untrusted end-user input in user.message events, the server reads that input as your intent too, and it can get a call allowed.”
↩︎ Checkpoint - 12.https://code.claude.com/docs/en/settings-referenceOfficial docs
“Claude Code also runs file edits and common filesystem commands such as mkdir and mv without asking”
↩︎ Privilege escalation through inherited permission modes“Claude Code runs everything without asking”
↩︎ Privilege escalation through inherited permission modes
Also cited
- https://code.claude.com/docs/en/sub-agentsOfficial docs
“the subagent runs in that same mode and Claude Code ignores the permissionMode you set”
↩︎ Exam trap 3“the subagent runs in that same mode and Claude Code ignores the permissionMode you set”
↩︎ Prediction