CIS Dovecot Benchmark

Security configuration benchmark for Dovecot IMAP/POP3 mail server

v1.0.0 03-2025

Overview

▶

This benchmark provides prescriptive guidance for establishing a secure configuration posture for Dovecot mail server. It covers TLS enforcement, plaintext authentication disabling, protocol restriction, connection limits, logging, mailbox and configuration permissions, quota management, Sieve filtering, LMTP security, and authentication backend hardening.

14Recommendations
7Sections
2Profile Levels
SectionAreaFocus
1Installation & IdentityVersion management, mail user
2TLS & AuthenticationTLS enforcement, auth mechanisms
3Network & Connection SecurityProtocol restriction, limits
4Logging & MonitoringAuth logging, mail event tracking
5File System SecurityMailbox and config permissions
6Mail ProcessingQuotas, Sieve filtering
7Integration & MaintenanceLMTP, auth backends

Profile Definitions

▶
ProfileDescriptionIntended Use
L1Level 1 — StandardEssential security for all Dovecot deployments; minimal performance impact.
L2Level 2 — HardenedAdvanced hardening for PCI-DSS, HIPAA, or high-security environments.

1 — Installation & Identity

▶

1.1 Version & Process Security

▶
1.1.1 Ensure Dovecot is running the latest stable version (Manual)
L1 Manual
Description

This recommendation verifies that Dovecot is running the latest stable version on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Verify Dovecot version
dovecot --version
doveconf -n | head -5
Remediation
# Update Dovecot to latest stable
apt-get update && apt-get install --only-upgrade dovecot-core dovecot-imapd dovecot-pop3d
systemctl restart dovecot
1.1.2 Ensure Dovecot uses dedicated mail user and group (Automated)
L1 Auto
Description

This recommendation verifies that Dovecot uses dedicated mail user and group on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check Dovecot runs as dedicated user
ps -eo user,pid,comm | grep dovecot
doveconf -n | grep -E 'first_valid_uid|last_valid_uid|mail_uid'
Remediation
# Configure dedicated user
# In /etc/dovecot/conf.d/10-mail.conf:
# mail_uid = vmail
# mail_gid = vmail
# first_valid_uid = 500
useradd -r -s /usr/sbin/nologin -d /var/vmail vmail
mkdir -p /var/vmail && chown -R vmail:vmail /var/vmail

2 — TLS & Authentication

▶

2.1 Encryption & Auth Mechanisms

▶
2.1.1 Ensure TLS is required with strong ciphers for all connections (Automated)
L1 Auto
Description

This recommendation ensures that TLS is required with strong ciphers for all connections on the Dovecot IMAP/POP3 mail server. Enforcing this requirement establishes a minimum security standard and prevents insecure configurations.

Rationale

Without this enforcement, the Dovecot IMAP/POP3 mail server may accept insecure configurations that weaken overall security posture. Mandating this control ensures consistent protection against common attack vectors.

Audit
# Check TLS configuration
doveconf -n | grep -E 'ssl|ssl_cert|ssl_key|ssl_min_protocol'
Remediation
# Configure TLS in /etc/dovecot/conf.d/10-ssl.conf:
ssl = required
ssl_cert = </etc/dovecot/ssl/dovecot-cert.pem
ssl_key = </etc/dovecot/ssl/dovecot-key.pem
ssl_min_protocol = TLSv1.2
ssl_cipher_list = ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305
ssl_prefer_server_ciphers = yes
2.1.2 Ensure plaintext authentication is disabled without TLS (Automated)
L1 Auto
Description

This recommendation verifies that plaintext authentication is disabled without TLS on the Dovecot IMAP/POP3 mail server. Disabling or removing unnecessary components reduces the attack surface and limits potential vectors for exploitation.

Rationale

Running unnecessary components on the Dovecot IMAP/POP3 mail server increases the attack surface and the risk of exploitation. Disabling or removing them follows the principle of least functionality and reduces exposure to known vulnerabilities.

Audit
# Check disabled plaintext authentication
doveconf -n | grep -E 'disable_plaintext_auth|auth_mechanisms'
Remediation
# Disable plaintext authentication
# In /etc/dovecot/conf.d/10-auth.conf:
disable_plaintext_auth = yes
auth_mechanisms = plain login
# These mechanisms are only allowed over TLS since ssl = required
# Consider adding CRAM-MD5 or SCRAM-SHA-256:
# auth_mechanisms = plain login cram-md5 scram-sha-256

3 — Network & Connection Security

▶

3.1 Protocols & Limits

▶
3.1.1 Ensure only required protocols are enabled on secure ports (Automated)
L1 Auto
Description

This recommendation ensures that only required protocols are enabled on secure ports on the Dovecot IMAP/POP3 mail server. Enforcing this requirement establishes a minimum security standard and prevents insecure configurations.

Rationale

Without this enforcement, the Dovecot IMAP/POP3 mail server may accept insecure configurations that weaken overall security posture. Mandating this control ensures consistent protection against common attack vectors.

Audit
# Check listening protocols and ports
doveconf -n | grep -E 'protocols|listen'
ss -tlnp | grep dovecot
Remediation
# Restrict protocols and binding
# In /etc/dovecot/dovecot.conf:
protocols = imap lmtp sieve
# Do not enable pop3 unless required
listen = *, ::
# In /etc/dovecot/conf.d/10-master.conf:
service imap-login {
  inet_listener imap {
    port = 0
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}
3.1.2 Ensure connection and process limits are configured (Automated)
L1 Auto
Description

This recommendation verifies that connection and process limits are configured on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check connection limits
doveconf -n | grep -E 'mail_max_userip|login_max_connections|login_max_processes'
Remediation
# Configure connection limits
# In /etc/dovecot/conf.d/10-master.conf:
default_process_limit = 100
default_client_limit = 1000
# In /etc/dovecot/conf.d/20-imap.conf:
protocol imap {
  mail_max_userip_connections = 10
  imap_idle_notify_interval = 2 mins
}
# In login conf:
service imap-login {
  process_min_avail = 1
  service_count = 1
}

4 — Logging & Monitoring

▶

4.1 Auth & Mail Logging

▶
4.1.1 Ensure authentication and login logging is enabled (Automated)
L1 Auto
Description

This recommendation verifies that authentication and login logging is enabled on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check logging configuration
doveconf -n | grep -E 'log_path|info_log_path|debug_log_path|syslog_facility'
Remediation
# Configure logging
# In /etc/dovecot/conf.d/10-logging.conf:
log_path = syslog
syslog_facility = mail
auth_verbose = yes
auth_verbose_passwords = sha1
mail_debug = no
verbose_ssl = no
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k
4.1.2 Ensure mail event logging plugin is configured (Automated)
L1 Auto
Description

This recommendation verifies that mail event logging plugin is configured on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check mail process logging
doveconf -n | grep -E 'mail_log|notify'
doveconf -n | grep 'mail_plugins'
Remediation
# Enable mail event logging plugin
# In /etc/dovecot/conf.d/10-mail.conf:
mail_plugins = $mail_plugins mail_log notify
# In /etc/dovecot/conf.d/20-imap.conf:
protocol imap {
  mail_plugins = $mail_plugins imap_quota
}
# In /etc/dovecot/conf.d/90-plugin.conf:
plugin {
  mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
  mail_log_fields = uid box msgid size
}

5 — File System Security

▶

5.1 Mailbox & Config Permissions

▶
5.1.1 Ensure mailbox directory permissions are restricted (Automated)
L1 Auto
Description

This setting ensures that mailbox directory permissions are restricted on the Dovecot IMAP/POP3 mail server. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the Dovecot IMAP/POP3 mail server is essential for defense in depth.

Audit
# Check mailbox permissions
find /var/vmail -type d -perm /o=rwx -ls 2>/dev/null | head -10
stat -c '%a %U %G' /var/vmail
Remediation
# Restrict mailbox permissions
chown -R vmail:vmail /var/vmail
chmod -R 700 /var/vmail
find /var/vmail -type f -exec chmod 600 {} \;
find /var/vmail -type d -exec chmod 700 {} \;
5.1.2 Ensure configuration file permissions are restricted (Automated)
L1 Auto
Description

This setting ensures that configuration file permissions are restricted on the Dovecot IMAP/POP3 mail server. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the Dovecot IMAP/POP3 mail server is essential for defense in depth.

Audit
# Check configuration permissions
stat -c '%a %U %G' /etc/dovecot/dovecot.conf
find /etc/dovecot -type f -perm /o=rwx -ls 2>/dev/null
Remediation
# Restrict configuration permissions
chown -R root:dovecot /etc/dovecot
chmod 640 /etc/dovecot/dovecot.conf
find /etc/dovecot -type f -exec chmod 640 {} \;
find /etc/dovecot -type d -exec chmod 750 {} \;
chmod 600 /etc/dovecot/ssl/*.pem

6 — Mail Processing

▶

6.1 Quotas & Filtering

▶
6.1.1 Ensure mailbox quota limits are configured (Automated)
L1 Auto
Description

This recommendation verifies that mailbox quota limits are configured on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check quota configuration
doveconf -n | grep -E 'quota|quota_rule'
doveconf plugin/quota
Remediation
# Configure mailbox quotas
# In /etc/dovecot/conf.d/90-quota.conf:
plugin {
  quota = maildir:User quota
  quota_rule = *:storage=1G
  quota_rule2 = Trash:storage=+100M
  quota_grace = 10%%
  quota_status_success = DUNNO
  quota_status_nouser = DUNNO
  quota_status_overquota = "552 5.2.2 Mailbox is full"
}
6.1.2 Ensure Sieve filtering has safe limits configured (Automated)
L1 Auto
Description

This recommendation verifies that Sieve filtering has safe limits configured on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check Sieve filtering
doveconf -n | grep -E 'sieve|ManageSieve'
ls -la /etc/dovecot/sieve/ 2>/dev/null
Remediation
# Configure Sieve filtering securely
# In /etc/dovecot/conf.d/90-sieve.conf:
plugin {
  sieve = file:~/sieve;active=~/.dovecot.sieve
  sieve_before = /etc/dovecot/sieve/before.d/
  sieve_after = /etc/dovecot/sieve/after.d/
  sieve_max_script_size = 1M
  sieve_max_actions = 32
  sieve_max_redirects = 4
  sieve_extensions = +editheader
}
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
}

7 — Integration & Maintenance

▶

7.1 LMTP & Authentication Backends

▶
7.1.1 Ensure LMTP socket permissions are restricted (Automated)
L1 Auto
Description

This setting ensures that LMTP socket permissions are restricted on the Dovecot IMAP/POP3 mail server. Restricting this capability limits potential abuse and enforces the principle of least privilege across the environment.

Rationale

Unrestricted access to this capability could allow unauthorized users or processes to perform actions beyond their intended scope. Applying least-privilege principles to the Dovecot IMAP/POP3 mail server is essential for defense in depth.

Audit
# Check LMTP and submission configuration
doveconf -n | grep -E 'submission|lmtp'
ss -tlnp | grep -E '24|587'
Remediation
# Configure LMTP securely
# In /etc/dovecot/conf.d/10-master.conf:
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    user = postfix
    group = postfix
    mode = 0600
  }
}
# Enable submission with auth:
service submission-login {
  inet_listener submission {
    port = 587
  }
}
submission_relay_host = smtp.internal
submission_relay_port = 25
7.1.2 Ensure authentication backends use secure credential storage (Automated)
L1 Auto
Description

This recommendation verifies that authentication backends use secure credential storage on the Dovecot IMAP/POP3 mail server. Implementing this control strengthens the overall security configuration and reduces exposure to potential threats.

Rationale

Failure to implement this control may leave the Dovecot IMAP/POP3 mail server vulnerable to attack or non-compliant with organizational security policies. This control helps establish a consistent, hardened configuration baseline.

Audit
# Check PAM and system auth integration
doveconf -n | grep 'passdb\|userdb'
cat /etc/pam.d/dovecot 2>/dev/null
Remediation
# Configure authentication backends securely
# In /etc/dovecot/conf.d/10-auth.conf:
# auth_cache_size = 10M
# auth_cache_ttl = 1 hour
# Prefer LDAP or SQL over PAM:
passdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext
}
userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext
}
chmod 600 /etc/dovecot/dovecot-sql.conf.ext