CertSafari
    Anthropic Claude Certified Architect – Professional (CCAR-P) - December 7 onwards· Lessons

    Domain 3 · Lesson 14/39

    Agent credential exposure and privilege escalation

    Authentication and Authorization Posture

    16 min read
    2.63% of exam
    13 sources
    Published 18 Nov 2026
    Docs as of 18 Nov 2026

    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.

    Vault credential settings that narrow exposure, and what each one leaves open
    SettingSet it toWhat it still leaves open
    injection_location{"header": true, "body": false}, because request bodies are often built from content the agent readsCode can still use the key on every host the credential allows
    networking on the credentiallimited, with the exact hosts the key is for, avoiding wildcards and hosts that echo request headersIt does not open the host; the environment must also allow it
    The key's permissions, at the service that issued itOnly the permissions the agent needsNothing 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?

    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.

    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?

    Sources1234

    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 resource parameter, 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: Bearer header 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.
    An MCP server asking for one more scope for a single operation instead of granting broad access up fronthttp
    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?

    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?

    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?

    Sources4567

    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.

    Managed Agents permission policies and where each one belongs
    PolicyBehaviourUse it for
    always_allowRuns with no confirmation; the agent toolset defaultNever on a write, command or record-changing tool in an agent that reads untrusted input
    always_askPauses the session for your approval; the MCP toolset defaultTools whose changes you cannot undo outside the sandbox, or that relayed end-user text alone should not trigger
    autoThe server evaluates each call and runs it, denies it or pauses itTools 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?

    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)

    0 of 2 selected

    Sources89101112

    Sources

    (13)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 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. 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. 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. 5.
      “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. 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. 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. 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. 9.
      “Array of allowed tool names. If omitted, inherits every tool available to subagents”
      ↩︎ Privilege escalation through inherited permission modes
    10. 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. 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. 12.
      “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

    Ready to test yourself?

    Practise Anthropic Claude Certified Architect – Professional (CCAR-P) - December 7 onwards in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.