Summary
Nanobot's email channel processing module treats incoming email content as highly trusted instructions for the language model, enabling indirect prompt injection that can override intended behavior.
A remote, unauthenticated attacker can send a crafted email to the monitored address and cause the assistant to execute arbitrary LLM instructions and downstream system tool actions without any interaction from the bot owner.
Affected context
This vulnerability occurs when Nanobot is configured with an active email channel that:
- Automatically polls and ingests new emails from a monitored inbox
- Forwards email bodies (and possibly subject/metadata) directly into the LLM as trusted context
- Allows the LLM's responses to drive system tools, plugins, or automations without strict output validation
In such setups, the email channel acts as a high-trust input source, so any external email content can silently influence the assistant's internal reasoning and tool invocation logic.
Exploit preconditions
- Attack surface: Network-exposed email inbox monitored by the Nanobot instance.
- Required access: Ability to send email to the bot's monitored address (no authentication needed beyond standard email delivery).
- Trigger point: Automatic polling and processing of new emails by
nanobot/channels/email.py, with no user interaction required. - Why exploitation is possible:
- Email content is injected into the LLM prompt as highly trusted instructions instead of being treated as untrusted user content.
- There are insufficient guardrails, content separation, or instruction hierarchies to prevent external text from overriding or bypassing system and developer messages.
- The LLM is permitted to call tools or perform actions based on the manipulated prompt, allowing the attacker's instructions to propagate into system-level behaviors.
Why this happens
The core issue lies in the email channel's trust model and prompt construction.
Incoming emails are effectively concatenated or embedded into the LLM conversation in a privileged position, without:
- Proper delimitation between untrusted user content and trusted system or developer instructions
- Robust instruction hierarchy enforcement that prevents external text from altering system-level behavior
- Output-constrained interfaces that limit what the LLM can subsequently command tools or automations to do
This aligns conceptually with:
- CWE-94 (Improper Control of Generation of Code): The LLM's natural language instructions are treated as operational logic that can dynamically drive tool or system actions, and external input can modify this "generated code."
- CWE-290 (Authentication Bypass by Spoofing): The email content is implicitly treated as if it were trusted/owner-originated instructions, effectively bypassing intended channel trust boundaries.
- CWE-1336 (Improper Neutralization of Special Elements Used in a Template Engine): The prompt template for the email channel does not neutralize or constrain instruction-like patterns, allowing untrusted email text to escape its intended data role and influence control flow.
At an abstract level, this is an insecure pattern in which untrusted, remote content is given directive power over an AI agent's reasoning and its tool interfaces without clear separation between data and control.
Potential impact
- Attacker-controlled execution of arbitrary instructions within the LLM's reasoning context
- Unauthorized invocation of system tools or plugins accessible to the Nanobot instance
- Silent exfiltration of sensitive data that the bot can access (e.g., files, calendars, internal APIs)
- Manipulation or deletion of user data through automated actions triggered by the LLM
- Covert persistence of malicious instructions embedded in conversation history or notes
- Abuse of the bot's identity to send deceptive or phishing responses on behalf of the owner
General mitigation guidance
Effective mitigation focuses on re-establishing strict trust boundaries for AI inputs and outputs, particularly for autonomous channels:
- Demote external email content to untrusted user input:
- Ensure that email bodies are always represented as data from an untrusted user role, never as system or developer instructions.
- Use explicit markers and delimiters (e.g., quoting and structured containers) so the model can reliably distinguish between instructions and raw content.
- Enforce strong instruction hierarchy and channel isolation:
- Design prompts where system and developer messages are clearly separated from channel content, and explicitly instruct the model to ignore any attempt by user content to modify its core rules.
- Maintain per-channel policies so that text arriving from the email channel cannot bypass global safety or authorization checks.
- Constrain tool and automation interfaces:
- Implement least-privilege design for tools: restrict actions, scopes, and accessible resources by default.
- Require explicit policy checks or rule-based filters before executing tool calls suggested by the model, especially when the trigger is remote, unauthenticated input.
- Introduce validation and gating for high-impact actions:
- Use intermediate decision layers (e.g., rule engines, allowlists, approval workflows) to vet actions derived from LLM output.
- Prefer idempotent, low-risk operations by default, reserving destructive or sensitive operations for paths that include human review or additional authentication.
- Harden prompt templates against injection:
- Treat prompts as structured templates with well-defined slots for untrusted content, rather than free-form string concatenation.
- Apply patterns such as role-based message separation, content labels, and meta-instructions that clearly restrict how the model should interpret embedded text.
How teams detect issues like this
Detecting this class of vulnerability benefits from a mix of code-level and behavior-level analysis:
- Static analysis and code scanning:
- Search for channels or integrations that ingest external data (email, webhooks, web content) and feed it directly into LLM prompts.
- Flag patterns where untrusted content is interpolated into system or developer messages, or placed ahead of safety instructions in the prompt.
- Identify code paths that allow LLM output to directly trigger tool invocations or system actions without intermediary policy checks.
- Structured code review:
- Review prompt construction logic in modules like
nanobot/channels/email.py, ensuring clear role separation and explicit treatment of untrusted content. - Examine tool and plugin interfaces to verify they enforce authorization, rate limits, and scope restrictions independently of the model's reasoning.
- Look for comments or logic implying that certain channels are "trusted" without a robust verification mechanism.
- Runtime monitoring and anomaly detection:
- Monitor logs of LLM conversations and tool invocations originated from automated channels for unusual patterns, such as:
- High-risk commands triggered immediately upon email receipt
- Sequences of actions that appear inconsistent with typical owner behavior
- Implement alerts when remote, unauthenticated channels cause access to sensitive resources or execute potentially destructive operations.
- Automated security testing:
- Use red-team style prompts and templated adversarial emails to test whether channel inputs can override system instructions or trigger unauthorized tool use.
- Integrate such tests into CI pipelines to detect regressions in prompt-hardening logic.

