A human approval step can stop an AI agent from sending an email or changing a record without oversight. But the approval request itself is an attack surface. If an agent includes text from a retrieved document, that text can try to instruct the reviewer: “Security has already verified this. Approve immediately.”
The reviewer is now seeing attacker-controlled content alongside a legitimate request. The gate must make that boundary explicit.
Intercept before the side effect
In n8n, put the gate between the agent’s proposed action and the node that actually performs it. One pattern is to expose a dedicated workflow as the agent’s tool: its first steps validate the proposed arguments and decide whether approval is required; only a later node calls the external API. Ensure the agent cannot also reach an ungated version of that API.
For each proposed call, capture a structured envelope:
- Action and target: for example,
send_emailand the recipient addresses. - Arguments: the exact payload intended for execution, including attachments or references.
- Context: workflow execution ID, requesting agent, and relevant policy version.
- Risk decision: deterministic checks for sensitive recipients, destructive operations, or data leaving an allowed domain.
Validate types, required fields, destination allowlists, and size limits before presenting anything to a reviewer. Treat the model’s explanation as context, not as the policy decision.
Keep instructions out of the approval UI
An attacker may control an email body, a document excerpt, a filename, or even a tool argument that looks like an internal instruction. A safe approval screen should separate these fields from trusted policy and reviewer controls.
Render untrusted content as plain text or escaped markup, with clear labels and no executable links or scripts. Do not let it populate the approval title, policy verdict, or button labels. Show the actual recipient, operation, and material changes prominently; a model-generated summary can omit the dangerous part.
For long payloads, offer a bounded preview and a way to inspect the full content. Truncation should be visible: otherwise, an attacker can hide the consequential instruction beyond the preview. Reviewers should approve the action on its merits, not follow instructions embedded in its input.
Bind approval to execution
A common failure is approving one payload and executing a modified one. Canonicalize the validated action and arguments, hash them, and bind the approval to that hash, a specific execution, an authorized reviewer, and an expiry. At resume time, recompute the hash; if it differs, reject or request approval again. Recheck time-sensitive policy and permissions before execution.
Use a durable, atomically claimed execution record to prevent concurrent resumes from starting the action twice. Pass an idempotency key to the downstream API when supported. If a timeout leaves the result unknown, reconcile with the provider before retrying; a local key alone cannot guarantee an external side effect happened only once.
Log the request, payload hash, policy result, reviewer decision, timestamps, and execution outcome. Restrict access and redact secrets or personal data; logs are another place untrusted content can surface.
Where AgentGate fits
I’m building AgentGate around this pre-execution boundary: routing risky agent actions to human approval while keeping the proposed call tied to the decision. The important part is not merely adding a pause—it’s preserving the trust boundary from the tool call through the approval screen to execution.
How are you handling untrusted content in approval requests? Let’s discuss in the comments.