diff --git a/postfix/.indent.pro b/postfix/.indent.pro index 32948b150..61ea04957 100644 --- a/postfix/.indent.pro +++ b/postfix/.indent.pro @@ -64,6 +64,9 @@ -TDELTA_TIME -TDICT -TDICT_CACHE +-TDICT_CACHE_SREQ +-TDICT_CACHE_SREQ_INFO +-TDICT_CACHE_TEST -TDICT_CDBM -TDICT_CDBQ -TDICT_CIDR diff --git a/postfix/HISTORY b/postfix/HISTORY index 6ca997e3f..eca39850f 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -19409,8 +19409,8 @@ Apologies for any names omitted. 20131219 Cleanup: renamed postconf(1) internal identifiers according - to a consistent scheme, to avoid name future name conflicts - as Postfix evolves. This is a no-feature change. Files: + to a consistent scheme, to avoid future name conflicts as + Postfix evolves. This is a no-feature change. Files: postconf/*.[hc], postconf/extract.awk. Documentation: linearized the order of exposition in @@ -19440,3 +19440,32 @@ Apologies for any names omitted. Documentation: added section on how to verify that forward secrecy works. File: proto/FORWARD_SECRECY_README.html. + +20131222 + + Documentation: forward secrecy, with feedback from Adam + Shostack. Viktor Dukhovni and Wietse Venema. File: + proto/FORWARD_SECRECY_README.html. + +20131224 + + Feature: smtpd_sasl_service (until now, this was hard-coded + internally as "smtp"). On request by Michal (sksoft.cz). + Files: global/mail_params.h, proto/postconf.proto, + mantools/postlink, smtpd/smtpd.c, smtpd/smtpd_sasl_glue.c. + + Documentation: updated example to Dovecot version 2 syntax. + File: proto/SASL_README/html. + +20131228 + + Cleanup: DANE support: test script. Viktor Dukhovni. File + tls/tls_dane.sh. + + LMDB will not be supported in the stable Postfix 2.11 release. + + Debugging: test driver to speed up LMDB debugging and stress + testing. Shockingly, LMDB terminates the postcreen daemon + without logfile record. Fixing this will require changes + in LMDB or changes in the way Postfix can use LMDB. File: + util/dict_cache.c. diff --git a/postfix/README_FILES/FORWARD_SECRECY_README b/postfix/README_FILES/FORWARD_SECRECY_README index b2bce2d34..785c572ac 100644 --- a/postfix/README_FILES/FORWARD_SECRECY_README +++ b/postfix/README_FILES/FORWARD_SECRECY_README @@ -2,6 +2,15 @@ ------------------------------------------------------------------------------- +WWaarrnniinngg + +Forward secrecy does not protect against active attacks such as forged DNS +replies or forged TLS server certificates. If such attacks are a concern, then +the SMTP client will need to authenticate the remote SMTP server in a +sufficiently-secure manner. For example, by the fingerprint of the public key +or certificate. Conventional PKI relies on many trusted parties and is easily +subverted by a state-funded adversary. + BBaacckkggrroouunndd Postfix supports forward secrecy of TLS network communication since version @@ -34,18 +43,15 @@ cost constraints on the efficacy of bulk surveillance, recovering all past traffic is generally infeasible, and even recovery of individual sessions may be infeasible given a sufficiently-strong key agreement method. -Forward secrecy protects network communication in the absence of active -attacks, i.e. no forged DNS replies, and no forged TLS server certificates. If -active attacks are a concern, then you will need to authenticate the remote -SMTP server in a secure manner. For example, by the fingerprint of the public -key or certificate. Conventional PKI relies on too many trusted parties. - Topics covered in this document: * Forward Secrecy in TLS * Forward Secrecy in the Postfix SMTP Server * Forward Secrecy in the Postfix SMTP Client - * How do I know that it works? + * Getting started, quick and dirty + * How can I see that a connection has forward secrecy? + * What ciphers provide forward secrecy? + * What do "Anonymous", "Untrusted", etc. in Postfix logging mean? * Credits And last but not least, for the impatient: @@ -71,18 +77,19 @@ not compromised by future disclosure of long-term authentication keys. The key-exchange algorithms used for forward secrecy require the TLS server to designate appropriate "parameters" consisting of a mathematical "group" and an -element of that group called a "generator". There are two flavors of "groups" -that work with PFS: +element of that group called a "generator". Presently, there are two flavors of +"groups" that work with PFS: - * Prime field groups. The server needs to be configured with a suitably large - prime and a corresponding "generator". - * Elliptic curve groups. The server needs to be configured with a "named - curve". These offer better security at lower computational cost than prime - field groups, but are not as widely implemented. + * PPrriimmee--ffiieelldd ggrroouuppss ((EEDDHH)):: The server needs to be configured with a + suitably-large prime and a corresponding "generator". The acronym for + forward secrecy over prime fields is EDH or Ephemeral Diffie-Hellman + (sometimes also abbreviated as DHE). -The acronym for forward secrecy over prime fields is EDH or Ephemeral Diffie- -Hellman (sometimes also abbreviated as DHE). The acronym for the elliptic curve -version is EECDH which is short for Ephemeral Elliptic Curve Diffie-Hellman. + * EElllliippttiicc--ccuurrvvee ggrroouuppss ((EEEECCDDHH)):: The server needs to be configured with a + "named curve". These offer better security at lower computational cost than + prime field groups, but are not as widely implemented. The acronym for the + elliptic curve version is EECDH which is short for Ephemeral Elliptic Curve + Diffie-Hellman. It is not essential to know what these are, but one does need to know that OpenSSL only supports EECDH as of version 1.0.0. Thus the configuration @@ -155,7 +162,7 @@ supported. The OpenSSL code for making this possible is not yet released as of late 2013 (it is available only in OpenSSL development snapshots). At some point Postfix will need to adjust to the new API for setting the -elliptic curve options. Fortunately, when EECDH support was added to Postfix, +elliptic-curve options. Fortunately, when EECDH support was added to Postfix, it introduced a layer of indirection: smtpd_tls_eecdh_grade = strong | ultra @@ -172,10 +179,12 @@ main.cf. FFoorrwwaarrdd SSeeccrreeccyy iinn tthhee PPoossttffiixx SSMMTTPP CClliieenntt The Postfix >= 2.2 SMTP client supports forward secrecy in its default -configuration. If the remote SMTP server supports cipher suites with forward -secrecy (and does not override the SMTP client cipher preference), then the -traffic between the server and client will resist decryption even if the -server's long-term authentication keys are later compromised. +configuration. No configuration changes are needed besides turning on elliptic- +curve support with Postfix 2.6 and 2.7 (see the quick-start section). If the +remote SMTP server supports cipher suites with forward secrecy (and does not +override the SMTP client's cipher preference), then the traffic between the +server and client will resist decryption even if the server's long-term +authentication keys are later compromised. The default Postfix SMTP client cipher lists are correctly ordered to prefer EECDH and EDH cipher suites ahead of similar cipher suites that don't implement @@ -189,68 +198,96 @@ a case-by-case basis via the TLS policy table. GGeettttiinngg ssttaarrtteedd,, qquuiicckk aanndd ddiirrttyy -At least one time as root (prime group generation can take a few seconds to a -few minutes): + * Postfix 2.6 and 2.7: Enable elliptic-curve support. This is the default + with Postfix >= 2.8. - # cd /etc/postfix - # openssl dhparam -out dh512.tmp 512 && mv dh512.tmp dh512.pem - # openssl dhparam -out dh1024.tmp 1024 && mv dh1024.tmp dh1024.pem - # openssl dhparam -out dh2048.tmp 2048 && mv dh2048.tmp dh2048.pem - # chmod 644 dh512.pem dh1024.pem dh2048.pem + /etc/postfix/main.cf: + # Postfix 2.6 or 2.7 only. This is default with Postfix 2.8 and + later. + smtpd_tls_eecdh_grade = strong -Note: greater security against "pre-computation" attacks against EDH can be -obtained by periodically regenerating the EDH parameters as above (an hourly or -daily cron job running as root can automate this task). The parameter files are -not secret, after all these are sent to all SMTP clients in the clear. Mode -0644 is fine. + * Optionally generate non-default EDH parameters for improved security + against pre-computation attacks and for compatibility with Debian-patched + EXIM SMTP clients (these require a minimum 2048-bit length for the non- + export prime). The parameter files are not secret, after all these + parameters are sent to all SMTP clients in the clear. Mode 0644 is fine. -Once the parameters are in place, update main.cf as follows: + Execute as root (prime group generation can take a few seconds to a few + minutes): - /etc/postfix/main.cf: - # Postfix >= 2.6 - smtpd_tls_eecdh_grade = strong - # All versions of Postfix: - smtpd_tls_dh1024_param_file = ${config_directory}/dh2048.pem - smtpd_tls_dh512_param_file = ${config_directory}/dh512.pem + # cd /etc/postfix + # openssl dhparam -out dh512.tmp 512 && mv dh512.tmp dh512.pem + # openssl dhparam -out dh1024.tmp 1024 && mv dh1024.tmp dh1024.pem + # openssl dhparam -out dh2048.tmp 2048 && mv dh2048.tmp dh2048.pem + # chmod 644 dh512.pem dh1024.pem dh2048.pem -If some of your MSA clients don't support 2048-bit EDH, you may need to adjust -the submission entry in master.cf accordingly: + You can improve security against pre-computation attacks further by + regenerating the EDH parameters periodically (an hourly or daily cron job + running as root can automate this task). - /etc/postfix/master.cf: - submission inet n - n - - smtpd - # Some submission clients may not yet do 2048-bit EDH, if such - # clients use your MSA, configure 1024-bit EDH instead: - -o smtpd_tls_dh1024_param_file=${config_directory}/dh1024.pem - -o smtpd_tls_security_level=encrypt - -o smtpd_sasl_auth_enable=yes - ... + Once the parameters are in place, update main.cf as follows: -HHooww ddoo II kknnooww tthhaatt iitt wwoorrkkss?? + /etc/postfix/main.cf: + smtpd_tls_dh1024_param_file = ${config_directory}/dh2048.pem + smtpd_tls_dh512_param_file = ${config_directory}/dh512.pem -Postfix reports TLS connection information in several ways: + If some of your MSA clients don't support 2048-bit EDH, you may need to + adjust the submission entry in master.cf accordingly: + + /etc/postfix/master.cf: + submission inet n - n - - smtpd + # Some submission clients may not yet do 2048-bit EDH, if such + # clients use your MSA, configure 1024-bit EDH instead: + -o smtpd_tls_dh1024_param_file=${config_directory}/dh1024.pem + -o smtpd_tls_security_level=encrypt + -o smtpd_sasl_auth_enable=yes + ... + +HHooww ccaann II sseeee tthhaatt aa ccoonnnneeccttiioonn hhaass ffoorrwwaarrdd sseeccrreeccyy?? + +Postfix can be configured to report information about the negotiated cipher, +the corresponding key lengths, and the remote peer certificate or public-key +verification status. * With "smtp_tls_loglevel = 1" and "smtpd_tls_loglevel = 1", the Postfix SMTP - client and server will log information about, among others, the remote peer - certificate or public-key verification status, the negotiated cipher, and - key lengths. The general logfile format is: + client and server will log TLS connection information to the maillog file. + The general logfile format is: - postfix/smtp[xxx]: Trusted TLS connection established to - host.example.com[192.168.0.2]:25: TLSv1 with cipher XXX (YYY/ZZZ bits) + postfix/smtp[process-id]: Untrusted TLS connection established + to host.example.com[192.168.0.2]:25: TLSv1 with cipher cipher-name + (actual-key-size/raw-key-size bits) - postfix/smtpd[xxx]: Untrusted TLS connection established from - host.example.com[192.168.0.2]: TLSv1 with cipher XXX (YYY/ZZZ bits) + postfix/smtpd[process-id]: Anonymous TLS connection established + from host.example.com[192.168.0.2]: TLSv1 with cipher cipher-name + (actual-key-size/raw-key-size bits) * With "smtpd_tls_received_header = yes", the Postfix SMTP server will record - similar information in the Received: header in the form of comments (text - inside parentheses). The general format is: + TLS connection information in the Received: header in the form of comments + (text inside parentheses). The general format depends on the + smtpd_tls_ask_ccert setting: Received: from host.example.com (host.example.com [192.168.0.2]) - (using TLSv1 with cipher XXX (YYY/ZZZ bits)) - (Client CN "host.example.com", Issuer "Wietse Venema" (not + (using TLSv1 with cipher cipher-name + (actual-key-size/raw-key-size bits)) + (Client CN "host.example.com", Issuer "John Doe" (not verified)) + Received: from host.example.com (host.example.com [192.168.0.2]) + (using TLSv1 with cipher cipher-name + (actual-key-size/raw-key-size bits)) + (No client certificate requested) + +The next sections will explain what cipher-name, key-size, and peer +verification status information to expect. + +WWhhaatt cciipphheerrss pprroovviiddee ffoorrwwaarrdd sseeccrreeccyy?? + There are dozens of ciphers that support forward secrecy. What follows is the -beginning of a list of 51 ciphers available with OpenSSL 1.0.1e: +beginning of a list of 51 ciphers available with OpenSSL 1.0.1e. The list is +sorted in the default Postfix preference order. It excludes null ciphers that +only authenticate and don't encrypt, together with export and low-grade ciphers +whose encryption is too weak to offer meaningful secrecy. The first column +shows the cipher name, and the second shows the key exchange method. $ openssl ciphers -v \ 'aNULL:-aNULL:kEECDH:kEDH:+RC4:!eNULL:!EXPORT:!LOW:@STRENGTH' | @@ -271,6 +308,81 @@ beginning of a list of 51 ciphers available with OpenSSL 1.0.1e: DHE-RSA-AES256-SHA256 Kx=DH ... +To date, all ciphers that support forward secrecy have one of five values for +the first component of their OpenSSL name: "AECDH", "ECDHE", "ADH", "EDH" or +"DHE". Ciphers that don't implement forward secrecy have names that don't start +with one of these prefixes. This pattern is likely to persist until some new +key-exchange mechanism is invented that also supports forward secrecy. + +The actual key length and raw algorithm key length are generally the same with +non-export ciphers, but may they differ for the legacy export ciphers where the +actual key is artificially shortened. + +WWhhaatt ddoo ""AAnnoonnyymmoouuss"",, ""UUnnttrruusstteedd"",, eettcc.. iinn PPoossttffiixx llooggggiinngg mmeeaann?? + +The verification levels below are subject to man-in-the-middle attacks to +different degrees. If such attacks are a concern, then the SMTP client will +need to authenticate the remote SMTP server in a sufficiently-secure manner. +For example, by the fingerprint of the public key or certificate. Remember that +conventional PKI relies on many trusted parties and is easily subverted by a +state-funded adversary. + +AAnnoonnyymmoouuss (no peer certificate) + PPoossttffiixx SSMMTTPP cclliieenntt:: With opportunistic TLS (the "may" security level) the + Postfix SMTP client does not verify any information in the peer + certificate. In this case it enables and prefers anonymous cipher suites in + which the remote SMTP server does not present a certificate (these ciphers + offer forward secrecy of necessity). When the remote SMTP server also + supports anonymous TLS, and agrees to such a cipher suite, the verification + status will be logged as "Anonymous". + + PPoossttffiixx SSMMTTPP sseerrvveerr:: This is by far most common, as client certificates are + optional, and the Postfix SMTP server does not request client certificates + by default (see smtpd_tls_ask_ccert). Even when client certificates are + requested, the remote SMTP client might not send a certificate. Unlike the + Postfix SMTP client, the Postfix SMTP server "anonymous" verification + status does not imply that the cipher suite is anonymous, which corresponds + to the server not sending a certificate. + +UUnnttrruusstteedd (peer certificate not signed by trusted CA) + PPoossttffiixx SSMMTTPP cclliieenntt:: The remote SMTP server presented a certificate, but + the Postfix SMTP client was unable to check the issuing CA signature. With + opportunistic TLS this is common with remote SMTP servers that don't + support anonymous cipher suites. + + PPoossttffiixx SSMMTTPP sseerrvveerr:: The remote SMTP client presented a certificate, but + the Postfix SMTP server was unable to check the issuing CA signature. This + can happen when the server is configured to request client certificates + (see smtpd_tls_ask_ccert). + +TTrruusstteedd (peer certificate signed by trusted CA, unverified peer name) + PPoossttffiixx SSMMTTPP cclliieenntt:: The remote SMTP server's certificate was signed by a + CA that the Postfix SMTP client trusts, but either the client was not + configured to verify the destination server name against the certificate, + or the server certificate did not contain any matching names. This is + common with opportunistic TLS (smtp_tls_security_level is "may" or else + "dane" with no usable TLSA DNS records) when the Postfix SMTP client's + trusted CAs can verify the authenticity of the remote SMTP server's + certificate, but the client is not configured or unable to verify the + server name. + + PPoossttffiixx SSMMTTPP sseerrvveerr:: The remote SMTP client certificate was signed by a CA + that the Postfix SMTP server trusts. The Postfix SMTP server never verifies + the remote SMTP client name against the names in the certificate. Since the + client chooses to connect to the server, the Postfix SMTP server has no + expectation of a particular client hostname. + +VVeerriiffiieedd (peer certificate signed by trusted CA, verified peer name) + PPoossttffiixx SSMMTTPP cclliieenntt:: The remote SMTP server's certificate was signed by a + CA that the Postfix SMTP client trusts, and it matches one of the expected + server names. This implies that the Postfix SMTP client enforced + verification for the destination server name, otherwise the verification + status would have been just "Trusted". + + PPoossttffiixx SSMMTTPP sseerrvveerr:: The status is never "Verified", as the Postfix SMTP + server never verifies the remote SMTP client name against the names in the + certificate. + CCrreeddiittss * TLS support for Postfix was originally developed by Lutz Jänicke at Cottbus diff --git a/postfix/README_FILES/SASL_README b/postfix/README_FILES/SASL_README index 4a05e9a0c..9e93b2326 100644 --- a/postfix/README_FILES/SASL_README +++ b/postfix/README_FILES/SASL_README @@ -1,3 +1,5 @@ +X + PPoossttffiixx SSAASSLL HHoowwttoo ------------------------------------------------------------------------------- @@ -109,71 +111,30 @@ configure and operate the Dovecot authentication server. PPoossttffiixx ttoo DDoovveeccoott SSAASSLL ccoommmmuunniiccaattiioonn Communication between the Postfix SMTP server and Dovecot SASL happens over a -UNIX-domain socket or over a TCP socket. Dovecot 1 supports UNIX-domain socket -communication only. +UNIX-domain socket or over a TCP socket. We will be using a UNIX-domain socket +for better privacy. -UUNNIIXX--ddoommaaiinn ssoocckkeett ccoommmmuunniiccaattiioonn +The following fragment for Dovecot version 2 assumes that the Postfix queue is +under /var/spool/postfix/. -The socket pathname and the list of mechanisms offered to Postfix need to be -specified on the Dovecot server side in dovecot.conf. + 1 conf.d/10-master.conf: + 2 service auth { + 3 ... + 4 unix_listener /var/spool/postfix/private/auth { + 5 mode = 0660 + 6 # Assuming the default Postfix user and group + 7 user = postfix + 8 group = postfix + 9 } + 10 ... + 11 } + 12 + 13 conf.d/10-auth.conf + 14 auth_mechanisms = plain login -The following example assumes that the Postfix queue is under /var/spool/ -postfix/. - -Note: the example uses Dovecot 1 syntax, See http://www.dovecot.org/ for newer -syntax. - - 1 /etc/dovecot.conf: - 2 auth default { - 3 mechanisms = plain login - 4 passdb pam { - 5 } - 6 userdb passwd { - 7 } - 8 socket listen { - 9 client { - 10 path = /var/spool/postfix/private/auth - 11 mode = 0660 - 12 user = postfix - 13 group = postfix - 14 } - 15 } - 16 } - -Line 3 provides plain and login as mechanisms for the Postfix SMTP server, line -10 places the Dovecot SASL socket in /var/spool/postfix/private/auth, and lines -11-13 limit read+write permissions to user and group postfix only. - -Proceed with the section "Enabling SASL authentication and authorization in the -Postfix SMTP server" to turn on and use SASL in the Postfix SMTP server. - -TTCCPP ssoocckkeett ccoommmmuunniiccaattiioonn - -The TCP port and the list of mechanisms offered to Postfix need to be specified -on the Dovecot server side in 10-auth.conf and 10-master.conf. - -The following examples assume that Postfix should communicate with Dovecot on -TCP port 12345. - -Note: the examples use Dovecot 1 syntax, See http://www.dovecot.org/ for newer -syntax. - - 1 /etc/dovecot/conf.d/10-auth.conf: - 2 auth_mechanisms = plain login - -Line 2 provides plain and login as mechanisms for the Postfix SMTP server. - - 1 /etc/dovecot/conf.d/10-master.conf: - 2 service auth { - 3 unix_listener auth-userdb { - 4 } - 5 inet_listener { - 6 port = 12345 - 7 } - 8 } - -Line 5 creates a new TCP socket and line 6 specifies port 12345 where Dovecot -SASL should wait for Postfix authentication requests. +Line 4 places the Dovecot SASL socket in /var/spool/postfix/private/auth, lines +5-8 limit read+write permissions to user and group postfix only, and line 14 +provides plain and login as mechanisms for the Postfix SMTP server. Proceed with the section "Enabling SASL authentication and authorization in the Postfix SMTP server" to turn on and use SASL in the Postfix SMTP server. diff --git a/postfix/WISHLIST b/postfix/WISHLIST index 5e83044e9..6ec562349 100644 --- a/postfix/WISHLIST +++ b/postfix/WISHLIST @@ -4,6 +4,10 @@ Wish list: independent from the DNS and native routines for host name/address lookup. + Incorporate 3rd-party code such as dynamic_maps. + + Support 3rd-party extension with /etc/postfix/postfix-files.d + Make been_here flag BH_FLAG_FOLD configurable for masochists. Replace some redundant TLS_README sections with pointers diff --git a/postfix/conf/main.cf b/postfix/conf/main.cf index 8d301aa98..dc58a1d85 100644 --- a/postfix/conf/main.cf +++ b/postfix/conf/main.cf @@ -5,7 +5,7 @@ # For common configuration examples, see BASIC_CONFIGURATION_README # and STANDARD_CONFIGURATION_README. To find these documents, use # the command "postconf html_directory readme_directory", or go to -# http://www.postfix.org/. +# http://www.postfix.org/BASIC_CONFIGURATION_README.html etc. # # For best results, change no more than 2-3 parameters at a time, # and test if Postfix still works after every change. diff --git a/postfix/conf/master.cf b/postfix/conf/master.cf index 1369918c3..51a339834 100644 --- a/postfix/conf/master.cf +++ b/postfix/conf/master.cf @@ -1,6 +1,7 @@ # # Postfix master process configuration file. For details on the format -# of the file, see the master(5) manual page (command: "man 5 master"). +# of the file, see the master(5) manual page (command: "man 5 master" or +# on-line: http://www.postfix.org/master.5.html). # # Do not forget to execute "postfix reload" after editing this file. # diff --git a/postfix/html/FORWARD_SECRECY_README.html b/postfix/html/FORWARD_SECRECY_README.html index 4878dccb7..42e132041 100644 --- a/postfix/html/FORWARD_SECRECY_README.html +++ b/postfix/html/FORWARD_SECRECY_README.html @@ -19,6 +19,16 @@ TLS Forward Secrecy in Postfix
+

Warning

+ +

Forward secrecy does not protect against active attacks such +as forged DNS replies or forged TLS server certificates. If such +attacks are a concern, then the SMTP client will need to authenticate +the remote SMTP server in a sufficiently-secure manner. For example, +by the fingerprint of the public key or certificate. Conventional +PKI relies on many trusted parties and is easily subverted by a +state-funded adversary.

+

Background

Postfix supports forward secrecy of TLS network communication @@ -55,13 +65,6 @@ all past traffic is generally infeasible, and even recovery of individual sessions may be infeasible given a sufficiently-strong key agreement method.

-

Forward secrecy protects network communication in the absence -of active attacks, i.e. no forged DNS replies, and no forged TLS -server certificates. If active attacks are a concern, then you will -need to authenticate the remote SMTP server in a secure manner. -For example, by the fingerprint of the public key or certificate. -Conventional PKI relies on too many trusted parties.

-

Topics covered in this document: