The net/smtp package is somewhat dangerous, in that it doesn't really do any validation of data passed to it, and generally will just directly pass that through to the SMTP server without any sanitization. For certain methods, like Client.Mail, or functions like SendMail this can cause issues if the to/from addresses are malformed, or contain reserved characters (like angle brackets), or if headers are malformed, etc. This is may have significant impact if the caller of this API is accepting untrusted user input and using it to populate these arguments without doing their own validation.
We could add validation to various parts of the package, but that would be a rather significant change in an otherwise frozen package. At the least we should document the (as currently defined) security properties of this package (i.e., there are none) and make it clear that this package is not hardened against adversarial inputs, and users should be extremely careful about what they pass into these functions/methods.
Thanks to RyotaK (@Ry0taK) for reporting this issue.
The net/smtp package is somewhat dangerous, in that it doesn't really do any validation of data passed to it, and generally will just directly pass that through to the SMTP server without any sanitization. For certain methods, like
Client.Mail, or functions likeSendMailthis can cause issues if the to/from addresses are malformed, or contain reserved characters (like angle brackets), or if headers are malformed, etc. This is may have significant impact if the caller of this API is accepting untrusted user input and using it to populate these arguments without doing their own validation.We could add validation to various parts of the package, but that would be a rather significant change in an otherwise frozen package. At the least we should document the (as currently defined) security properties of this package (i.e., there are none) and make it clear that this package is not hardened against adversarial inputs, and users should be extremely careful about what they pass into these functions/methods.
Thanks to RyotaK (@Ry0taK) for reporting this issue.