Summary
Multiple input validation and access control weaknesses in AgenticMail's API and core libraries expose email and telephony workflows to abuse.
When agents or external systems can send unvalidated parameters to storage SQL, ownership checks, SMTP commands, or TLS configuration, attackers may escalate privileges, tamper data, or weaken transport security.
Affected context
The issues arise in AgenticMail deployments where AI agents are given real email addresses and phone numbers and rely on @agenticmail/api and @agenticmail/core for message handling, storage, and outbound delivery.
Risk is elevated when:
- Agent hour filtering and storage SQL identifiers are accepted with minimal validation
- Ownership enforcement for raw storage SQL depends solely on metadata
- Direct access to storage metadata is possible via raw SQL interfaces
- Outbound worker secrets are not handled in a fail-closed manner
- SMTP envelopes and headers are constructed without strict control-character checks
- MailSender is configured without proper TLS certificate verification, especially beyond local development setups.
Exploit preconditions
- Attack surface: Agent APIs, outbound worker interfaces, and storage SQL endpoints reachable by agents, services, or operators.
- Required access: Ability to submit agent commands, configuration changes, or SQL-like identifiers; and influence mail-sending configuration or SMTP parameters.
- Trigger point: Processing of unvalidated fields for inactive-agent hour filtering, storage SQL identifiers, ownership metadata, outbound secrets, SMTP envelopes/headers, or TLS options during routine workflows.
- Why exploitation is possible: The system trusts input and metadata too broadly, lacks comprehensive validation and fail-closed behavior, and exposes low-level storage and transport controls without robust guardrails.
Why this happens
The vulnerabilities stem from a combination of weak input validation (CWE-20), insufficient SQL identifier and query protection (related to CWE-89), overly permissive or metadata-only authorization checks (CWE-284), insecure handling of secrets and transport security (CWE-319, CWE-798), and reliance on non-fail-closed patterns.
In abstract terms, the platform allows agents and services to influence core storage and messaging behavior through parameters that are not rigorously validated, not properly bound to least-privilege roles, and sometimes processed without secure defaults for encryption and credential handling. This creates multiple pathways where untrusted data can cross trust boundaries into storage, SMTP command construction, or TLS configuration.
Potential impact
- Agents or users could bypass inactive-agent hour filtering and perform unauthorized actions.
- Storage SQL identifiers could be abused to read or modify unintended data sets.
- Metadata-backed ownership checks may be circumvented, enabling unauthorized access to raw storage SQL.
- Direct access to storage metadata via raw SQL could expose sensitive structural or tenancy information.
- Mismanaged outbound worker secrets could allow misuse of mail-sending infrastructure.
- Crafted SMTP envelopes or headers might lead to header injection, message spoofing, or delivery anomalies.
- Weak TLS verification options could enable man-in-the-middle attacks on outbound email connections.
General mitigation guidance
Durable mitigation focuses on strengthening validation, authorization, and secure defaults across the messaging pipeline.
Recommended patterns include:
- Applying strict input validation and normalization for agent filters, storage identifiers, and SMTP parameters, rejecting malformed or unexpected values.
- Enforcing least-privilege access to storage and SQL layers, with ownership tied to stable, non-spoofable attributes rather than easily manipulated metadata.
- Designing raw SQL interfaces to be inaccessible from agent-facing layers, favoring parameterized, well-bounded queries or APIs instead.
- Handling outbound worker secrets in a fail-closed manner, where missing or inconsistent credentials halt operations rather than degrade to insecure behavior.
- Treating TLS certificate verification as a secure default and isolating any local development opt-outs so they cannot be enabled in production.
- Using layered authorization checks that combine role-based policies with contextual constraints to reduce abuse of AI agents' communication capabilities.
How teams detect issues like this
Detection typically involves examining both code and configuration for trust boundary violations and insecure patterns.
Effective approaches include:
- Static analysis rules that flag dynamic or unvalidated SQL identifier usage, direct metadata access, and bypassable ownership checks.
- Targeted code review focusing on agent hour filters, storage access paths, SMTP command builders, and MailSender TLS options, looking for missing validation, parameterization, or authorization controls.
- Policy-based enforcement to ensure TLS verification remains enabled in non-development environments and secrets are never processed with permissive defaults.
- Logging and anomaly detection on storage queries and outbound mail patterns to identify unusual access to metadata, unexpected SQL shapes, or abnormal SMTP header structures.
- Optional use of automated security review tools to continuously scan for CWE-20, CWE-89, CWE-284, and related misconfiguration patterns in the codebase and deployment manifests.

