On Sun, Dec 06, 2009 at 09:44:21PM +0000, Arthur Dent wrote: > On Sun, 2009-12-06 at 12:59 +0100, Dominick Grift wrote: > > On Sun, Dec 06, 2009 at 09:38:32AM +0000, Arthur Dent wrote: > > > > > [Snip] > > > The rule with the initrc_t type is due to missing policy. It is encouraged to implement policy for all init daemons. > > > > With regard to the other rules you can, i guess, basically allow the access required, > > > > But always go through the checklist: > > > > 1. are the parties in an interaction labeled correctly? (matchpatchcon/restorecon/semanage/chcon) > > 2. are there any booleans or types that facilitate a certain interaction? (audit2allow) > > 3. is there a misconfiguration in some application? (see if a program should be able to do what it wants) > > 3. is there a bug in some application? (is the denial due to a bug in an application?) > > 4. is there a bug in the selinux policy? (missing policy to allow a certain interaction?) > > 5. is it a break in attempt (is the application compromised. > > > > taking these 5 golden rules into concideration. i have some questions: > > > > allow logrotate_t fail2ban_var_run_t:sock_file write > > - why would logrotate have to write to a fail2ban sock file? (this may be a bug in fail2ban, maybe leaked file descriptor. does this denial cause any loss in functionality? if not consider silently denying it) > > > > allow logrotate_t squid_log_t:lnk_file rename; > > - why does squidgaurd, or whatever managed squid_log_t lnk_file, create a lnk_file in /var/log/... This is obviously not common behaviour afaik. That may be the reason why is denied. > > > > withregard to the rules with mail_spool_t type i would like to know if and why logrotate wants to rotate spool files. is this expeected behaviour of logrotate or are the mail_spool_t object mislabeled? > > > > so in conclusion the only denial that i am somewhat comfortable with is the squid link file denial. This may be some uncommon behaviour of squid/squidgaurd that selinux policy currently does not support (when confirmed that squidgaurd indeed creates a lnk file in /var/log for some reason , then implement policy to allow logrotate to rename the link (and what else it may need to do with the lnk_file.) > > > > See what runs initrc_t (ps auxZ) and consider writing policy for this init daemon. By implementing policy for init daemon you prtect the system plus you achive that confined domain do not have to interact with the unconfined initrc_t domain. > > OK - I'm going to change the focus of this question slightly here. > > Many of my AVCs do in fact relate to Fail2Ban and in fact running ps > auxZ shows the following: > > # ps auxZ | grep init > system_u:system_r:init_t:s0 root 1 0.0 0.0 2008 164 ? Ss Dec02 0:03 /sbin/init > system_u:system_r:initrc_t:s0 ddclient 1673 0.0 0.7 10228 2956 ? S Dec02 1:00 ddclient - sleeping for 130 seconds > system_u:system_r:initrc_t:s0 root 1827 0.1 0.5 75940 2156 ? Sl Dec02 6:52 /usr/bin/python /usr/bin/fail2ban-server -b -s /var/run/fail2ban/fail2ban.sock -x > system_u:system_r:initrc_t:s0 root 1830 0.0 0.0 2904 348 ? S Dec02 0:17 /usr/libexec/gam_server > unconfined_u:system_r:initrc_t:s0 clamav 13149 0.3 28.8 220652 109928 ? Ssl 05:50 1:30 /usr/local/sbin/clamd > unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 14886 1.0 0.1 4200 720 pts/0 S+ 12:08 0:00 grep init You are using old policy. [root@localhost ~]# semanage fcontext -l | grep fail2ban /etc/rc\.d/init\.d/fail2ban regular file system_u:object_r:fail2ban_initrc_exec_t:s0 /usr/bin/fail2ban regular file system_u:object_r:fail2ban_exec_t:s0 /usr/bin/fail2ban-server regular file system_u:object_r:fail2ban_exec_t:s0 /var/lib/fail2ban(/.*)? all files system_u:object_r:fail2ban_var_lib_t:s0 /var/log/fail2ban\.log regular file system_u:object_r:fail2ban_log_t:s0 /var/run/fail2ban.* all files system_u:object_r:fail2ban_var_run_t:s0 But anyways with regard to SELinux issues: SELinux is a framework that lets you configure the access that various processes have. It just like iptables/netfilter where a particular port is not open. The netfilter framework allows you to open it and the iptables frontend is a way to implement it. No policy is ever perfect. So for professionals it is a good idea to just learn how to manage an SELinux environment. One thing to keep in mind is that processes running initrc_r do not have policy (in your case ddclient, gameserver, clamd, and fail2ban-server). To fix this in a managable way it is encourage to confine these init daemons first. Writing/implementing policy for a init daemon is not particularly hard and you do not have to be a programmer to do so. With regard to fail2ban-server, you could start by trying to label the fail2ban executable (/usr/bin/fail2ban-server) with the fail2ban executable type (semanage fcontext -a -t fail2ban_exec_t /usr/bin/fail2ban-server; restorecon -v /usr/bin/fail2ban-server). This should atleast get the fail2ban-server process out of the initrc_t domain and into the fail2ban domain. From there on, youre on the right track. As for ddclient, gam_server and clamd it may require that you write a policy from scratch. Also usually not hard to do. In a nutshell: 1. create a type for the process 2. create a type for the executable file 3. declare the two types init_daemon_domain(). 4. label the executable file with the type you declared executable file. 5. start service (if needed in permissive mode during policy development stage) and see whether the process runs with the declared type for the process. 6. use ausearch/audit2allow to write rule that define how you process type can interact with other types. 7. make sure that interacting with type initrc_t means its trying to interact with a process that is not confined (does not have policy yet) after that, its just the five golden rules i mentioned in a previous post. 1. make sure parties in an interaction have the expected type. 2. make sure you check for any booleans/custom types that may provide the access it needs. 3. make sure you app is configured properly. 4. make sure you dont allow access that your app needs because it has a bug. 5. implement policy. > > My Fail2Ban policy has also grown over the months and now looks like > this: > ===============8<==================================================== > module myfail2ban 11.1.3; > > require { > type iptables_t; > type system_mail_t; > type fail2ban_t; > type usr_t; > type syslogd_t; > type sendmail_t; > type initrc_t; > class file read; > class unix_stream_socket { read write }; > class unix_dgram_socket { read write sendto }; > } > > #============= fail2ban_t ============== > allow fail2ban_t self:unix_dgram_socket write; > allow fail2ban_t syslogd_t:unix_dgram_socket sendto; > > #============= iptables_t ============== > allow iptables_t fail2ban_t:unix_stream_socket { read write }; > allow iptables_t fail2ban_t:unix_dgram_socket { read write }; > allow iptables_t initrc_t:unix_dgram_socket { read write }; > > #============= system_mail_t ============== > allow system_mail_t fail2ban_t:unix_stream_socket { read write }; > allow system_mail_t fail2ban_t:unix_dgram_socket { read write }; > allow system_mail_t usr_t:file read; > > #============= sendmail_t ============== > allow sendmail_t initrc_t:unix_dgram_socket { read write }; > > ===============8<==================================================== > > I am concious that this is not ideal and so I have asked on the fail2ban > list if someone with more technical expertise than me can help clean up > fail2ban with respect to selinux. > > Fortunately Arturo "Buanzo" Busleiman, one of the developers, has > offered to take a look at this. (I am also copying this email to the > fail2ban list). > > I would very much appreciate it if Dominick, Daniel, and anyone else who > can help, could liaise with Arturo so that this important security > package could work cleanly with selinux. > > I will do what I can too - but I should just point out that I can just > about spell "patch" and only if I'm really desperate would I ever try to > apply one! > > Thanks in advance. > > Mark > > > > -- > fedora-selinux-list mailing list > fedora-selinux-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/fedora-selinux-list
Attachment:
pgpVbLOXnKJuN.pgp
Description: PGP signature
-- fedora-selinux-list mailing list fedora-selinux-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-selinux-list