When an email tries to give your AI agent orders

A reply draft and a file transfer are two different actions. A small Python example shows how to enforce the difference.

You ask an AI agent to read a supplier’s email and draft a reply. The email contains a normal delivery update and an extra sentence asking the agent to send your customer list somewhere else. The sentence looks like an instruction to the model because it uses the same kind of language as your request. The software still knows where it came from.

That is indirect prompt injection. Someone puts instructions inside material the agent is meant to read, hoping the agent will act on those instructions. The important question is who authorized the action. The sender can tell you when the shipment arrives. Only you can authorize sharing the customer list.

Follow the two requests

SourceWhat it asks forWhat the agent is allowed to do
YouDraft a reply to the supplierCreate a draft for the supplier with no attachments
The emailSend a customer file to a new addressKeep the request as email text

An agent typically asks an application to run a tool when it wants to act. A tool request describes a proposed operation. The application can compare the operation, recipient and attachment against the permission it saved from the user. That check still runs if the model misreads the email and proposes the wrong operation.

Put the check in the application

This sample uses made-up addresses and file names. The tuples represent proposed tool calls. The only permission allows a reply draft to the supplier with an empty attachment list. The function returns a decision and never contacts an email service.

approved = {("create_draft", "[email protected]", ())}

def check(proposal):
    return "allowed" if proposal in approved else "blocked"

normal = ("create_draft", "[email protected]", ())
forward = ("send_email", "[email protected]", ("customers.csv",))
attachment = ("create_draft", "[email protected]", ("customers.csv",))

print("Normal reply draft:", check(normal))
print("Forward customer file:", check(forward))
print("Add customer file to draft:", check(attachment))
Normal reply draft: allowed
Forward customer file: blocked
Add customer file to draft: blocked

The third case is the easy one to miss. The recipient and the operation both match, but the agent slipped in an attachment the user never approved. Checking the complete request catches that change. In a real application, use a trusted record of the user’s permission and validate the action against it before calling the email service.

For an agent that only drafts replies, a separate draft tool makes the permission easier to enforce. If you add a send tool later, show the exact recipient, message and attachments for approval, then send those approved values. Test cases where an email asks the agent to change just one of them.

OpenAI’s overview of prompt injection · NIST’s analysis of agent hijacking