-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve security defaults for SMTP_SSL and SMTP_TLS to prevent man-in-the-middle attacks #105
Comments
I can generally agree on all points. I'm only wondering what effect it might have on existing users. I don't want to disturb currently working functionality. If that's the case, instead I might introduce a SMTP_TLS_STRICT for example. Although, the documentation mentioned it's turned off by default due to backwards compatibility reasons (which goes back many years now). Thoughts? |
Hm, I have some reservations with this approach, and I think it would be What do you think about the following proposal?
So, yes, I share your concerns that our changes will break library consumers, |
Excellent, I can get behind this on all points. Except for the naming scheme, I'm not sure I understand the reasoning. SMTP_SSL and SMTP_TLS describe exactly what they support (and SMTPS is the same as SMTP_SSL in my mind). Aside from that, I'll have to find some time in the coming weeks to perform the changes (pregnant wife and all :), but if you feel up to it, you're welcome to give it a go for a pull-request. |
The confusion between SSL and TLS is very common, and to be honest it's kind of a pet peeve of mine 😄 SSL refers to a very obsolete encryption protocol that has since been superseded by TLS across the entire internet. Yet, for some reason, many people still refer to TLS as SSL! In a standard JVM, both SMTPS and STARTTLS JavaMail transport modes use the TLS encryption protocol when talking to encrypted mail servers. The suggestion to rename these
I've updated my PR in #104 to include the changes discussed above. It's missing tests, and if you're OK with it I would also like to include the enum naming changes suggested above. |
Alright, I'm on board for these changes. I'll look into merging your changes for review. I'll update the enum names while I'm at it. |
I'm on the fench abount naming TLS mode |
…e TLS mode for basic SMTP protocol (effectively reverting to the legacy behavior for SMTP_PLAIN
… programmatically as well as with a property
Released as 5.0.0.rc1-SNAPSHOT. Add OSS' snapshots repo to find it in Maven. |
I submitted a PR in #104 to fix these issues but I thought I'd also open this ticket for broader discussion about how Simple Java Mail is vulnerable and why this is a bad thing even when taking email's inherent lack of security into account.
TransportStrategy.SMTP_TLS
currently gives a false sense of security.As currently implemented,
TransportStrategy.SMTP_TLS
is merely opportunistic and can be easily circumvented by an active attacker. If sending emails viaTransportStrategy.SMTP_TLS
it is reasonable to assume that SMTP credentials and email contents will necessarily be protected via TLS (or otherwise an error should be raised), but that's not the current behavior of this library.The various ways an active attacker could circumvent STARTTLS are outlined in the spec, RFC 2487 § 7:
TransportStrategy.SMTP_TLS
andTransportStrategy.SMTP_SSL
do not perform certificate identity validation.At present, any certificate signed by a trusted CA and presented by an upstream SMTP server is accepted when negotiating a TLS session. A certificate issued by a public CA to
www.totally-not-spying-on-you.com
would be accepted by JavaMail during a connection attempt to, for example,smtp.gmail.com
.As noted in the PR, Oracle concedes that this default behavior of JavaMail is bad. As a convenience wrapper, I think Simple Java Mail should make its own default behavior secure. (Since developers should be turning this flag on anyways)
The current behavior is bad even when we consider that SMTP is insecure
SMTP is insecure in that email contents are not guaranteed to be end-to-end encrypted during transit. However, authentication with credentials to an SMTP server should be end-to-end encrypted if SMTPS or STARTTLS is used. The attacks above break this guarantee.
The text was updated successfully, but these errors were encountered: