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
196 \subsubsection{cyrus-imapd (based on 2.4.17)}
198 \paragraph*{imapd.conf}\mbox{}\\
200 To activate SSL/TLS configure your certificate with
201 \begin{lstlisting}[breaklines]
202 tls_cert_file: .../cert.pem
203 tls_key_file: .../cert.key
206 Do not forget to add necessary intermediate certificates to the .pem file.\\
208 Limiting the ciphers provided may force (especially older) clients to connect without encryption at all! Sticking to the defaults is recommended.\\
210 If you still want to force strong encryption use
211 \begin{lstlisting}[breaklines]
212 tls_cipher_list: <...recommended ciphersuite...>
215 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.
217 \paragraph*{cyrus.conf}\mbox{}\\
219 To support POP3/IMAP on ports 110/143 with STARTTLS add
220 \begin{lstlisting}[breaklines]
221 imap cmd="imapd" listen="imap" prefork=3
222 pop3 cmd="pop3d" listen="pop3" prefork=1
224 to the SERVICES section.\\
226 To support POP3S/IMAPS on ports 995/993 add
227 \begin{lstlisting}[breaklines]
228 imaps cmd="imapd -s" listen="imaps" prefork=3
229 pop3s cmd="pop3d -s" listen="pop3s" prefork=1
232 \paragraph*{Limitations}\mbox{}\\
234 cyrus-imapd currently (2.4.17, trunk) does not support elliptic curves. ECDHE will not work even if defined in your cipher list.
235 A working patch to provide limited support exists (NID\_X9\_62\_prime256v1 only):
236 \url{https://bugzilla.cyrusimap.org/show_bug.cgi?id=3822}\\
238 Currently there is no way to prefer server ciphers.\\
240 There is no way to prevent unencrypted connections on the STARTTLS ports. You can prevent usage of plaintext login by setting
241 \begin{lstlisting}[breaklines]
244 in imapd.conf. But note that SASL PLAIN/LOGIN is still available!\\
249 \todo{write this subsubsection}
251 Another option to secure IMAPs servers is to place them behind an stunnel server.
253 % XXX config von Adi?
255 % ciphers = EDH+CAMELLIA256:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:-AES128:!CAMELLIA128:!ECDSA:AES256-SHA:EDH+AES128;
256 % options = CIPHER_SERVER_PREFERENCE
259 \subsubsection{Postfix}
263 First, you need to generate Diffie Hellman parameters (please first take a look at the section \ref{section:PRNG}):
265 \todo{FIXME: this is a really weak setting! See also: http://postfix.1071664.n5.nabble.com/postfix-hardening-what-can-we-do-td61874.html}
266 \begin{lstlisting}[breaklines]
267 % openssl gendh -out /etc/postfix/dh_param_512.pem -2 512
268 % openssl gendh -out /etc/postfix/dh_param_1024.pem -2 1024
271 Next, we specify these DH parameters in the postfix config file:
273 \begin{lstlisting}[breaklines]
274 smtpd_tls_dh512_param_file = /etc/postfix/dh_param_512.pem
275 smtpd_tls_dh1024_param_file = /etc/postfix/dh_param_1024.pem
278 You usually don't want restrictions on the ciphers for opportunistic
279 encryption, because any encryption is better than plain text.
281 For submission (Port 587) or other special cases, however, you want to
282 enforce strong encryption. In addition to the below entries in
283 main.cf, you need to enable ``mandatory`` encryption for the
284 respective service, e.g. by adding ``-o
285 smtpd\_tls\_security\_level=encrypt'' to the submission smtpd in
288 % don't -- this influences opportunistic encryption
289 % smtpd_tls_protocols = !SSLv2, !SSLv3
291 \begin{lstlisting}[breaklines]
292 smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
293 tls_ssl_options=NO_COMPRESSION
294 smtpd_tls_mandatory_ciphers=high
295 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'
296 tls_preempt_cipherlist = yes
297 tls_random_source = dev:/dev/urandom
298 %% NOTE: might want to have /dev/random here + Haveged
301 For those users, who want to use ECC key exchange, it is possible to specify this via:
302 \begin{lstlisting}[breaklines]
303 smtpd_tls_eecdh_grade = ultra
306 You can check the settings by specifying smtpd\_tls\_loglevel = 1 and then check the selected ciphers with the following command:
307 \begin{lstlisting}[breaklines]
308 $ zegrep "TLS connection established from.*with cipher" /var/log/mail.log | \
309 > awk '{printf("%s %s %s %s\n", $12, $13, $14, $15)}' | sort | uniq -c | sort -n
310 1 SSLv3 with cipher DHE-RSA-AES256-SHA
311 23 TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384
312 60 TLSv1 with cipher ECDHE-RSA-AES256-SHA
313 270 TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384
314 335 TLSv1 with cipher DHE-RSA-AES256-SHA
317 Source: \url{http://www.postfix.org/TLS_README.html}
319 \subsubsection{Exim (based on 4.82)}
321 It is highly recommended to read
323 \url{http://exim.org/exim-html-current/doc/html/spec_html/ch-encrypted_smtp_connections_using_tlsssl.html}
329 \subparagraph*{server mode (incoming)}\mbox{}\\
331 In the main config section of exim add:
333 \begin{lstlisting}[breaklines]
334 tls_certificate = ..../cert.pem
335 tls_privatekey = ..../cert.key
337 don't forget to add intermediate certificates to the .pem file if needed.\\
339 Tell exim to advertise STARTTLS in the EHLO answer:
340 \begin{lstlisting}[breaklines]
341 tls_advertise_hosts = *
344 If you want to support legacy SMTPS on port 465, and STARTTLS on smtp(25)/submission(587) ports set
345 \begin{lstlisting}[breaklines]
346 daemon_smtp_ports = smtp : smtps : submission
347 tls_on_connect_ports = 465
350 Exim already disables SSLv2 by default. We recommend to add
351 \begin{lstlisting}[breaklines]
352 openssl_options = +no_sslv2 +no_compression +cipher_server_preference
355 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.\\
356 % Exim maintainers do not recommend to change default ciphers
359 %\begin{lstlisting}[breaklines]
360 % tls_require_ciphers = <...recommended ciphersuite...>
363 If you want to request and verify client certificates from sending hosts set
364 \begin{lstlisting}[breaklines]
365 tls_verify_certificates = /etc/pki/tls/certs/ca-bundle.crt
366 tls_try_verify_hosts = *
369 tls\_try\_verify\_hosts only reports the result to your logfile. If you want to disconnect such clients you have to use
370 \begin{lstlisting}[breaklines]
374 You do not need to set dh\_parameters. exim with OpenSSL uses a 2048bit default prime defined in section 2.2 of RFC 5114.
375 If you want to set your own DH parameters please read the TLS documentation of exim.\\
377 The cipher used is written to the logfiles by default. You may want to add
378 \begin{lstlisting}[breaklines]
379 log_selector = <....whatever your log_selector already contains...> \
380 +tls_certificate_verified +tls_peerdn +tls_sni
382 to get even more information logged.
384 \subparagraph*{client mode (outgoing)}\mbox{}\\
386 Exim uses opportunistic encryption in the SMTP transport by default.
388 Client mode settings have to be done in the configuration section of the smtp transport (driver = smtp).
390 If you want to use a client certificate (most server certificates can be used as client certificate, too) set
391 \begin{lstlisting}[breaklines]
392 tls_certificate = .../cert.pem
393 tls_privatekey = .../cert.key
395 This is recommended for MTA-MTA traffic.\\
397 %If you want to limit used ciphers set
398 %\begin{lstlisting}[breaklines]
399 % tls_require_ciphers = <...recommended ciphersuite...>
401 % Exim Maintainers do not recommend ciphers. We shouldn't do so, too.
402 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.
404 \paragraph*{GnuTLS}\mbox{}\\
406 GnuTLS is different in only some respects to OpenSSL:
408 \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.
409 \item There is no option like openssl\_options
412 \paragraph*{Limit SMTP AUTH to SSL connections only}\mbox{}\\
414 It is highly recommended to limit SMTP AUTH to SSL connections only. To do so add
415 \begin{lstlisting}[breaklines]
416 server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
418 to every authenticator defined.
420 \paragraph*{Exim string expansion}\mbox{}\\
422 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.
424 \paragraph*{Limitations}\mbox{}\\
426 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.
427 There already is a working patch to provide support:\\
428 \url{http://bugs.exim.org/show_bug.cgi?id=1397}
430 \subsubsection{SMTP: opportunistic TLS}
432 \todo{write this subsubsection}
434 % do we need to documment starttls in detail?
435 %\subsubsection{starttls?}
439 \begin{lstlisting}[breaklines]
440 RSAAuthentication yes
443 HostKey /etc/ssh/ssh_host_rsa_key
445 MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
446 KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1
449 % XXX: curve25519-sha256@libssh.org only available upstream(!)
450 Note: older linux systems won't support SHA2, PuTTY does not support RIPE-MD160.
456 \todo{write this subsection}
459 \todo{write this subsection}
461 \subsection{PGP/ GPG - Pretty Good Privacy}
463 \todo{write this subsection -- this is still only a draft!!}
470 %%% TeX-master: "applied-crypto-hardening"