Summary
A high-severity command injection vulnerability in PraisonAI's email tools allows language-model-controlled values to alter quoted IMAP search criteria. When an exposed agent has configured email credentials, an attacker may access, modify, delete, or disrupt mailbox operations.
Affected context
The issue occurs in PraisonAI email functionality that constructs IMAP SEARCH criteria from language-model-controlled sender, subject, or query values. Deployments become risky when agents can invoke search, reply, or archive operations and have access to configured email credentials. The vulnerability depends on those values being inserted into IMAP criteria without sufficient escaping or validation.
Exploit preconditions
- Attack surface: PraisonAI email tools that issue IMAP operations
- Required access: Ability to influence an agent's
from_addr,subject, orqueryvalues, plus access to an agent configured with email credentials - Trigger point: Invocation of
search_emails,reply_email, orarchive_email - Why exploitation is possible: User-controlled values are interpolated directly into quoted IMAP SEARCH criteria, allowing special characters to change the intended operation
Why this happens
The underlying bug is improper neutralization of special elements in an externally influenced command or query. Email tool parameters controlled by an LLM are inserted into IMAP SEARCH criteria without treating them as data separate from the command syntax. Embedded quotes, backslashes, line breaks, or null characters can therefore alter parser interpretation. This maps primarily to CWE-77, Improper Neutralization of Special Elements used in a Command, with CWE-20 reflecting insufficient input validation.
Potential impact
- An attacker may access mailbox messages or search results
- An attacker could modify or delete email through available tool operations
- Mailbox content or metadata may be manipulated
- IMAP connections or email workflows may be disrupted
- Compromised mailbox credentials could enable further account abuse
General mitigation guidance
Mitigation generally focuses on keeping LLM-controlled values separate from
IMAP command syntax and reducing trust in agent-generated inputs.
Common defensive patterns include:
- Using protocol-aware APIs or structured query builders that safely encode IMAP criteria
- Applying strict allowlist validation for sender, subject, and search parameters
- Rejecting control characters and unsupported delimiters before request construction
- Separating read-only search capabilities from message modification or deletion capabilities
- Limiting mailbox permissions and using dedicated accounts with least privilege
- Requiring explicit authorization for destructive email actions
- Treating model output as untrusted input even when generated by an internal agent
How teams detect issues like this
Organizations can identify similar issues through:
- Static analysis rules for string interpolation into IMAP commands or protocol queries
- Code review checks for direct concatenation of model output into quoted criteria
- Tests covering quotes, backslashes, line breaks, null characters, and other control characters
- Policy enforcement requiring protocol encoders or structured query APIs
- Runtime monitoring for unusual search criteria, bulk mailbox changes, or repeated failed IMAP commands
- Automated security review tools that flag command construction from untrusted inputs

