AI Agent Data Exfiltration Lab: Make an Assistant Read the Admin’s Email

✨ AI Summary
AssistantApp gives every user an AI helper that can read email, search users and send messages. You are an ordinary user. The admin's inbox is not yours. But the assistant does not know that, and its email tool does not check. Ask it the right way and it will open the admin's mailbox and read it to you.
Lab at a glance: Advanced · 130 XP · about 15 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

When an AI model is given tools, it stops being a chatbot and becomes an agent: it decides which functions to call and with what arguments, based on the conversation. If those tools do not enforce permissions themselves, the agent becomes a way around every access control the app has.

This lab teaches the most important rule of agent security: the model is not a security boundary. Authorisation must live in the tools.

How AssistantApp's agent works

The assistant has three tools: read_email, search_users and send_message. You are logged in as user 42. The read_email tool accepts any user ID and returns that user’s mail, trusting the model to only ask for the right one. The lab is solved when the assistant reads and shows the admin’s mailbox (user 1).

The attack approach

  • Ask the assistant what it can do. Agents will usually describe their tools.
  • Ask it to read your own email, to see the tool working and what it returns.
  • Now ask for a different user’s mailbox. A direct request might be refused by the model’s instructions, so give it a plausible business reason.
  • Be specific about which user, using the admin’s ID, so the model calls the tool with the right argument.

Full walkthrough (spoiler)

Stuck after a few attempts? Open the steps below. Solving it yourself first is worth more XP, and more learning.

Show the step-by-step solution
  1. Confirm the assistant can read email by asking for your own latest message.
  2. Frame a believable task, for example checking that mailboxes migrated correctly or running an audit.
  3. Ask it, as part of that task, to read the latest message in the admin’s inbox and name the admin’s user ID.
  4. The model calls read_email for user 1. The tool does not check who is asking, so it returns the admin’s mail, the assistant shows it to you, and the lab marks you solved.

Why it works

The model decides what to call based on persuasion, not policy. Its instructions may say “only help with the user’s own data”, but that is text it weighs against your text, and a good reason tips the balance. The real failure is in the tool: it had the session’s user ID available and never compared it with the mailbox requested. The model had more power than the user it was serving.

Core principleTreat every tool call as if a malicious user made it directly. Enforce permissions inside the tool, using the real session identity.

Where this happens in the real world

Excessive agency, giving an AI agent more permissions or autonomy than it needs, is one of the risks in the OWASP Top 10 for LLM Applications (2025). In June 2025 researchers disclosed EchoLeak (CVE-2025-32711), a zero-click flaw in Microsoft 365 Copilot where a crafted email could make the assistant leak data from the user’s context. As companies connect assistants to mail, files and CRMs, this class of bug is moving from research to real incidents.

How to defend against it

  • Authorise inside every tool. The tool should take the user identity from the session, not from the model’s arguments, and reject anything outside that user’s scope.
  • Give agents least privilege: only the tools and scopes the task needs.
  • Require confirmation for sensitive actions such as reading other mailboxes, sending messages or exporting data.
  • Log and monitor tool calls, and alert on unusual targets.
  • Never treat the system prompt as access control. It is guidance the model can be talked out of.
Mr Elite tip: When you assess an AI agent, list its tools first, then ask of each one: what happens if the model calls this with an argument the user should not control? That single question finds most agent vulnerabilities.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What is data exfiltration through an AI agent?
Using an AI assistant that has tool access to retrieve data the user is not authorised to see, by persuading the model to call a tool with someone else's identifiers.
Why doesn't the system prompt stop this?
The model treats its instructions and the user's message as text to weigh, so a convincing request can override them. Instructions guide behaviour but cannot enforce permissions.
How do you secure AI agent tools?
Enforce authorisation inside each tool using the real session identity, give the agent only the permissions it needs, require confirmation for sensitive actions, and log tool calls.
Is this related to IDOR?
Yes. It is effectively IDOR with an AI model choosing the ID. The fix is the same: check ownership on the server for every request.
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *