CVE-2025-59937: go-mail has insufficient address encoding when passing mail addresses to the SMTP client
N/A
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| github.com/wneessen/go-mail | go | < 0.7.1 | 0.7.1 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability lies in the insufficient encoding of email addresses passed to the SMTP client, which can be exploited for SMTP command injection. The root cause is found in the Msg.GetSender and Msg.GetRecipients functions, which were returning raw, unescaped email addresses instead of properly formatted ones. These raw addresses were then consumed by the smtp.Client.Mail and smtp.Client.Rcpt functions. These functions would wrap the provided addresses in angle brackets, but a crafted address containing a closing angle bracket could terminate the address field prematurely and allow an attacker to inject arbitrary SMTP commands. The patch addresses this by modifying Msg.GetSender and Msg.GetRecipients to use the String() method, which ensures correct escaping and quoting of the email address. Consequently, the smtp.Client.Mail and smtp.Client.Rcpt functions were updated to remove the hardcoded angle brackets, as the String() method now provides them, thus preventing the injection.
Vulnerable functions
Msg.GetSendermsg.go
Msg.GetRecipientsmsg.go
Client.Mailsmtp/smtp.go
Client.Rcptsmtp/smtp.go