Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security fixes in SMTP_SSL and SMTP_TLS strategies #104

Merged
merged 1 commit into from
Nov 5, 2017

Conversation

cbarcenas
Copy link
Contributor

  • The SMTP_SSL and SMTP_TLS transport strategies now validate certificates
    by setting JavaMail's mail.<protocol>.ssl.checkserveridentity property
    to true.

    Previously, no identity validation was performed, leaving SMTPS and
    STARTTLS connections vulnerable to man-in-the-middle attacks. Without
    identity validation, JavaMail accepts any certificate issued by a
    JVM-trusted CA, regardless of the identity encoded in the certificate.

  • The SMTP_TLS transport strategy now requires STARTTLS support by setting
    JavaMail's mail.smtp.starttls.required property to true.

    Previously, STARTTLS support was not required, enabling a man-in-the-middle
    attack whereby an attacker could strip the STARTTLS request from an SMTP
    connection, causing JavaMail to fall back to plaintext SMTP for
    authentication and email transport.

@cbarcenas
Copy link
Contributor Author

cbarcenas commented Oct 19, 2017

It's worth noting that while having a certificate identity validation mechanism is required the STARTTLS/SMTPS RFCs, it's only "strongly recommended" by Oracle, who left it off "for compatibility with earlier releases of JavaMail". 🤦‍♂️ This is very dangerous default behavior - and it's no surprise that developers might miss this while building software on top of JavaMail.

RFC 2595 specifies addition checks that must be performed on the
server's certificate to ensure that the server you connected to is
the server you intended to connect to. This reduces the risk of
"man in the middle" attacks. For compatibility with earlier releases
of JavaMail, these additional checks are disabled by default. We
strongly recommend that you enable these checks when using SSL. To
enable these checks, set the "mail.<protocol>.ssl.checkserveridentity"
property to "true".

- "Server Identity Check", SSLNOTES.txt

  - The SMTP_PLAIN transport strategy now attempts an (insecure) STARTTLS
    upgrade where possible, but will always permit plaintext fallback to
    preserve backwards-compatibility with unencrypted SMTP.

    The opportunistic STARTTLS handshake in SMTP_PLAIN does not validate
    the server certificate's issuer or identity; therefore, it does not
    protect against active network attackers.

    The STARTTLS handshake, in this transport strategy, is merely a best-effort
    encryption mechanism to defend against passive network eavesdroppers.

  - The SMTP_SSL and SMTP_TLS transport strategies now validate certificates
    by setting JavaMail's `mail.<protocol>.ssl.checkserveridentity` property
    to true.

    Previously, no identity validation was performed, leaving SMTPS and
    STARTTLS connections vulnerable to man-in-the-middle attacks. Without
    identity validation, JavaMail accepts _any_ certificate issued by a
    JVM-trusted CA, regardless of the identity encoded in the certificate.

  - The SMTP_TLS transport strategy now requires STARTTLS support by setting
    JavaMail's `mail.smtp.starttls.required` property to true.

    Previously, STARTTLS support was not required, enabling a man-in-the-middle
    attack whereby an attacker could strip the STARTTLS request from an SMTP
    connection, causing JavaMail to fall back to plaintext SMTP for
    authentication and email transport.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants