1 \section{Recommendations on practical settings}
4 \subsection{Webservers}
10 %-All +TLSv1.1 +TLSv1.2
11 \begin{lstlisting}[breaklines]
12 SSLProtocol All -SSLv2 -SSLv3
13 SSLHonorCipherOrder On
15 # Add six earth month HSTS header for all users...
16 Header add Strict-Transport-Security "max-age=15768000"
17 # If you want to protect all subdomains, use the following header
18 # ALL subdomains HAVE TO support https if you use this!
19 # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
21 SSLCipherSuite 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EDH+CAMELLIA256:EECDH:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!AES128:!CAMELLIA128:!ECDSA:AES256-SHA'
24 Note again, that any cipher suite starting with ECDHE can be omitted in case of doubt.
25 %% XXX NOTE TO SELF: remove from future automatically generated lists!
27 You should redirect everything to httpS:// if possible. In Apache you can do this with the following setting inside of a VirtualHost environment:
29 \begin{lstlisting}[breaklines]
33 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=permanent]
38 %XXXX ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
41 \subsubsection{lighttpd}
45 %% Note: need to be checked / reviewed
47 %% Complete ssl.cipher-list with same algo than Apache
48 \todo{FIXME: this string seems to be wrongly formatted}
50 \begin{lstlisting}[breaklines]
51 $SERVER["socket"] == "0.0.0.0:443" {
53 ssl.use-sslv2 = "disable"
54 ssl.use-sslv3 = "disable"
55 ssl.use-compression = "disable"
56 ssl.pemfile = "/etc/lighttpd/server.pem"
57 ssl.cipher-list = 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EDH+CAMELLIA256:EECDH:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!AES128:!CAMELLIA128:!ECDSA:AES256-SHA'
58 ssl.honor-cipher-order = "enable"
59 setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=31536000")
63 As for any other webserver, you should redirect automatically http traffic toward httpS:\footnote{That proposed configuration is directly coming from lighttpd documentation: \url{http://redmine.lighttpd.net/projects/1/wiki/HowToRedirectHttpToHttps}}
65 \begin{lstlisting}[breaklines]
66 $HTTP["scheme"] == "http" {
67 # capture vhost name with regex conditiona -> %0 in redirect pattern
68 # must be the most inner block to the redirect rule
69 $HTTP["host"] =~ ".*" {
70 url.redirect = (".*" => "https://%0$0")
79 \begin{lstlisting}[breaklines]
80 ssl_prefer_server_ciphers on;
81 ssl_protocols -SSLv2 -SSLv3;
82 ssl_ciphers 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EDH+CAMELLIA256:EECDH:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!AES128:!CAMELLIA128:!ECDSA:AES256-SHA';
83 add_header Strict-Transport-Security max-age=2592000;
84 add_header X-Frame-Options DENY;
87 %% XXX FIXME: do we need to specify dhparams? Parameter: ssl_dhparam = file. See: http://wiki.nginx.org/HttpSslModule#ssl_protocols
90 If you decide to trust NIST's ECC curve recommendation, you can add the following line to nginx's configuration file to select special curves:
92 \begin{lstlisting}[breaklines]
93 ssl_ecdh_curve sect571k1;
96 You should redirect everything to httpS:// if possible. In Nginx you can do this with the following setting:
98 \begin{lstlisting}[breaklines]
99 rewrite ^(.*) https://$host$1 permanent;
102 %\subsubsection{openssl.conf settings}
104 %\subsubsection{Differences in SSL libraries: gnutls vs. openssl vs. others}
106 \subsubsection{MS IIS}
111 When trying to avoid RC4 and CBC (BEAST-Attack) and requiring perfect
112 forward secrecy, Microsoft Internet Information Server (IIS) supports
113 ECDSA, but does not support RSA for key exchange (consider ECC suite
114 B doubts\footnote{\url{http://safecurves.cr.yp.to/rigid.html}}).
116 Since \verb|ECDHE_RSA_*| is not supported, a SSL certificate based on
117 elliptic curves needs to be used.
119 The configuration of cipher suites MS IIS will use can be configured in one
120 of the following ways:
122 \item Group Policy \footnote{\url{http://msdn.microsoft.com/en-us/library/windows/desktop/bb870930(v=vs.85).aspx}}
124 \item IIS Crypto~\footnote{\url{https://www.nartac.com/Products/IISCrypto/}}
128 Table~\ref{tab:MS_IIS_Client_Support} shows the process of turning on
129 one algorithm after another and the effect on the supported Clients
130 tested using https://www.ssllabs.com.
132 \verb|SSL 3.0|, \verb|SSL 2.0| and \verb|MD5| are turned off.
133 \verb|TLS 1.0| and \verb|TLS 2.0| are turned on.
138 \begin{tabular}{|l|l|}
140 Cipher Suite & Client \\
142 \verb|TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256| & only IE 10,11, OpenSSL 1.0.1e \\
144 \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256| & Chrome 30, Opera 17, Safari 6+ \\
146 \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA| & FF 10-24, IE 8+, Safari 5, Java 7\\
149 \caption{Client support}
150 \label{tab:MS_IIS_Client_Support}
153 Table~\ref{tab:MS_IIS_Client_Support} shows the algoriths from
154 strongest to weakest and why they need to be added in this order. For
155 example insiting on SHA-2 algorithms (only first two lines) would
156 eliminate all versions of Firefox, so the last line is needed to
157 support this browser, but should be placed at the bottom, so capable
158 browsers will choose the stronger SHA-2 algorithms.
160 \verb|TLS_RSA_WITH_RC4_128_SHA| or equivalent should also be added if
161 MS Terminal Server Connection is used (make sure to use this only in a
162 trusted environment). This suite will not be used for SSL, since we do
166 % \verb|TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256| ... only supported by: IE 10,11, OpenSSL 1.0.1e
167 % \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256| ... Chrome 30, Opera 17, Safari 6+
168 % \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA| ... Firefox 10-24, IE 8+, Safari 5, Java 7
171 Not supported Clients:
179 \subsection{Mail and POP/IMAP Servers}
180 \subsubsection{Dovecot}
186 % Example: http://dovecot.org/list/dovecot/2013-October/092999.html
188 \begin{lstlisting}[breaklines]
189 ssl_cipher_list = 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EDH+CAMELLIA256:EECDH:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!AES128:!CAMELLIA128:!ECDSA:AES256-SHA'
190 ssl_prefer_server_ciphers = yes
193 Dovecot 2.1: Almost as good as dovecot 2.2. Does not support ssl\_prefer\_server\_ciphers
195 \paragraph*{Limitations}\mbox{}\\
197 Dovecot currently does not support disabling TLS compression.
199 \subsubsection{cyrus-imapd (based on 2.4.17)}
201 \paragraph*{imapd.conf}\mbox{}\\
203 To activate SSL/TLS configure your certificate with
204 \begin{lstlisting}[breaklines]
205 tls_cert_file: .../cert.pem
206 tls_key_file: .../cert.key
209 Do not forget to add necessary intermediate certificates to the .pem file.\\
211 Limiting the ciphers provided may force (especially older) clients to connect without encryption at all! Sticking to the defaults is recommended.\\
213 If you still want to force strong encryption use
214 \begin{lstlisting}[breaklines]
215 tls_cipher_list: <...recommended ciphersuite...>
218 cyrus-imapd loads hardcoded 1024 bit DH parameters using get\_rfc2409\_prime\_1024() by default. If you want to load your own DH parameters add them PEM encoded to the certificate file given in tls\_cert\_file. Do not forget to re-add them after updating your certificate.
220 \paragraph*{cyrus.conf}\mbox{}\\
222 To support POP3/IMAP on ports 110/143 with STARTTLS add
223 \begin{lstlisting}[breaklines]
224 imap cmd="imapd" listen="imap" prefork=3
225 pop3 cmd="pop3d" listen="pop3" prefork=1
227 to the SERVICES section.\\
229 To support POP3S/IMAPS on ports 995/993 add
230 \begin{lstlisting}[breaklines]
231 imaps cmd="imapd -s" listen="imaps" prefork=3
232 pop3s cmd="pop3d -s" listen="pop3s" prefork=1
235 \paragraph*{Limitations}\mbox{}\\
237 cyrus-imapd currently (2.4.17, trunk) does not support elliptic curves. ECDHE will not work even if defined in your cipher list.
239 Currently there is no way to prefer server ciphers or to disable compression.\\
241 There is a working patch for all three features:
242 \url{https://bugzilla.cyrusimap.org/show_bug.cgi?id=3823}\\
244 There is no way to prevent unencrypted connections on the STARTTLS ports. You can prevent usage of plaintext login by setting
245 \begin{lstlisting}[breaklines]
248 in imapd.conf. But note that SASL PLAIN/LOGIN is still available!\\
253 \todo{write this subsubsection}
255 Another option to secure IMAPs servers is to place them behind an stunnel server.
257 % XXX config von Adi?
259 % ciphers = EDH+CAMELLIA256:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:-AES128:!CAMELLIA128:!ECDSA:AES256-SHA:EDH+AES128;
260 % options = CIPHER_SERVER_PREFERENCE
263 \subsubsection{Postfix}
267 First, you need to generate Diffie Hellman parameters (please first take a look at the section \ref{section:PRNG}):
269 \todo{FIXME: this is a really weak setting! See also: http://postfix.1071664.n5.nabble.com/postfix-hardening-what-can-we-do-td61874.html}
270 \begin{lstlisting}[breaklines]
271 % openssl gendh -out /etc/postfix/dh_param_512.pem -2 512
272 % openssl gendh -out /etc/postfix/dh_param_1024.pem -2 1024
275 Next, we specify these DH parameters in the postfix config file:
277 \begin{lstlisting}[breaklines]
278 smtpd_tls_dh512_param_file = /etc/postfix/dh_param_512.pem
279 smtpd_tls_dh1024_param_file = /etc/postfix/dh_param_1024.pem
282 You usually don't want restrictions on the ciphers for opportunistic
283 encryption, because any encryption is better than plain text.
285 For submission (Port 587) or other special cases, however, you want to
286 enforce strong encryption. In addition to the below entries in
287 main.cf, you need to enable ``mandatory`` encryption for the
288 respective service, e.g. by adding ``-o
289 smtpd\_tls\_security\_level=encrypt'' to the submission smtpd in
292 % don't -- this influences opportunistic encryption
293 % smtpd_tls_protocols = !SSLv2, !SSLv3
295 \begin{lstlisting}[breaklines]
296 smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
297 tls_ssl_options=NO_COMPRESSION
298 smtpd_tls_mandatory_ciphers=high
299 tls_high_cipherlist='EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EDH+CAMELLIA256:EECDH:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!AES128:!CAMELLIA128:!ECDSA:AES256-SHA'
300 tls_preempt_cipherlist = yes
301 tls_random_source = dev:/dev/urandom
302 %% NOTE: might want to have /dev/random here + Haveged
305 For those users, who want to use ECC key exchange, it is possible to specify this via:
306 \begin{lstlisting}[breaklines]
307 smtpd_tls_eecdh_grade = ultra
310 You can check the settings by specifying smtpd\_tls\_loglevel = 1 and then check the selected ciphers with the following command:
311 \begin{lstlisting}[breaklines]
312 $ zegrep "TLS connection established from.*with cipher" /var/log/mail.log | \
313 > awk '{printf("%s %s %s %s\n", $12, $13, $14, $15)}' | sort | uniq -c | sort -n
314 1 SSLv3 with cipher DHE-RSA-AES256-SHA
315 23 TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384
316 60 TLSv1 with cipher ECDHE-RSA-AES256-SHA
317 270 TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384
318 335 TLSv1 with cipher DHE-RSA-AES256-SHA
321 Source: \url{http://www.postfix.org/TLS_README.html}
323 \paragraph*{Limitations}\mbox{}\\
325 tls\_ssl\_options is supported from Postfix 2.11 onwards. You can
326 leave the statement in the configuration for older versions, it will
329 tls\_preempt\_cipherlist is supported from Postfix 2.8 onwards. Again,
330 you can leave the statement in for older versions.
332 \subsubsection{Exim (based on 4.82)}
334 It is highly recommended to read
336 \url{http://exim.org/exim-html-current/doc/html/spec_html/ch-encrypted_smtp_connections_using_tlsssl.html}
342 \subparagraph*{server mode (incoming)}\mbox{}\\
344 In the main config section of exim add:
346 \begin{lstlisting}[breaklines]
347 tls_certificate = ..../cert.pem
348 tls_privatekey = ..../cert.key
350 don't forget to add intermediate certificates to the .pem file if needed.\\
352 Tell exim to advertise STARTTLS in the EHLO answer:
353 \begin{lstlisting}[breaklines]
354 tls_advertise_hosts = *
357 If you want to support legacy SMTPS on port 465, and STARTTLS on smtp(25)/submission(587) ports set
358 \begin{lstlisting}[breaklines]
359 daemon_smtp_ports = smtp : smtps : submission
360 tls_on_connect_ports = 465
363 Exim already disables SSLv2 by default. We recommend to add
364 \begin{lstlisting}[breaklines]
365 openssl_options = +no_sslv2 +no_compression +cipher_server_preference
368 It is not advisable to restrict the default cipher list for opportunistic encryption as used by SMTP. Do not use cipher lists recommended for HTTPS! If you still want to define one please consult the Exim documentation or ask on the exim-users mailinglist.\\
369 % Exim maintainers do not recommend to change default ciphers
372 %\begin{lstlisting}[breaklines]
373 % tls_require_ciphers = <...recommended ciphersuite...>
376 If you want to request and verify client certificates from sending hosts set
377 \begin{lstlisting}[breaklines]
378 tls_verify_certificates = /etc/pki/tls/certs/ca-bundle.crt
379 tls_try_verify_hosts = *
382 tls\_try\_verify\_hosts only reports the result to your logfile. If you want to disconnect such clients you have to use
383 \begin{lstlisting}[breaklines]
387 You do not need to set dh\_parameters. exim with OpenSSL uses a 2048bit default prime defined in section 2.2 of RFC 5114.
388 If you want to set your own DH parameters please read the TLS documentation of exim.\\
390 The cipher used is written to the logfiles by default. You may want to add
391 \begin{lstlisting}[breaklines]
392 log_selector = <....whatever your log_selector already contains...> \
393 +tls_certificate_verified +tls_peerdn +tls_sni
395 to get even more information logged.
397 \subparagraph*{client mode (outgoing)}\mbox{}\\
399 Exim uses opportunistic encryption in the SMTP transport by default.
401 Client mode settings have to be done in the configuration section of the smtp transport (driver = smtp).
403 If you want to use a client certificate (most server certificates can be used as client certificate, too) set
404 \begin{lstlisting}[breaklines]
405 tls_certificate = .../cert.pem
406 tls_privatekey = .../cert.key
408 This is recommended for MTA-MTA traffic.\\
410 %If you want to limit used ciphers set
411 %\begin{lstlisting}[breaklines]
412 % tls_require_ciphers = <...recommended ciphersuite...>
414 % Exim Maintainers do not recommend ciphers. We shouldn't do so, too.
415 Do not limit ciphers without a very good reason. In the worst case you end up without encryption at all instead of some weak encryption. Please consult the Exim documentation if you really need to define ciphers.
417 \paragraph*{GnuTLS}\mbox{}\\
419 GnuTLS is different in only some respects to OpenSSL:
421 \item tls\_require\_ciphers needs a GnuTLS priority string instead of a cipher list. It is recommended to use the defaults by not defining this option. It highly depends on the version of GnuTLS used. Therefore it is not advisable to change the defaults.
422 \item There is no option like openssl\_options
425 \paragraph*{Limit SMTP AUTH to SSL connections only}\mbox{}\\
427 It is highly recommended to limit SMTP AUTH to SSL connections only. To do so add
428 \begin{lstlisting}[breaklines]
429 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
431 to every authenticator defined.
433 \paragraph*{Exim string expansion}\mbox{}\\
435 Note that most of the options accept expansion strings. This way you can eg. set cipher lists or STARTTLS advertisment conditionally. Please follow the link to the official Exim documentation to get more information.
437 \paragraph*{Limitations}\mbox{}\\
439 Exim currently (4.82) does not support elliptic curves with OpenSSL. This means that ECDHE is not used even if defined in your cipher list.
440 There already is a working patch to provide support:\\
441 \url{http://bugs.exim.org/show_bug.cgi?id=1397}
443 \subsubsection{SMTP: opportunistic TLS}
445 \todo{write this subsubsection}
447 % do we need to documment starttls in detail?
448 %\subsubsection{starttls?}
452 \begin{lstlisting}[breaklines]
453 RSAAuthentication yes
456 HostKey /etc/ssh/ssh_host_rsa_key
458 MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
459 KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1
462 % XXX: curve25519-sha256@libssh.org only available upstream(!)
463 Note: older linux systems won't support SHA2, PuTTY does not support RIPE-MD160.
469 \todo{write this subsection}
472 \todo{write this subsection}
474 \subsection{PGP/ GPG - Pretty Good Privacy}
476 \todo{write this subsection -- this is still only a draft!!}
483 %%% TeX-master: "applied-crypto-hardening"