Skip to contentSkip to conversation

Policy for Kerberos

DISCUSSION Kerry Thompson 2 participants 3 messages Jul 15, 2003 – Jul 21, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

Attached is my first cut at a policy for Kerberos. This is for the MIT Kerberos5 software but should work fine for most for most distros with file location tweaking.

The policy basically just supports the krb5kdc and kadmind daemons, and most user programs such as kinit, klist, kdestroy, and kadmin. The Kerberos release also includes telnetd, ftpd, and rlogind services which I haven't put into this policy. The Kerberos telnetd and rlogind use their own login program to perform ticket authentication and forwarding which would need to be patched for SELinux support.

Rather than using telnetd/ftpd/rlogind I recommend OpenSSH instead which is more functional and supports privsep. This policy supports the latest OpenSSH ssh & sshd patched with GSSAPI-Kerberos support ( Simon Wilkinson's patch ) plus the SELinux patch.

Note that something in the Kerberos library is opening config files in read/write mode - I've blocked this with a few dontaudit rules to avoid the noise, but it doesn't cover everything - you'll still see some write denials here and there. I've notified the MIT Kerberos team as to the issue, but I'm not expecting a fix any time soon.

I've also included a patch to put the Kerberos services into net_contexts.

Kerry

Signature · 3 lines
Kerry Thompson
Information Systems Security Consultant
http://www.crypt.gen.nz  [email protected]

78,88d77
< #
< # Kerberos krb5kdc, kadmind
< #
< ifdef(kerberos.te',
< portcon udp 88 system_u:object_r:kerberos_port_t < portcon tcp 88 system_u:object_r:kerberos_port_t < portcon tcp 749 system_u:object_r:kerberos_admin_port_t < portcon udp 751 system_u:object_r:kerberos_master_port_t < portcon tcp 751 system_u:object_r:kerberos_master_port_t < ')
<

#1 lore raw
Quoted 3 lines · Kerry Thompson

Attached is my first cut at a policy for Kerberos. This is for the MIT Kerberos5 software but should work fine for most for most distros with file location tweaking.

# General rules for /etc/krb5.conf
allow user_t krb5_conf_t:file { getattr ioctl read }; allow local_login_t krb5_conf_t:file { getattr ioctl read }; allow sysadm_su_t krb5_conf_t:file { getattr ioctl read }; allow user_su_t krb5_conf_t:file { getattr ioctl read }; allow run_init_t krb5_conf_t:file { getattr read };

Maybe this file should be labeled etc_t as it seems to be read by the same programs that read /etc/passwd (presumably for the same reasons).

Also you should not specify user_t in policy, userdomain or unpriv_userdomain are more appropriate.

As for the user_su_t, that would require a modification to the su_macros.te file with an ifdef(`kerberos.te'.

allow krb5kdc_t tmp_t:dir { add_name remove_name search write }; allow krb5kdc_t tmp_t:file { create getattr read rename unlink write };

Should be:
tmp_domain(krb5kdc)

allow krb5kdc_t var_log_t:dir { add_name search write }; allow krb5kdc_t var_log_t:file { read append create getattr };

Should be:
log_domain(krb5kdc)

Same for kadmin_t, although maybe they should share a log type.

allow krb5kdc_t user_ssh_t:udp_socket { recvfrom }; allow user_ssh_t krb5kdc_t:udp_socket { recvfrom };

This needs to be in the ssh_macros.te file, otherwise it won't work for staff_t and other user domains.

Also do you think it would be a good idea to separate kerberos server and client policy?

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

Thanks Russell, your help is greatly appreciated. I've made most of your suggested fixes, and retested everything.

Quoted 10 lines · Russell Coker

# General rules for /etc/krb5.conf
allow user_t krb5_conf_t:file { getattr ioctl read }; allow local_login_t krb5_conf_t:file { getattr ioctl read }; allow sysadm_su_t krb5_conf_t:file { getattr ioctl read }; allow user_su_t krb5_conf_t:file { getattr ioctl read }; allow run_init_t krb5_conf_t:file { getattr read };

Maybe this file should be labeled etc_t as it seems to be read by the same programs that read /etc/passwd (presumably for the same reasons).

I initially though so too, unfortunately something in the kerberos library likes to open the config file for writing and putting in a dontaudit for etc_t would block too much. Using 'allow userdomain krb5_conf_t:file' cleans this up quite well.

Quoted 3 lines

Also you should not specify user_t in policy, userdomain or unpriv_userdomain are more appropriate.

Done. Updated kerberos.te attached.

Quoted 3 lines

As for the user_su_t, that would require a modification to the su_macros.te file with an ifdef(`kerberos.te'.

Done. Patches for su_macros.te attached.

Quoted 6 lines

allow krb5kdc_t tmp_t:dir { add_name remove_name search write }; allow krb5kdc_t tmp_t:file { create getattr read rename unlink write };

Should be:
tmp_domain(krb5kdc)

Done.

Quoted 8 lines

allow krb5kdc_t var_log_t:dir { add_name search write }; allow krb5kdc_t var_log_t:file { read append create getattr };

Should be:
log_domain(krb5kdc)

Same for kadmin_t, although maybe they should share a log type.

Done (although still separate log types).

Quoted 6 lines

allow krb5kdc_t user_ssh_t:udp_socket { recvfrom }; allow user_ssh_t krb5kdc_t:udp_socket { recvfrom };

This needs to be in the ssh_macros.te file, otherwise it won't work for staff_t and other user domains.

Done. Patch for ssh_macros.te attached.

Quoted 3 lines

Also do you think it would be a good idea to separate kerberos server and client policy?

Maybe. I put them together because there wasn't a client/server split for other packages in the policy base, and there's only a few simple client rules. Also, its possible that anything using PAM could become a kerberos client with the krb5 PAM module. The krb5 specific clients could be split out of the policy fairly easily.

One outstanding problem is the ksu (client) program. It behaves very much like su and sudo combined, but with kerberos-based transparent authentication. It reads ~/.k5login and ~/.k5users from the destination user's home directory to get authorisation rules. With the kerberos policy at this stage it gets labelled with su_exec_t which causes it to behave like su ( no transparent authentication and no sudo features ). I'll need to learn a lot more about SELinux before I get ksu sorted out.

Kerry.

Signature · 3 lines
Kerry Thompson, CCNA CISSP
Information Systems Security Consultant
http://www.crypt.gen.nz  [email protected]
net_contexts renamed from net_contexts.orig +11 -0
@@ -75,6 +75,17 @@
 ifdef(`use_http_cache', `portcon tcp 8080  system_u:object_r:http_cache_port_t')
 ifdef(`transproxy.te', `portcon tcp 8081 system_u:object_r:transproxy_port_t')
 
+#
+# Kerberos krb5kdc, kadmind
+#
+ifdef(`kerberos.te', `
+portcon udp 88 system_u:object_r:kerberos_port_t
+portcon tcp 88 system_u:object_r:kerberos_port_t
+portcon tcp 749 system_u:object_r:kerberos_admin_port_t
+portcon udp 751 system_u:object_r:kerberos_master_port_t
+portcon tcp 751 system_u:object_r:kerberos_master_port_t
+')
+
 # Network interfaces (default = initial SID 'netif' and 'netmsg')
 #
 # interface netif_context default_msg_context
program/ssh_macros.te renamed from program/ssh_macros.te.orig +10 -0
@@ -149,6 +149,16 @@
 allow $1_ssh_t xdm_xserver_tmpfs_t:file read;
 ')
 
+ifdef(`kerberos.te', `
+# Kerberos authentication for ssh
+allow krb5kdc_t $1_ssh_t:udp_socket { recvfrom };
+allow $1_ssh_t krb5kdc_t:udp_socket { recvfrom };
+allow $1_ssh_t krb5_conf_t:file { getattr read };
+dontaudit $1_ssh_t krb5_conf_t:file { write };
+allow $1_t sshd_tmp_t:file { lock read unlink };
+allow $1_ssh_t user_tmp_t:file { lock write };
+')
+
 ')dnl  end of ifdef ssh.te
 
 
program/su_macros.te renamed from program/su_macros.te.orig +11 -0
@@ -67,6 +67,17 @@
 domain_auto_trans($1_su_t, xauth_exec_t, $1_xauth_t)
 ')
 
+# Additional rules for kerberos auth, and ksu
+ifdef(`kerberos.te', `
+allow $1_su_t krb5_conf_t:file { getattr ioctl read };
+allow $1_su_t tmp_t:dir { add_name write remove_name };
+allow $1_su_t tmp_t:file { create write setattr unlink };
+allow $1_su_t krb5kdc_t:udp_socket { recvfrom };
+allow krb5kdc_t $1_su_t:udp_socket { recvfrom };
+allow $1_su_t krb5_keytab_t:file { lock read };
+dontaudit $1_su_t krb5_conf_t:file { write };
+')
+
 # Access sshd cookie files.
 allow $1_su_t sshd_tmp_t:dir rw_dir_perms;
 allow $1_su_t sshd_tmp_t:file rw_file_perms;