7bf89135fc3494e08bbf33545f53c0318a7e51f9
[ach-master.git] / src / practical_settings / kerberos.tex
1 This section discusses various implementations of the Kerberos 5 authentication protocol
2 on Unix and Unix-like systems as well as on Microsoft Windows. 
3
4 \subsection{Overview}
5 \label{subsection:kerberos_overview}
6
7 Kerberos provides mutual authentication of two communicating parties, e.g. a user using a network service. The authentication process is mediated by a trusted third party, the Kerberos key distribution centre (KDC). Kerberos implements secure single-sign-on across a large number of network protocols and operating systems. Optionally, Kerberos can be used to create encrypted communications channels between the user and service.
8
9 \paragraph{Recommended reading}
10 An understanding of the Kerberos protocol is necessary for properly implementing a Kerberos setup. Also, in the following section some knowledge about the inner workings of Kerberos is assumed. Therefore we strongly recommend reading this excellent introduction first: \url{http://gost.isi.edu/publications/kerberos-neuman-tso.html}.
11 No further overview over Kerberos terminology and functions will be provided, for a discussion and a selection of relevant papers refer to \url{http://web.mit.edu/kerberos/papers.html}.
12
13 % describe realm, login, ticket exchanges here? would be quite lengthy and necessarily incomplete, so currently left out
14
15 The Kerberos protocol over time has been extended with a variety of extensions and Kerberos implementations provide additional services in addition to the aforementioned KDC. All discussed implementations provide support for trust relations between multiple realms, an administrative network service (kerberos-adm, kadmind) as well as a password changing service (kpasswd). Sometimes, alternative database backends for ticket storage, X.509 and SmartCard authentication are provided. Of those, only administrative and password changing services will be discussed.
16
17 Only the Kerberos 5 protocol and implementation will be discussed. Kerberos 4 is obsolete, insecure and its use is strongly discouraged.
18
19 \subsubsection{Providing a suitable Setup for secure Kerberos Operations}
20 \label{subsubsection:kerberos_secure_setup}
21
22 The aim of Kerberos is to unify authentication across a wide range of services, for many different users and use cases and on many computer platforms. The resulting complexity and attack surface make it necessary to carefully plan and continuously evaluate the security of the overall ecosystem in which Kerberos is deployed. Several assumptions are made on which the security of a Kerberos infrastructure relies:
23 \begin{itemize}
24         \item Every KDC in a realm needs to be trustworthy. The KDC's principal database must not become known to or changed by an attacker. The contents of the principal database enables the attacker to impersonate any user or service in the realm.
25         \item Synchronisation between KDCs must be secure, reliable and frequent. An attacker that is able to intercept or influence synchronisation messages obtains or influences parts of the principal database, enabling impersonation of affected principals. Unreliable or infrequent synchronisation enlarges the window of vulnerability after disabling principals or changing passwords that have been compromised or lost.
26         \item KDCs must be available. An attacker is able to inhibit authentication for services and users by cutting off their access to a KDC.
27         \item Users' passwords must be secure. Since Kerberos is a single-sign-on mechanism, a single password may enable an attacker to access a large number of services.
28         \item Service keytabs need to be secured against unauthorized access similarly to SSL/TLS server certificates. Obtaining a service keytab enables an attacker to impersonate a service.
29         \item DNS infrastructure must be secure and reliable. Hosts that provide services need consistent forward and reverse DNS entries. The identity of a service is tied to its DNS name, similarly the realm a client belongs to as well as the KDC, kpasswd and kerberos-adm servers may be specified in DNS TXT and SRV records. Spoofed DNS entries will cause denial-of-service situations and might endanger the security of a Kerberos realm.
30 % "might endanger" according to the following source:
31 % http://web.mit.edu/kerberos/krb5-latest/doc/admin/realm_config.html
32 % unfortunately no further details beyond the suspicion of vulnerability are provided
33 % mentions possible redirection to a compromised realm in setups with trust relations: http://www.ietf.org/proceedings/48/I-D/cat-krb-dns-locate-02.txt
34         \item Clients and servers in Kerberos realms need to have synchronized clocks. Tickets in Kerberos are created with a limited, strictly enforced lifetime. This limits an attacker's window of opportunity for various attacks such as the decryption of tickets in sniffed network traffic or the use of tickets read from a client computer's memory. Kerberos will refuse tickets with old timestamps or timestamps in the future. This would enable an attacker with access to a systems clock to deny access to a service or all users logging in from a specific host.
35 \end{itemize}
36
37 Therefore we suggest:
38 \begin{itemize}
39         \item Secure all KDCs at least as strongly as the most secure service in the realm.
40         \item Dedicate physical (i.e. non-VM) machines to be KDCs. Do not run any services on those machines beyond the necessary KDC, kerberos-adm, kpasswd and kprop services. 
41         \item Restrict physical and administrative access to the KDCs as severely as possible. E.g. ssh access should be limited to responsible adminstrators and trusted networks. 
42         \item Encrypt and secure the KDCs backups.
43         \item Replicate your primary KDC to at least one secondary KDC.
44         \item Prefer easy-to-secure replication (propagation in Kerberos terms) methods.Especially avoid LDAP replication and database backends. LDAP enlarges the attack surface of your KDC and facilitates unauthorized access to the principal database e.g. by ACL misconfiguration.
45         \item Use DNSSEC. \todo{link to DNSSEC section as soon as there is one} If that is not possible, at least ensure that all servers and clients in a realm use a trustworthy DNS server contacted via secure network links.
46         \item Use NTP on a trustworthy server via secure network links. \todo{link to NTP section as soon as there is one}
47         \item Avoid services that require the user to enter a password which is then checked against Kerberos. Prefer services that are able to use authentication via service tickets, usually not requiring the user to enter a password except for the initial computer login to obtain a ticket-granting-ticket (TGT). This limits the ability of attackers to spy out passwords through compromised services.
48 \end{itemize}
49
50 \subsection{Implementations}
51 \label{subsection:kerberos_implementations}
52
53 \paragraph{Cryptographic Algorithms in Kerberos Implementations}
54
55 The encryption algorithms (commonly abbreviated 'etypes' or 'enctypes') in Kerberos exchanges are subject to negotiation between both sides of an exchange. Similarly, a ticket granting ticket (TGT), which is usually obtained on initial login, can only be issued if the principal contains a version of the password encrypted with an etype that is available both on the KDC and on the client where the login happens. Therefore, to ensure interoperability among components using different implementations as shown in table \ref{table:Kerberos_enctypes}, a selection of available etypes is necessary. However, the negotiation process may be subject to downgrade attacks and weak hashing algorithms endanger integrity protection and password security. This means that the des3-cbc-sha1-kd or rc4-hmac algorithms should not be used, except if there is a concrete and unavoidable need to do so. Other des3-*, des-* and rc4-hmac-exp algorithms should never be used.
56
57 Along the lines of cipher string B, the following etypes are recommended: aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac.
58
59 \todo{say something about salt types, eg discourage the null salt type?}
60
61 \begin{table}[h]
62         \centering
63         \small
64         \begin{tabular}{ll|llll}
65                 \toprule
66                 ID & Algorithm & MIT & Heimdal & GNU Shishi & MS ActiveDirectory \\
67                 \midrule
68                 1  & des-cbc-crc             & yes            & yes & yes & yes \\
69                 2  & des-cbc-md4             & yes            & yes & yes & no  \\
70                 3  & des-cbc-md5             & yes            & yes & yes & yes \\
71                 6  & des3-cbc-none           & no             & yes & yes & no  \\
72                 7  & des3-cbc-sha1           & no             & yes, {\tiny named old-des3-cbc-sha1} & no  & no  \\
73                 16 & des3-cbc-sha1-kd & yes, {\tiny alias des3-cbc-sha1, des3-hmac-sha1} & yes, {\tiny named des3-cbc-sha1} & yes & no  \\
74                 17 & aes128-cts-hmac-sha1-96 & yes            & yes & yes & yes, {\tiny since Vista, Server 2008} \\
75                 18 & aes256-cts-hmac-sha1-96 & yes            & yes & yes & yes, {\tiny since 7, Server 2008R2} \\
76                 23 & rc4-hmac                & yes            & yes & yes & yes \\
77                 24 & rc4-hmac-exp            & yes            & no  & yes & yes \\
78                 25 & camellia128-cts-cmac    & yes, since 1.9 & no  & no  & no  \\
79                 26 & camellia256-cts-cmac    & yes, since 1.9 & no  & no  & no  \\
80                 \bottomrule
81         \end{tabular}
82         \caption{Commonly supported Kerberos encryption types by implementation. Algorithm names according to RFC3961, except where aliases can be used or the algorithm is named differently altogether as stated.}
83         \label{tab:Kerberos_enctypes}
84 \end{table}
85 % \footnote{In MIT krb5 and Heimdal aliased to des3-hmac-sha1 and des3-cbc-sha1, colliding with the official string for enctype 7 which is referred to as old-des3-cbc-sha1 or similar.}
86 % AES enctypes: http://tools.ietf.org/html/rfc3962
87 % Camellia enctypes: http://tools.ietf.org/html/rfc6803
88 % enctype numbers list: http://tools.ietf.org/html/rfc3961#section-8
89 % recommended settings: http://tools.ietf.org/html/rfc4120#section-8.2
90 % MIT krb5 1.9: http://web.mit.edu/kerberos/krb5-1.9/
91 % Java enctype support: http://docs.oracle.com/javase/7/docs/technotes/guides/security/jgss/jgss-features.html
92 % Shishi enctype support: http://www.gnu.org/software/shishi/manual/shishi.html#Cryptographic-Overview
93 % enctype alias collision in MIT krb5: see src/lib/crypto/krb/etypes.c line 84 and src/include/krb5/krb5.hin line 438 compared to RFC3961
94 % in Heimdal, HEIM_WEAK_CRYPTO and DES3_OLD_ENCTYPE disable some DES and old 3DES algorithms at build time (lib/krb5/crypto-algs.c in source)
95 % etype recommendations, downgrade attacks and more: http://media.blackhat.com/bh-us-10/presentations/Stender_Engel_Hill/BlackHat-USA-2010-Stender-Engel-Hill-Attacking-Kerberos-Deployments-slides.pdf
96
97 \paragraph{Existing installations}
98
99 The configuration samples below assume new installations without preexisting principals.
100
101 For existing installations:
102 \begin{itemize}
103         \item Be aware that for existing setups, the master\_key\_type can not be changed easily since it requires a manual conversion of the database. When in doubt, leave it as it is. \todo{database conversion howto}
104         \item When changing the list of supported\_enctypes, principals where all enctypes are no longer supported will cease to work.
105         \item Be aware that Kerberos 4 is obsolete and should not be used.
106         \item Principals with weak enctypes pose an increased risk for password bruteforce attacks if an attacker gains access to the database.
107 \end{itemize}
108
109 To get rid of principals with unsupported or weak enctypes, a password change is usually the easiest way. Service principals can simply be recreated. \todo{force password change for old enctypes howto?}
110
111 \subsubsection{MIT krb5}
112
113 \paragraph{KDC configuration}
114 In \verb#/etc/krb5kdc/kdc.conf# set the following in your realm's configuration:
115 \begin{lstlisting}[breaklines]
116 default_principal_flags = +preauth
117 master_key_type = aes256-cts-hmac-sha1-96
118 supported_enctypes = aes256-cts-hmac-sha1-96:normal camellia256-cts-cmac:normal aes128-cts-hmac-sha1-96:normal camellia128-cts-cmac:normal
119 \end{lstlisting}
120 \todo{TODO: recommendations for lifetime, proxiable, forwardable}
121
122 In \verb#/etc/krb5.conf# set in the \[libdefaults\] section:
123 \begin{lstlisting}[breaklines]
124 [libdefaults] 
125         allow_weak_crypto = false
126         permitted_enctypes= aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac
127         default_tkt_enctypes= aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac
128         default_tgs_enctypes= aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac
129 \end{listlisting}
130 \todo{verify MIT client config}
131
132 \subsubsection{Heimdal Kerberos 5}
133 \todo{research and write Heimdal Kerberos section}
134
135 % In \verb#/etc/krb5.conf# set in the \[libdefaults\] section:
136 % \begin{lstlisting}[breaklines]
137 %[libdefaults] 
138 %       default\_etypes= aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac
139 %       default\_as\_etypes= aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac
140 %       default\_tgs\_etypes= aes256-cts-hmac-sha1-96 camellia256-cts-cmac aes128-cts-hmac-sha1-96 camellia128-cts-cmac
141 % \end{listlisting}
142
143 \subsubsection{GNU Shishi}
144 \todo{research and write GNU Shishi section}
145
146 \subsubsection{Microsoft ActiveDirectory}
147 \todo{research and write MS AD section}
148
149 % encryption type setting for a user account: http://blogs.msdn.com/b/openspecification/archive/2011/05/31/windows-configurations-for-kerberos-supported-encryption-type.aspx
150 % hunting down DES: http://blogs.technet.com/b/askds/archive/2010/10/19/hunting-down-des-in-order-to-securely-deploy-kerberos.aspx
151 % supported subset of encryption types, extension documentation: http://msdn.microsoft.com/en-us/library/cc233855.aspx
152