Next up World Congress Europe 14–16 Jul 2027 · Berlin Find out more
MA
Mohamed Abo Elkheir
DC
Daniel Cranney

Are AI Agents the Ultimate Confused Deputy? How AI Agents' Capabilities Are Being Abused

November 30, 2026
A puppeteer controls a number of laptops on strings
A puppeteer controls a number of laptops on strings

AI agents are unlocking seemingly unlimited new use cases, so it shouldn’t be a surprise that everyone is racing to build AI agents right now. And with adoption skyrocketing, AI agents are gaining unprecedented capabilities, including access to private data and APIs to perform privileged actions, making them more and more powerful.

Of course, the very capabilities that make them powerful also introduce new security risks and challenges. And in today’s post, we discuss one of these risks. Specifically, how AI agents could be tricked into abusing the permissions and the capabilities assigned to them, aka the “Confused Deputy” problem, which is an old security issue that has now been given new dimensions with the rise of AI agents, as I am going to illustrate shortly.

We will go through some real-world vulnerabilities to understand the patterns and root causes behind the AI agents’ “confused deputy” problem, and we will also discuss a mental model to understand the problem and mitigate it when designing and implementing new agents.

The “Confused Deputy”

Imagine a user has access to a specific Service / API, but the role assigned to this user doesn’t grant it permission to access specific data or perform a specific action. Now imagine if this user had access to another intermediate Service / API that does have this permission. This intermediate Service / API can be considered a “Confused Deputy” if the user can abuse it to access the data or perform the action that shouldn’t be authorized.

The “Confused Deputy”

Let’s take a real-world example: multiple AWS services, including AWS CloudTrail, were affected by a “Confused Deputy” vulnerability (described in detail here), which allowed a user to write their Cloudtrail logs to an S3 bucket they don’t have access to by passing this bucket to the Cloudtrail service as the destination to write the logs to. Let’s break it down:

  1. The user doesn’t have write access to an S3 bucket in a different account.
  2. The user onboards to the CloudTrail service in their AWS account.
  3. The user specifies the target bucket as the destination to write the CloudTrail logs to.
  4. CloudTrail service generates the logs and tries to write to the target bucket.
  5. While the target bucket policy doesn’t allow the original user to write to it, in many cases, it could be configured to allow the CloudTail Service Principal to write (e.g. if this bucket is also being used for CloudTrail logs in the target account).
  6. The CloudTrail logs of the user account are written to the target S3 bucket.
  7. In this case, the CloudTrail Service Principal is acting as a “Confused Deputy”.

AWS CloudTrail as a “Confused Deputy”

The “Confused AI Agent”

Now that we understand the “Confused Deputy” problem, let’s imagine that instead of a classic non-AI service (e.g. AWS Cloudtrail), we have an AI agent, and let’s explore the dimensions this adds to the problem.

The “Confused AI Agent”

One main difference is that for classic non-AI services, the logic is hard-coded in the application, which means that for “Confused Deputy” to have any impact, there should be an existing hard-coded relation between an entry point (user input, e.g. the S3 bucket ARN) and a permission to perform a capability (e.g. write logs to S3 bucket). E.g. The AWS CloudTrail Service has many permissions assigned (some more impactful than writing to a bucket), but it was only possible to exploit the “writing to bucket” permission as the S3 bucket ARN came from direct user input.

However, for AI agents, the logic isn’t hard-coded; it is fluid and dynamic as it depends on the input, task, prompts, and environment. This created very interesting relations between the entry points (input) and the capabilities assigned to the AI agent, and these relations make “Confused Deputy” for AI agents much more likely and much more impactful (as we are going to see in the upcoming examples).

AI Agents have “fluid” logic which creates interesting relations between entry points and capabilities

AI Agent Confused Deputy Examples

Example #1: SnippetsAI

Note: you can find the full code for this example application here, including instructions on how to setup and use. Check it out if you want to try it yourself.

Let’s start with a simple example. Imagine that we are building the backend for a new website where users can share their cool code snippets (e.g. a simpler version of Codepen), and let’s say that by default, when a snippet is created it is public, but users can choose to make it private. We start with the typical Create, List, Read, Update, and Delete operations, and now the website is working and starts to attract an audience.

Now, with many users hosting their code snippets on the website, it is becoming harder to find the snippets users are looking for, so we want to make it easier for users to find the relevant code snippets by using normal language (e.g. give me a code snippet in Python that converts markdown to HTML), which is a use case AI can help us with.

We add an “AI Search Agent” to our website to make it easier to find code snippets

So we add an AI agent accessible through a new route in our backend that works as shown below:

  1. Takes user query in normal language.
  2. Reads the snippets from the database.
  3. Passes the query and the snippets to AI, and asks it to only show the ones relevant to the query.

Here’s a simple implementation for this logic.

AI Agent implementation

Now, let’s compare the permissions of this AI agent to those of the user calling it. The AI agent, as shown above, has access to ALL snippets in the DB; however, the user only has access to the snippets that are public or private but owned by the same user. This discrepancy in permissions means that our implementation of the AI agent makes it a “Confused Deputy”.

AI Search Agent” is a “Confused Deputy

We can easily confirm that by creating a private code snippet as User A.

User A create a private snippet

Then, as User B (any different user that shouldn’t have access to the private snippet), we try to access the private snippet through the AI agent, which will be successful as shown below.

User B is able to abuse the AI agent to access the private snipprt

Example #2: AI Enterprise Search

Let’s move to another example. Many organizations have started using AI for Enterprise Search solutions, where they hook up AI to their internal sources and systems (e.g. Slack, Google Drive, .. etc) to search, summarize, and answer questions based on the data in these data sources and systems.

AI Internal Search Agent

This type of use case has become significantly easier now with MCP. So we can create a Slack app to access our Slack org, give it the needed permissions to read messages, and access it from the AI agent using Slack’s MCP server. By default, this will only have access to public Slack channels, but as users start using our agent, they could add the app to other private channels to use it on the messages there, and as long as the app has the right permissions, it will be able to search and read the messages from these private channels.

This again could create a “Confused Deputy” situation, as without proper validation, any user with access to the AI agent can use it to expose information in these private Slack channels, even if they aren’t members of these private channels themselves. And this isn’t only true for Slack; any other integration that follows the same pattern could be affected by this.

The AI Agent could expose private data the user isn’t authorized to access

Example #3: GitHub MCP Vulnerability

Now let’s move on to another example. This time, a real-world vulnerability fully described on InvariantLabs blog here. To summarize, this is a potential vulnerability that could affect any AI agent using GitHub’s MCP with full permissions over a GitHub org with both public and private repos, as shown below.

AI Agent using GitHub’s MCP to manage an org

In this case, let’s say the direct users authorized to use the AI agent have admin permissions over the GitHub org, same as the AI agent. So, it would appear in this case that this is not a “Confused Deputy” situation. However, this is not the full picture, because besides the direct users interacting with the AI agent, the AI agent takes indirect input from other places, and uses this input to build prompts, and this indirect input could still be used to trick the agent into abusing its permissions through prompt injection (more details about prompt injection in my previous blog post) if users that aren’t GitHub admins have control over this indirect input.

And this was the exact pattern this vulnerability followed. The vulnerability was exploitable in this case through public repo issue descriptions (which anyone could create). The attack went this way:

1. The attacker created an issue on one of the public repos with a prompt injection payload, such as this one:

prompt injection payload in a GitHub issue description

2. An authorized user reaches out to the AI agent, asking for a task that needs the issue description to be read and processed. e.g. Have a look at the issues in my public-repo xyz, and suggest a fix for each.

3. Once the AI agent reads the issue description and uses it for the subsequent prompt, the instructions in the description will trick it into reading from the private repos and exfiltrating the output to another public repo controlled by the attacker.

“Confused” through indirect prompt injection

This example is a bit different from the previous two, because in this case, the AI agent is being confused not through the direct prompt, but indirectly through input it is reading and using to build a prompt (e.g. public repo issue description), and this takes us back to what we discussed earlier about AI agents having fluid logic that created very interesting and unexpected relations between entry points and capabilities. In a classic (non-AI) system, it is very unlikely that there would be a relation between the issue description and reading from private repos, but as we know now, in AI agents, this is possible.

More and More Examples

To illustrate that this type of vulnerability is becoming a recurring pattern for AI agents, let me share a few more real-world vulnerabilities that follow the same pattern.

VS Code Co-pilot’s RCE (CVE-2025–53773):

You can find the full write-up here. To summarize, this vulnerability affected VS Code’s Co-pilot (Coding agent). It also used indirect prompt injection in a comment in a code file (as shown below) to trick Co-pilot to change its own settings to not require approval before running a command, and then run any command specified in the prompt injection payload.

Prompt injection payload in a comment in a code file leading to run the command “calc”

Co-pilot “Confused” through indirect prompt injection

Comet Prompt Injection:

You can find the full write-up here. To summarize, this vulnerability affected Comet (an agentic browser) also through indirect prompt injection in a comment in a public web-page (e.g. Reddit page) it was asked to summarize, which tricked the agent into exposing the credentials of the user logged in, as shown below.

Comet exposing the logged-in user's credentials via indirect prompt injection

Supabase MCP leak:

You can find the full write-up here. To summarize, AI agents using the MCP server of Supabase (a PostgreSQL development platform) could be tricked into exposing internal database data (e.g. credentials stored in the integrations db) through indirect prompt injection in case descriptions.

Prompt injection in case description

Supabase MCP “Confused” into exposing creds in internal db

Mitigations

Now that we have established how prevalent “Confused Deputy” vulnerabilities are in AI agents. Let’s discuss what we can do about it.

1. Understand when “Confused Deputy” is relevant

Understanding whether a problem is relevant to what you are building is the first step towards solving this problem. That is why it is really important when designing (or threat modeling) an AI agent to have a mental model to help determine whether “Confused Deputy” issues are relevant to your design.

The best way to do that is to document three things:

  1. The permissions/capabilities that the AI agent needs for the tasks it is built to perform.
  2. The direct users of the AI agent, how they will be authenticated and authorized, and what permissions they are expected to already have.
  3. The entry points: That is the list of anything the agent could use to build a prompt that will be sent to the AI service (e.g. this includes GitHub Issue descriptions, Code files, Web page content in the examples we discussed earlier), and for each of these resources we need to know what kind of users are allowed to create/edit them, and what permissions they are expected to have.

Once these 3 lists are ready, compare the agents’ permissions to the permissions of both direct users and indirect users (users that can create/modify entry points). If the agent has permissions that either type of users doesn’t have, then “Confused Deputy” is relevant, and you will need to plan for mitigating it using one of the techniques we are going to discuss shortly.

Compare Agent permissions to direct user and indirect user permissions

E.g., if your agent only has the permission to search the public internet and summarize results, “Confused Deputy” is not relevant, as direct and indirect users are expected to have this permission already. However, if your agent has the permission to access private resources and uses publicly editable resources to build prompts, then “Confused Deputy” is relevant.

2. Least Privilege Principle

The simple rule is: Permissions you don’t have can’t be abused. E.g. In Example#3, if the AI Agent using GitHub’s MCP didn’t have access to any private repos, the attack described above wouldn’t have been possible. Hence, it is really important to find out the minimum amount of permissions the agent needs to perform its tasks, and only assign these permissions.

3. Limit the scope of the AI Agent

Realistically, it is very hard to abide by the “Least Privilege Principle” if the scope of the AI agent is too wide. An AI agent built to have extensive capabilities and perform many tasks will end up needing extensive permissions that can’t be scoped down, and will be more susceptible to “Confused Deputy” situations.

That is why security-wise, it is better to build multiple AI agents, each with a limited scope (1 or 2 tasks), rather than one very powerful agent. e.g. an AI agent built just to list the issue and suggest fixes on public repos, and a different one for the private repo wouldn’t have been affected by the GitHub MCP issue above.

4. Give the AI Agent the same permissions as the caller

The best way to mitigate “Confused Deputy” for the direct users of the AI agent is to make the agent assume the same permissions as the user or less. One way to do that, if the AI agent uses an MCP server that supports OAuth, is to use OAuth for authentication, as this generates user-scoped tokens that impersonate the user calling the AI Agent. E.g., If we use OAuth for the Slack MCP server in Example#2 above, the agent wouldn’t have access to any private channels the user isn’t a member of.

MCP server with OAuth to generate user-scoped tokens

Otherwise, you can just apply the same authorization applied to the user within the logic of the agent itself. E.g. In Example#1 above, we could only pass the code snippets that are public or are owned by the caller to AI to make sure it can only see the same snippets the caller can see.

Only pass authorized code snippets to AI

5. Enumerate all entry points

As discussed in the previous story, Prompt injection can’t be prevented, but its impact can be minimized. Hence, it is really important to enumerate the list of all inputs that could be used to write a prompt, and understand who could create and edit these inputs. Then either remove the ones that are editable by low-privileged users, or give the AI agent the same amount of permissions.

6. Add Guardrails

If you can’t avoid resources editable by low-privileged users being used by your AI agent to build prompts (e.g. public GitHub issues), a last resort is adding guardrails between these resources and the dangerous capabilities of the agent. E.g., in Example#3, if the Agent was only allowed to access one repo per task (no cross-repo access), it would mitigate the described attack.

If possible, the guardrails should be added directly to the configuration of the AI agent, but if not, there are tools that can help, such as:

  • InvariantLabs: This acts as a proxy between your application and the AI service, and can apply guardrails on the requests being sent, e.g. the below rule prevents cross-repo access as described in the vulnerability blog post.

InvariantLabs guardrail to prevent cross-repo access

  • mcp-gateway: Similarly, this acts as a gateway to access your MCP servers, and you can add scripts through it to enforce your guardrails as described in detail here.

mcp-gateway guardrail to prevent cross-repo access

mcp-gateway guardrail to prevent cross-repo access

7. Human-in-the-Loop (HITL)

It is always a good idea to get a human’s permission before performing dangerous actions, so include that if possible. My only comment is that we shouldn’t over-rely on this control, as humans have the habit of approving without reading, especially if the agent starts to ask for too many approvals.

Conclusion

AI agents are exciting because they help us do more, faster. But that same power can be abused if we don’t plan for how these capabilities are being triggered. I hope this blog post leaves you with a mental model you can now use to understand “Confused Deputy” vulnerabilities in AI agents and be able to mitigate them when designing and implementing AI agents. Have a great day ahead!