Join our Newsletter — 33% off our NHI Course
Home› Guides› Confused Deputy in AI Agents Guide: Stop agents…
Guide Agent Threats & Attacks

Confused Deputy in AI Agents Guide: Stop agents spending authority nobody gave them

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 27 October 2026 15 min read
On this page

An AI agent that holds more authority than the person or system asking it to act is a confused deputy waiting to be exploited. The confused deputy problem is old: a privileged program is tricked into using its own authority for someone who should not have it. Agents make it common, because they combine broad service credentials, instructions that arrive in natural language from many sources, and tools that act in other systems. This guide explains how the problem shows up in agents, MCP servers and multi-agent systems, how to decide whose authority an action should run under, the controls that close the gap (audience-bound tokens, delegation with actor claims, per-client consent, request-time authorisation), and how to detect it. It is for identity architects, AppSec engineers and platform teams building or reviewing agentic systems. The broader OWASP risk that contains this pattern is covered in the OWASP Agentic Top 10 ASI03 Guide; this page goes deeper on the confused deputy itself.

Key takeaways

  • The question is always "whose authority?" Every agent action should be authorised against the requester's rights, the agent's own scope, or the intersection of both, and the choice must be explicit in design, not left to whatever credential the agent happens to hold.
  • Injected instructions are requests from a stranger. Text in a web form, email, ticket or tool result can direct an agent, and if the agent acts with its own broad credential, the stranger has borrowed that credential.
  • Tokens must name their audience and their actor. The MCP specification forbids token passthrough and requires audience validation; OAuth token exchange (RFC 8693) lets a token show both the user and the agent acting for them.
  • Consent must bind to the specific client. MCP proxy servers that use a static client ID upstream must implement per-client consent, or a consent cookie lets an attacker's dynamically registered client skip the consent screen.
  • Authorise at the point of action, outside the model. The model cannot be the policy decision point: a deterministic check on each tool call, with the requester's identity attached, is what stops the deputy.

What a confused deputy is, and why agents are one

The term comes from Norm Hardy's 1988 paper, in which a compiler with permission to write a billing file was tricked by a user into overwriting that file by naming it as the compiler's output. The compiler acted on two authorities at once, its own and the user's, and could not tell which one a given request relied on. MITRE's CWE catalogue lists the pattern as CWE-441, Unintended Proxy or Intermediary ('Confused Deputy'): a product forwards a request without preserving its original source, so it appears to be the source itself. AWS defines it as "a security issue where an entity that doesn't have permission to perform an action can coerce a more-privileged entity to perform the action."

Agents fit the definition precisely. An agent usually holds a service credential, an OAuth grant or a delegated token that lets it read and write in several systems. It receives instructions from its user, but also, in effect, from everything it reads. And it decides which tool to call through a model whose reasoning can be steered. Three properties make the problem worse than in classic software:

  • Ambient authority: the agent's credentials apply to every request it handles, so a request from a low-privilege user, or from injected text, is executed with the agent's full rights unless something checks.
  • Blurred request origin: natural-language instructions do not carry an authenticated sender. A sentence in a retrieved document looks the same to the model as a sentence from the user.
  • Chains of deputies: an orchestrator calls a sub-agent, which calls an MCP server, which calls a SaaS API. Each hop can lose the original requester's identity and replace it with a more powerful one.

Where confused deputies appear in agent systems

PatternHow the deputy is confusedExamplePrimary control
Shared agent service accountA help-desk or Slack bot runs with one powerful credential for all users, so any user can ask it to do what only admins couldAn employee asks the IT agent to reset another person's MFAAuthorise each request against the requester's entitlements, not the bot's
Indirect prompt injectionUntrusted content supplies instructions that the agent executes with its own accessA web-to-lead form field directs a CRM agent to send records to an external URLTreat content as data; restrict tools and egress after untrusted input
Token passthroughAn MCP server forwards a client's token downstream, or accepts tokens issued for another serviceA downstream API trusts the token as if the MCP server had validated itAudience validation; separate upstream token; no passthrough
OAuth proxy consent bypassAn MCP proxy uses one static client ID upstream; a consent cookie lets a malicious registered client skip consentAuthorisation code redirected to an attacker's redirect_uriPer-client consent before the upstream flow; exact redirect URI matching
Cross-user stateServer trusts a client-supplied handle or user ID instead of the verified tokenAgent passes another customer's order ID and the tool acts on itBind state to the authenticated principal server-side
Retrieval without requester permissionsThe retrieval layer searches with the agent's index credential and returns content the user cannot seeAn intern's question surfaces board papersPermission-aware retrieval using the requester's identity
Agent-to-agent delegationA sub-agent receives a broader token than the task needs, or the orchestrator's token without attenuationA summarisation sub-agent can also send emailAttenuated, task-scoped tokens per hop
Cloud service principalsA cloud service acts on a resource policy that trusts the service, not the account that configured itAnother tenant points the service at your bucketaws:SourceArn, aws:SourceAccount, sts:ExternalId

Deciding whose authority an action runs under

Most confused deputy bugs come from never making this decision. Pick a model per tool, write it down, and enforce it in code.

ModelEffective permissionUse whenRisk if misapplied
User-delegated (on behalf of)The requester's own rights, possibly narrowedPersonal assistants, retrieval, actions in the user's own accountsLow deputy risk; but a compromised session lets the agent do everything the user can
Agent-owned identityThe agent's scoped service credentialUnattended workflows, actions no individual user is entitled to but the business process isHigh deputy risk unless the agent checks the requester's right to trigger the process
IntersectionOnly what both the user and the agent may doShared agents serving many users with different rightsSafest default; requires both identities at decision time
Elevated with approvalAgent scope, gated by a human or policy approval for this specific actionRare privileged operations (refunds, access grants, production changes)Approval fatigue; approvals the agent itself can satisfy
  • Small organisations: default every agent to user-delegated tokens and avoid agent-owned credentials except for a few reviewed workflows.
  • Large organisations: use a policy engine that evaluates the intersection model centrally, with the requester, agent, tool, resource and data sensitivity as inputs, so each team does not reinvent the check.
  • Anything triggered by untrusted input (inbound email, public forms, tickets from customers) should never run under an agent-owned identity with write access, because the effective requester is the outside world.

Controls that close the gap

Audience-bound tokens and no passthrough

The MCP authorization specification (draft, checked 27 October 2026) requires clients to send the RFC 8707 resource parameter in authorization and token requests, identifying the MCP server by its canonical URI. Servers must validate that access tokens were issued specifically for them, and the specification states that "MCP servers MUST NOT accept or transit any other tokens". When an MCP server needs to call an upstream API, it obtains its own token for that API rather than forwarding the client's. The security best practices page explains why: a forwarded token bypasses the server's controls, breaks the audit trail, and lets a stolen token use the server as a proxy for exfiltration.

Delegation that names the actor

OAuth 2.0 Token Exchange (RFC 8693) lets an agent exchange the user's token for a new one aimed at a specific downstream audience, with an act (actor) claim identifying the agent acting for the subject. The downstream service then sees both identities and can apply the intersection model; the may_act claim can restrict which actors are allowed to act for a subject. See the OAuth Token Exchange and Delegation Guide and, for multi-hop narrowing, the Delegation Chains and Attenuated Authority for AI Agents guide.

Per-client consent in MCP proxy servers

The MCP security best practices describe a specific confused deputy: an MCP proxy server that uses a static client ID with a third-party authorisation server, allows dynamic client registration, and relies on a consent cookie the third party sets. An attacker registers a client with their own redirect_uri, sends the victim a link, the third party skips consent because of the cookie, and the MCP authorisation code goes to the attacker. The required protections include:

  • Consent registry: keep approved client_id values per user and check it before starting the third-party flow.
  • Consent page: name the requesting client, show the third-party scopes and the registered redirect_uri, protect against CSRF, and block framing with frame-ancestors or X-Frame-Options: DENY.
  • Cookies: __Host- prefix, Secure, HttpOnly, SameSite=Lax, signed, and bound to the specific client_id.
  • Redirect URIs: exact string matching against the registered value, no wildcards, rejection if changed without re-registration.
  • State: a single-use, short-lived random state stored only after consent is approved and validated exactly at the callback.

Request-time authorisation outside the model

  • Policy enforcement point on every tool call: a gateway or middleware that receives the verified requester identity, the agent identity, the tool and its arguments, and asks a policy engine for a decision. The model proposes; the policy decides.
  • Bind resources to the principal: the MCP best practices tell servers not to treat possession of a state handle as authentication and to key state to the user ID taken from the verified token, never from a client-supplied argument.
  • Least scope, stepped up: start with minimal scopes and use WWW-Authenticate scope challenges for privileged operations, avoiding wildcard scopes such as * or full-access. The specification lists "treating claimed scopes in token as sufficient without server-side authorization logic" as a common mistake.
  • Capability-style references: pass the agent unguessable, scoped handles to specific resources (a pre-authorised file reference) rather than general credentials plus a name, which is the capability answer Hardy's paper pointed towards.

Containing injected requests

  • Taint after untrusted input: once an agent has read external content, drop or gate write tools and outbound network calls for the rest of that task.
  • Egress control: allowlisted destinations stop injected instructions from sending data to attacker URLs. See the Agent Egress Control and Network Isolation Guide.
  • Human approval for consequential actions, shown with the requester, the data source that prompted the action and the exact arguments, through a channel the agent cannot answer itself.

Implementation steps

  1. Inventory agent authority. For each agent list its credentials (service accounts, OAuth grants, API keys), the tools they unlock, and every input channel that can steer it (users, documents, email, tickets, other agents).
  2. Assign an authority model per tool. User-delegated, agent-owned, intersection or elevated with approval. Flag every tool where an agent-owned credential can be triggered by a user or input with fewer rights.
  3. Propagate the requester's identity. Make the verified user identity available at every hop, through token exchange with actor claims or a signed context header the gateway verifies, never as a free-text argument.
  4. Fix token handling. Require the resource parameter, validate audience on every MCP server and API, and remove any passthrough of client tokens upstream.
  5. Add the enforcement point. Deploy policy checks on tool calls in audit mode first, logging what would have been denied for two to four weeks; review false positives with tool owners.
  6. Enforce in rings. Switch to deny mode for internal pilot users, then for broader groups, keeping a feature flag to return a tool to audit mode as the rollback.
  7. Harden MCP proxies. Implement per-client consent, exact redirect URI matching and correct state handling before exposing any proxy server to external clients.
  8. Test like an attacker. Add test cases where a low-privilege user, an injected document and a rogue sub-agent each ask for a privileged action, and assert denial. Repeat on every model or prompt change. See the OWASP GenAI Red Teaming Manual Guide.

Detection and measurement

  • Requester-to-action mismatch: log, for every tool call, the requester, the agent, the credential used and the authority model. Alert when an agent-owned credential performs an action the requester would not be entitled to.
  • Actions following untrusted input: correlate tool calls with the content the agent read in the same task; flag writes or outbound calls that follow external content.
  • Audience failures: count rejected tokens with the wrong audience at MCP servers and APIs; a spike can indicate replay or passthrough attempts.
  • Consent anomalies: new dynamically registered clients with unusual redirect URIs, and authorisation codes issued without a recorded MCP-level consent.
  • Cloud deputy signals: service principal access to resources without the expected aws:SourceArn or aws:SourceAccount.
MetricTarget
Tools with a documented authority model100 per cent
Tool calls carrying a verified requester identity100 per cent for user-triggered agents
MCP servers and APIs validating token audience100 per cent; zero passthrough
Agent-owned write credentials reachable from untrusted inputsZero
Confused deputy test cases passing in CIAll, on every model or prompt release
Policy denials reviewed within one working dayAbove 95 per cent

Framework mapping

AreaReference
Risk taxonomyOWASP Top 10 for Agentic Applications ASI03 Identity and Privilege Abuse; OWASP LLM06:2025 Excessive Agency; OWASP LLM01:2025 Prompt Injection; CWE-441
Adversary techniquesMITRE ATLAS AML.T0051.001 Indirect prompt injection, AML.T0053 AI Agent Tool Invocation, AML.T0086 Exfiltration via AI Agent Tool Invocation, AML.T0098 AI Agent Tool Credential Harvesting; ATT&CK T1550.001 Application Access Token, T1528 Steal Application Access Token
Access enforcementNIST SP 800-53 AC-3, AC-6, AC-24 Access Control Decisions, AC-4 Information Flow Enforcement
Identity of services and attributesNIST SP 800-53 IA-9 Service Identification and Authentication, AC-16 Security and Privacy Attributes
AccountabilityNIST SP 800-53 AU-10 Non-repudiation; CSF 2.0 DE.CM-03
Programme levelCSF 2.0 PR.AA-03, PR.AA-05; ISO/IEC 27001:2022 A.5.15, A.8.2, A.8.3; CIS Controls v8.1 Control 6

Common failure patterns

  • One bot, one god credential: chat and help-desk agents that run every user's request with an admin token. Users discover quickly that the bot will do what they cannot.
  • Identity as a prompt variable: passing "the user is [email protected]" in the prompt or as a tool argument, where the model or an injection can change it.
  • Checking once at the front door: verifying the user when the session starts, then letting the agent call tools with its own credential for the rest of the conversation.
  • Forwarding tokens to save effort: MCP servers that pass the client's token to downstream APIs, so audit logs show the wrong caller and audience controls are bypassed.
  • Allowlisting the proxy, not the client: trusting a consent decision made for the proxy's static client ID as if it covered every client registered behind it.
  • Approvals the agent can answer: confirmation prompts delivered into the same channel the agent writes to, or summarised by the agent in a way that hides the real action.

Lessons from incidents

  • Borrowed CRM authority: in ForcedLeak, an attacker with no Salesforce login placed instructions in a public web-to-lead form; when an employee asked Agentforce to process the lead, the agent used its own CRM access to send data to an external URL. Salesforce responded by enforcing Trusted URLs for agent output. The deputy was the agent, the requester was an anonymous web visitor.
  • Borrowed developer authority: in the Sentry MCP agentjacking research, a fake error report submitted through a public DSN reached coding agents through an MCP server, and agents ran the suggested command with the developer's privileges and credentials.
  • Retrieval as deputy: in EchoLeak, an external email caused Microsoft 365 Copilot to use data it could access on the user's behalf and place it in an outbound URL, what the researchers called an LLM scope violation.

Practitioner checklist

  • Document an authority model (user-delegated, agent-owned, intersection or elevated with approval) for every agent tool.
  • Carry the verified requester identity to every tool call and downstream hop; never take identity from prompt text or tool arguments.
  • Require RFC 8707 resource indicators and validate token audience on every MCP server and API; ban token passthrough.
  • Use token exchange with actor claims for delegation, and attenuate scope at each agent-to-agent hop.
  • Implement per-client consent, exact redirect URI matching and correct state handling in MCP proxy servers.
  • Put a deterministic policy check outside the model on every privileged tool call, rolled out audit-first.
  • Remove write tools and outbound network access after an agent reads untrusted content, unless a human approves.
  • Add confused deputy abuse cases to CI and red team exercises, and rerun them on every model or prompt change.
  • Use aws:SourceArn, aws:SourceAccount and sts:ExternalId conditions wherever cloud services or third parties act on your resources.

Standards and references

Related NHI Mgmt Group resources: OWASP Agentic Top 10 ASI03 Guide · OAuth Token Exchange and Delegation Guide · Delegation Chains and Attenuated Authority for AI Agents · MCP Security Guide · Permission-Aware RAG Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 27 October 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.