The short answer. An email is untrusted input even when its transport is authenticated. Put authorization around the agent’s tools, bind actions to approved context and keep high-impact decisions outside the message.
Keep three trust decisions separate
An email from a familiar company asks your assistant to replace payment instructions. The sender's domain authenticates correctly. The message looks ordinary. Even then, transport authentication does not establish that the requested change is authorized for your customer, approved by your organization or appropriate for an automated action.
Separate origin, content and authority. Origin concerns where a message came from. Content analysis concerns what it contains and whether it looks suspicious. Authority concerns what a particular user or service is allowed to do. A model's confidence in a message cannot grant that authority.
This guide proposes a boundary for a Node application that reads inbound mail and prepares actions. It is a design review aid, not a security certification or a claim that a classifier can eliminate prompt injection.
Reduce the material that reaches the model
Preserve the original message in controlled storage if your retention policy requires it. Give the model a bounded representation with explicit fields for sender, subject, extracted text and attachment metadata. Avoid handing over a browser session, unrestricted filesystem or a credential merely to summarize an email.
Handle HTML and attachments as separate input surfaces. Remote images, linked documents and quoted threads can introduce additional content after the first message has been screened. Apply size limits, permitted formats and explicit fetching rules. A visible excerpt is easier to inspect than an agent that silently follows every link.
OWASP describes indirect prompt injection through externally supplied material. Treat instructions found in the message as part of that material. Labeling the content helps express the boundary, but enforcement must also exist in application code.
Make tool authorization deterministic
The model can propose an action object. A separate policy layer should resolve the authenticated user, tenant, permitted operation and destination from trusted application state. It then validates the proposal against those permissions. Never accept a model-supplied tenant identifier as proof that the model may act for that tenant.
// All arguments are loaded by trusted server code, not the model.
function canSendDraft(session, draft, approval, currentHash) {
return session.permissions.includes('mail:send-draft') &&
draft.tenantId === session.tenantId &&
session.allowedRecipients.includes(draft.to) &&
approval.status === 'approved' &&
approval.draftId === draft.id &&
approval.approvedBy === session.userId &&
approval.contentHash === currentHash;
}
This sketch demonstrates placement, not a complete authorization system. A real implementation must load approval from trusted storage and compute the content hash itself over the exact recipient, body and attachments. It must also enforce expiration and one-time use where the operation requires them. Otherwise, a draft can change after review while retaining a misleading approval flag.
Give each action a narrow envelope
Prefer tools with small, explicit capabilities: retrieve one authorized thread, create a draft, classify a message or send an approved draft. Avoid a single tool that accepts arbitrary network destinations, raw SQL or broad instructions. Validate inputs at the tool boundary even if the model already produced schema-shaped JSON.
Set limits on recipient count, attachment size, message volume and execution time. Separate read credentials from send credentials where the platform supports it. Re-check permissions when executing an action, because access may have changed since the agent started reasoning.
OWASP's agent guidance supports constrained permissions and controls around tool use. The specific envelope here is our proposed application design. Tune it to the workflow: generating a support draft and changing bank details should not share the same approval policy.
Place Oveyon at the transport boundary
Oveyon is a related commercial product. Its site describes inbound email with safety verdicts, signed webhook delivery and scoped API or MCP access. Those capabilities can supply transport and screening signals to a Node application; they do not replace the application's authorization decisions.
A practical architecture receives and verifies the inbound event, stores a bounded work item, evaluates policy, and only then asks the model to summarize or propose a draft. Content flagged for review stays in a review path. Even content classified as clean remains external input and cannot approve its own requested action.
Keep the integration behind a small adapter so business policy does not depend on prose from the model or on a product-specific label. Read the current integration documentation and inspect the related service at Oveyon.
Make review and recovery practical
Show a reviewer the proposed action, exact destination, material changes and reason it needs approval. An “approve everything” screen creates friction without a meaningful decision. Keep a useful audit trail of policy version, action ID, approval identity and result, while excluding secrets and unnecessary private content.
Test a message that asks to reveal a secret, one that requests a new recipient, and one that embeds instructions in an attachment. Include harmless messages containing similar words so you can observe false positives. Also test permission revocation between draft creation and send, and edits made after approval.
When a tool call fails, do not let a general-purpose agent improvise a more privileged route. Return a structured failure and preserve the draft or job for review. The desired result is an understandable boundary: the agent can help interpret the message while the application remains responsible for deciding what may happen next.
Primary sources
Consult the current documentation when implementing. Links checked during preparation of this edition.