The AgenticMail vulnerability GHSA-wjjv-3mj2-39hf is a composite of several high-severity issues across the API and core packages, primarily stemming from improper input validation. The root causes include:
-
SQL Injection: Multiple routes in the API (/storage/*, /accounts/inactive, /accounts/cleanup) constructed SQL queries by directly interpolating user-provided parameters (having, where keys, hours) without proper sanitization or use of parameterized queries. This allowed for classic SQL injection attacks.
-
Improper Access Control: The raw SQL storage endpoint failed to correctly identify all tables in a comma-joined query, allowing a user to craft a query that could access and exfiltrate data belonging to other users (cross-agent access).
-
Hardcoded Credentials: The outbound email relay worker contained a hardcoded secret key as a fallback. This key was publicly available in the source code, effectively nullifying authentication for the email relay service.
-
SMTP Injection: The same outbound worker did not validate email headers for control characters. This would allow an attacker to inject SMTP commands, leading to potential email spoofing or abuse of the relay.
-
Insecure Defaults (MITM): The MailSender component, responsible for sending emails, was configured by default to not verify TLS certificates. This made all outgoing email connections vulnerable to Man-in-the-Middle (MITM) attacks, where an attacker could intercept and read sensitive email content.
The patches address these issues by introducing strict input validation, moving to parameterized queries, removing hardcoded secrets, and enabling secure-by-default TLS verification.