Skip to content

Insecure SMTP SSL Configuration

Description

The Apache commons mail client does not enable TLS server identity by default, allowing an adversary to intercept sensitive information or transmit malicious data.

Examples

Insecure Code

java
Email email = new SimpleEmail();
email.setHostName("smtp.mail.example.com");
email.setSmtpPort(465);
email.setSSLOnConnect(true);

Secure Code

java
Email email = new SimpleEmail();
email.setHostName("smtp.mail.example.com");
email.setSmtpPort(465);
email.setSSLOnConnect(true);
email.setSSLCheckServerIdentity(true);

Remediation

Enable checking server identity by calling `Email.setSSLCheckServerIdentity(true)` and ensure SSL is used on connect with `Email.setSSLOnConnect(true)`

Rule Details

FieldValue
IDCODE-0721
CategoryInsecureConfig
SeverityMEDIUM
CWECWE-297
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityMODERATE
TagsTLS, SSL, Server Identity
OWASPA3:2017-Sensitive Data Exposure, A02:2021-Cryptographic Failures