no need for "\" anymore
[ach-master.git] / src / practical_settings.tex
index ef63104..08a4e32 100644 (file)
 \section{Recommendations on practical settings}
 
 
-\subsection{SSL}
-
-At the time of this writing, SSL is defined in RFCs:   
-
-\begin{itemize}
-\item RFC2246 - TLS1.0         
-\item RFC3268 - AES            
-\item RFC4132 - Camelia                
-\item RFC4162 - SEED           
-\item RFC4279 - PSK            
-\item RFC4346 - TLS 1.1                
-\item RFC4492 - ECC            
-\item RFC4785 - PSK\_NULL              
-\item RFC5246 - TLS 1.2                
-\item RFC5288 - AES\_GCM               
-\item RFC5289 - AES\_GCM\_SHA2\_ECC            
-\item RFC5430 - Suite B                
-\item RFC5487 - GCM\_PSK               
-\item RFC5489 - ECDHE\_PSK             
-\item RFC5932 - Camelia                
-\item RFC6101 - SSL 3.0                
-\item RFC6209 - ARIA           
-\item RFC6367 - Camelia                
-\item RFC6655 - AES\_CCM               
-\item RFC7027 - Brainpool Curves               
-\end{itemize}
-
-\subsubsection{Overview of SSL Server settings}
-
-Most Server software (Webservers, Mail servers, etc.) can be configured to prefer certain cipher suites over others. 
-We followed the recommendations by Ivan Ristic's \cite{RisticSSLTLSDeploymentBestPractices}SSL/TLS Deployment Best Practices document (section 2.2 "Use Secure Protocols") and arrived at a list of recommended cipher suites for SSL enabled servers.
-
-The results of following his adivce is a categorisation of cipher suites.
-
-\begin{center}
-\begin{tabular}{| l | l | l | l | l|}
-\hline
-& Version   & Key\_Exchange  & Cipher    & MAC       \\ \hline
-\cellcolor{green}prefer  & TLS 1.2   & DHE\_DSS   & AES\_256\_GCM   & SHA384        \\ \hline
-    &   & DHE\_RSA   & AES\_256\_CCM   & SHA256        \\ \hline
-    &   & ECDHE\_ECDSA   & AES\_256\_CBC   &       \\ \hline
-    &   & ECDHE\_RSA &   &       \\ \hline
-    &   &   &   &       \\ \hline
-\cellcolor{orange}consider    & TLS 1.1   & DH\_DSS    & AES\_128\_GCM   & SHA       \\ \hline
-    & TLS 1.0   & DH\_RSA    & AES\_128\_CCM   &       \\ \hline
-    &   & ECDH\_ECDSA    & AES\_128\_CBC   &       \\ \hline
-    &   & ECDH\_RSA  & CAMELLIA\_256\_CBC  &       \\ \hline
-    &   & RSA   & CAMELLIA\_128\_CBC  &       \\ \hline
-    &   &   &   &       \\ \hline
-\cellcolor{red}avoid   
-& SSL 3.0   & NULL  & NULL  & NULL      \\ \hline
-    &   & DH\_anon   & RC4\_128   & MD5       \\ \hline
-    &   & ECDH\_anon & 3DES\_EDE\_CBC  &       \\ \hline
-    &   &   & DES\_CBC   &       \\ \hline
-    &   &   &   &       \\ \hline
-\cellcolor{blue}{\color{white}special }
-&   & PSK   & CAMELLIA\_256\_GCM  &       \\ \hline
-    &   & DHE\_PSK   & CAMELLIA\_128\_GCM  &       \\ \hline
-    &   & RSA\_PSK   & ARIA\_256\_GCM  &       \\ \hline
-    &   & ECDHE\_PSK & ARIA\_256\_CBC  &       \\ \hline
-    &   &   & ARIA\_128\_GCM  &       \\ \hline
-    &   &   & ARIA\_128\_CBC  &       \\ \hline
-    &   &   & SEED  &       \\ \hline
-\end{tabular}
-\end{center}
-
-
-Note that the entries marked as "special" are cipher suites which are not common to all clients (webbrowsers etc).
-
-
-\subsubsection{Clients}
-Next we tested the cipher suites above on the following clients:
-
-\begin{itemize}
-\item Chrome 30.0.1599.101 Mac OS X 10.9
-\item Safari 7.0 Mac OS X 10.9
-\item Firefox 25.0 Mac OS X 10.9
-\item Internet Explorer 10 Windows 7
-\item Apple iOS 7.0.3
-\end{itemize}
-
-
-The result of testing the cipher suites with these clients gives us the following result and a preference order. 
-Should a client not be able to use a specific cipher suite, it will fall back to the next possible entry as given by the ordering.
-
-\begin{table}
-    \begin{tabular}{|l|l|l|l|l|}
-    \hline
-    Pref & Cipher Suite                                   & ID         & Browser                     \\ \hline
-    1    & TLS\_ECDHE\_ECDSA\_WITH\_AES\_256\_CBC\_SHA384 &     0xC024 & Safari                      \\ \hline
-    2    & TLS\_ECDHE\_RSA\_WITH\_AES\_256\_CBC\_SHA384   &     0xC028 & Safari                      \\ \hline
-    3    & TLS\_DHE\_RSA\_WITH\_AES\_256\_CBC\_SHA256     &     0x006B & Safari, Chrome              \\ \hline
-    4    & TLS\_ECDHE\_ECDSA\_WITH\_AES\_256\_CBC\_SHA    &     0xC00A & Safari, Chrome, Firefox, IE \\ \hline
-    5    & TLS\_ECDHE\_RSA\_WITH\_AES\_256\_CBC\_SHA      &     0xC014 & Safari, Chrome, Firefox, IE \\ \hline
-    6    & TLS\_DHE\_RSA\_WITH\_AES\_256\_CBC\_SHA        &     0x0039 & Safari, Chrome, Firefox     \\ \hline
-    7    & TLS\_DHE\_DSS\_WITH\_AES\_256\_CBC\_SHA        &     0x0038 & Firefox, IE                 \\ \hline
-    8    & TLS\_DHE\_RSA\_WITH\_CAMELLIA\_256\_CBC\_SHA   &     0x0088 & Firefox                     \\ \hline
-    9    & TLS\_DHE\_DSS\_WITH\_CAMELLIA\_256\_CBC\_SHA   &     0x0087 & Firefox                     \\ \hline
-    \end{tabular}
-\end{table}
+\subsection{Webservers}
+
+\subsubsection{Apache}
+
+
+
+%-All +TLSv1.1 +TLSv1.2
+\begin{lstlisting}[breaklines]
+  SSLProtocol All -SSLv2 -SSLv3 
+  SSLHonorCipherOrder On
+  SSLCompression off
+  # Add six earth month HSTS header for all users...
+  Header add Strict-Transport-Security "max-age=15768000"
+  # If you want to protect all subdomains, use the following header
+  # ALL subdomains HAVE TO support https if you use this!
+  # Strict-Transport-Security: max-age=15768000 ; includeSubDomains
+
+  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'
+\end{lstlisting}
+
+Note again, that any cipher suite starting with ECDHE  can be omitted in case of doubt.
+%% XXX NOTE TO SELF: remove from future automatically generated lists!
+
+You should redirect everything to httpS:// if possible. In Apache you can do this with the following setting inside of a VirtualHost environment:
+
+\begin{lstlisting}[breaklines]
+  <VirtualHost *:80>
+   #...
+   RewriteEngine On
+        RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=permanent]
+   #...
+  </VirtualHost>
+\end{lstlisting}
+
+%XXXX   ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
+
+
+\subsubsection{lighttpd}
+
+
+
+%% Note: need to be checked / reviewed
+
+%% Complete ssl.cipher-list with same algo than Apache
+%% Currently this is only the default proposed lighttpd config for SSL
+\begin{lstlisting}[breaklines]
+  $SERVER["socket"] == "0.0.0.0:443" {
+    ssl.engine  = "enable"
+    ssl.use-sslv2 = "disable"
+    ssl.use-sslv3 = "disable"
+    ssl.use-compression = "disable"
+    ssl.pemfile = "/etc/lighttpd/server.pem"
+    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'
+    ssl.honor-cipher-order = "enable"
+  }
+\end{lstlisting}
+
+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}}
+
+\begin{lstlisting}[breaklines]
+  $HTTP["scheme"] == "http" {
+    # capture vhost name with regex conditiona -> %0 in redirect pattern
+    # must be the most inner block to the redirect rule
+    $HTTP["host"] =~ ".*" {
+        url.redirect = (".*" => "https://%0$0")
+    }
+  }
+\end{lstlisting}
+
+\subsubsection{nginx}
 
-\FloatBarrier
 
-The same data again, specifying the OpenSSL name:
+
+\begin{lstlisting}[breaklines]
+  ssl_prefer_server_ciphers on;
+  ssl_protocols -SSLv2 -SSLv3; 
+  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';
+  add_header Strict-Transport-Security max-age=2592000;
+  add_header X-Frame-Options DENY;
+\end{lstlisting}
+
+%% XXX FIXME: do we need to specify dhparams? Parameter: ssl_dhparam = file. See: http://wiki.nginx.org/HttpSslModule#ssl_protocols
+
+
+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:
+
+\begin{lstlisting}[breaklines]
+  ssl_ecdh_curve          sect571k1;
+\end{lstlisting}
+
+You should redirect everything to httpS:// if possible. In Nginx you can do this with the following setting:
+
+\begin{lstlisting}[breaklines]
+  rewrite     ^(.*)   https://$host$1 permanent;
+\end{lstlisting}
+
+%\subsubsection{openssl.conf settings}
+
+%\subsubsection{Differences in SSL libraries: gnutls vs. openssl vs. others}
+
+\subsubsection{MS IIS}
+\label{sec:ms-iis}
+
+
+
+When trying to avoid RC4 and CBC (BEAST-Attack) and requiring perfect
+forward secrecy, Microsoft Internet Information Server (IIS) supports
+ECDSA, but does not support RSA for key exchange (consider ECC suite
+B doubts\footnote{\url{http://safecurves.cr.yp.to/rigid.html}}).
+
+Since \verb|ECDHE_RSA_*| is not supported, a SSL certificate based on
+elliptic curves needs to be used.
+
+The configuration of cipher suites MS IIS will use can be configured in one
+of the following ways:
+\begin{enumerate}
+\item Group Policy \footnote{\url{http://msdn.microsoft.com/en-us/library/windows/desktop/bb870930(v=vs.85).aspx}}
+\item Registry
+\item IIS Crypto~\footnote{\url{https://www.nartac.com/Products/IISCrypto/}}
+\end{enumerate}
+
+
+Table~\ref{tab:MS_IIS_Client_Support} shows the process of turning on
+one algorithm after another and the effect on the supported Clients
+tested using https://www.ssllabs.com.
+
+\verb|SSL 3.0|, \verb|SSL 2.0| and \verb|MD5| are turned off.
+\verb|TLS 1.0| and \verb|TLS 2.0| are turned on.
 
 \begin{table}[h]
-    \begin{tabular}{|l|l|l|}
+  \centering
+  \small
+  \begin{tabular}{|l|l|}
+    \hline
+    Cipher Suite & Client \\
     \hline
-    Cipher Suite                                   & ID            & OpenSSL Name                  \\ \hline
-    TLS\_ECDHE\_ECDSA\_WITH\_AES\_256\_CBC\_SHA384 &     0xC024 &     ECDHE-ECDSA-AES256-SHA384 \\ \hline
-    TLS\_ECDHE\_RSA\_WITH\_AES\_256\_CBC\_SHA384   &     0xC028 &     ECDHE-RSA-AES256-SHA384   \\ \hline
-    TLS\_DHE\_RSA\_WITH\_AES\_256\_CBC\_SHA256     &     0x006B &     DHE-RSA-AES256-SHA256     \\ \hline
-    TLS\_ECDHE\_ECDSA\_WITH\_AES\_256\_CBC\_SHA    &     0xC00A &     ECDHE-ECDSA-AES256-SHA    \\ \hline
-    TLS\_ECDHE\_RSA\_WITH\_AES\_256\_CBC\_SHA      &     0xC014 &     ECDHE-RSA-AES256-SHA      \\ \hline
-    TLS\_DHE\_RSA\_WITH\_AES\_256\_CBC\_SHA        &     0x0039 &     DHE-RSA-AES256-SHA        \\ \hline
-    TLS\_DHE\_DSS\_WITH\_AES\_256\_CBC\_SHA        &     0x0038 &     DHE-DSS-AES256-SHA        \\ \hline
-    TLS\_DHE\_RSA\_WITH\_CAMELLIA\_256\_CBC\_SHA   &     0x0088 &     DHE-RSA-CAMELLIA256-SHA   \\ \hline
-    TLS\_DHE\_DSS\_WITH\_CAMELLIA\_256\_CBC\_SHA   &     0x0087 &     DHE-DSS-CAMELLIA256-SHA   \\ \hline
-    \end{tabular}
+    \verb|TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256| & only IE 10,11, OpenSSL 1.0.1e \\
+    \hline
+    \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256| & Chrome 30, Opera 17, Safari 6+ \\
+    \hline
+    \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA| & FF 10-24, IE 8+, Safari 5, Java 7\\
+    \hline
+  \end{tabular}
+  \caption{Client support}
+  \label{tab:MS_IIS_Client_Support}
 \end{table}
 
+Table~\ref{tab:MS_IIS_Client_Support} shows the algoriths from
+strongest to weakest and why they need to be added in this order. For
+example insiting on SHA-2 algorithms (only first two lines) would
+eliminate all versions of Firefox, so the last line is needed to
+support this browser, but should be placed at the bottom, so capable
+browsers will choose the stronger SHA-2 algorithms.
 
-Based on this ordering, we can now define the corresponding settings for servers. We will start with the most common web servers
+\verb|TLS_RSA_WITH_RC4_128_SHA| or equivalent should also be added if
+MS Terminal Server Connection is used (make sure to use this only in a
+trusted environment). This suite will not be used for SSL, since we do
+not use a RSA Key.
 
-\subsubsection{apache}
 
-\subsubsection{nginx}
+% \verb|TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256| ... only supported by: IE 10,11, OpenSSL 1.0.1e
+% \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256| ... Chrome 30, Opera 17, Safari 6+
+% \verb|TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA| ... Firefox 10-24, IE 8+, Safari 5, Java 7
 
 
-\subsubsection{openssl.conf settings}
+Not supported Clients:
+\begin{enumerate}
+\item Java 6
+\item WinXP
+\item Bing
+\end{enumerate}
+
+
+\subsection{Mail and POP/IMAP Servers}
+\subsubsection{Dovecot}
+
+
+
+Dovecot 2.2:
+
+% Example: http://dovecot.org/list/dovecot/2013-October/092999.html
+
+\begin{lstlisting}[breaklines]
+  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'
+  ssl_prefer_server_ciphers = yes
+\end{lstlisting}
+
+Dovecot 2.1: Almost as good as dovecot 2.2. Does not support ssl\_prefer\_server\_ciphers
+
+
+\subsubsection{Cyrus}
+
+\todo{write this subsubsection}
+
+\subsubsection{UW}
+
+\todo{write this subsubsection}
+
+Another option to secure IMAPs servers is to place them behind an stunnel server. 
+
+% XXX config von Adi?
+% sslVersion = TLSv1
+% ciphers = EDH+CAMELLIA256:EDH+aRSA:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:-AES128:!CAMELLIA128:!ECDSA:AES256-SHA:EDH+AES128;
+% options = CIPHER_SERVER_PREFERENCE
+% TIMEOUTclose = 1
+
+\subsubsection{Postfix}
 
-%\subsubsection{Differences in SSL libraries: gnutls vs. openssl vs. others}
 
-\subsubsection{IMAPS}
+
+First, you need to generate Diffie Hellman parameters (please first take a look at the section \ref{section:PRNG}):
+
+\begin{lstlisting}[breaklines]
+  % openssl gendh -out /etc/postfix/dh_param_512.pem -2 512
+  % openssl gendh -out /etc/postfix/dh_param_1024.pem -2 1024
+\end{lstlisting}
+
+Next, we specify these DH parameters in the postfix config file:
+
+\begin{lstlisting}[breaklines]
+  smtpd_tls_dh512_param_file = /etc/postfix/dh_param_512.pem
+  smtpd_tls_dh1024_param_file = /etc/postfix/dh_param_1024.pem
+\end{lstlisting}
+
+You usually don't want restrictions on the ciphers for opportunistic
+encryption, because any encryption is better than plain text. 
+
+For submission (Port 587) or other special cases, however, you want to
+enforce strong encryption. In addition to the below entries in
+main.cf, you need to enable ``mandatory`` encryption for the
+respective service, e.g. by adding ``-o
+smtpd\_tls\_security\_level=encrypt'' to the submission smtpd in
+master.cf.
+
+% don't -- this influences opportunistic encryption
+%  smtpd_tls_protocols = !SSLv2, !SSLv3
+
+\begin{lstlisting}[breaklines]
+  smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
+  tls_ssl_options=NO_COMPRESSION
+  smtpd_tls_mandatory_ciphers=high
+  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'
+  tls_preempt_cipherlist = yes
+  tls_random_source = dev:/dev/urandom         
+    %% NOTE: might want to have /dev/random here + Haveged
+\end{lstlisting}
+  
+For those users, who want to use ECC key exchange, it is possible to specify this via:
+\begin{lstlisting}[breaklines]
+  smtpd_tls_eecdh_grade = ultra
+\end{lstlisting}
+
+You can check the settings by specifying  smtpd\_tls\_loglevel = 1 and then check the selected ciphers with the following command:
+\begin{lstlisting}[breaklines]
+$ zegrep "TLS connection established from.*with cipher" /var/log/mail.log | \
+> awk '{printf("%s %s %s %s\n", $12, $13, $14, $15)}' | sort | uniq -c | sort -n
+      1 SSLv3 with cipher DHE-RSA-AES256-SHA
+     23 TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384
+     60 TLSv1 with cipher ECDHE-RSA-AES256-SHA
+    270 TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384
+    335 TLSv1 with cipher DHE-RSA-AES256-SHA
+\end{lstlisting}
+
+Source: \url{http://www.postfix.org/TLS_README.html}
+
 \subsubsection{SMTP: opportunistic TLS}
+
+\todo{write this subsubsection}
+
 % do we need to documment starttls in detail?
 %\subsubsection{starttls?}
 
 \subsection{SSH}
 
+\begin{lstlisting}[breaklines]
+       RSAAuthentication yes
+       PermitRootLogin no
+       StrictModes yes
+       HostKey /etc/ssh/ssh_host_rsa_key
+       Ciphers aes256-ctr
+       MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
+       KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1
+\end{lstlisting}
+
+% XXX: curve25519-sha256@libssh.org only available upstream(!)
+Note: older linux systems won't support SHA2, PuTTY does not support RIPE-MD160.
+
 \subsection{OpenVPN}
 
+\todo{write this subsection}
+
+\subsection{IPSec}
+\todo{write this subsection}
+
 \subsection{PGP}
 
-\subsection{PRNG settings}
+\todo{write this subsection}
+
+
+
+%%% Local Variables: 
+%%% mode: latex
+%%% TeX-master: "applied-crypto-hardening"
+%%% End: