<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">

<channel>
	<title>Planet SELinux</title>
	<link>http://selinuxnews.org/planet/</link>
	<language>en</language>
	<description>Planet SELinux - http://selinuxnews.org/planet/</description>

<item>
	<title>Dan Walsh: A follow up to the Bash Exploit and SELinux.</title>
	<guid>http://danwalsh.livejournal.com/71396.html</guid>
	<link>http://danwalsh.livejournal.com/71396.html</link>
	<description>One of the advantages of a remote exploit is to be able to setup and launch attacks on other machines. &lt;br /&gt;&lt;br /&gt;I wondered if it would be possible to setup a &lt;a href=&quot;https://en.wikipedia.org/wiki/Botnet&quot; rel=&quot;nofollow&quot;&gt;bot net&lt;/a&gt; attack using the remote attach on an apache server with the bash exploit.&lt;br /&gt;&lt;br /&gt;Looking at my rawhide machine's policy&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch -A -s httpd_sys_script_t -p name_connect -C | grep -v ^D&lt;br /&gt;Found 24 semantic av rules:&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow nsswitch_domain dns_port_t : tcp_socket { recv_msg send_msg name_connect } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow nsswitch_domain dnssec_port_t : tcp_socket name_connect ;&lt;br /&gt;ET allow nsswitch_domain ldap_port_t : tcp_socket { recv_msg send_msg name_connect } ; [ authlogin_nsswitch_use_ldap ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The apache script would only be allowed to connect/attack a dns server and an LDAP server.&amp;nbsp; It would not be allowed to become a spam bot (No connection to mail ports) or even attack other web service.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Could an attacker leave a back door to be later connected to even after the bash exploit is fixed?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# sesearch -A -s httpd_sys_script_t -p name_bind -C | grep -v ^D&lt;/span&gt;&lt;br /&gt;&lt;span&gt;#&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Nope!&amp;nbsp; On my box the httpd_sys_script_t process is not allowed to listen on any network ports.&lt;br /&gt;&lt;br /&gt;I guess the crackers will just have to find a machine with SELinux disabled.</description>
	<pubDate>Fri, 26 Sep 2014 12:58:19 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: What does SELinux do to contain the the bash exploit?</title>
	<guid>http://danwalsh.livejournal.com/71122.html</guid>
	<link>http://danwalsh.livejournal.com/71122.html</link>
	<description>&lt;b&gt;Do you have SELinux enabled on your Web Server? &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Lots of people are asking me about SELinux and the Bash Exploit.&lt;br /&gt;&lt;br /&gt;I did a quick analysis on one reported remote Apache exploit:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
&lt;a href=&quot;http://www.reddit.com/r/netsec/comments/2hbxtc/cve20146271_remote_code_execution_through_bash/&quot; rel=&quot;nofollow&quot;&gt;http://www.reddit.com/r/netsec/comments/2hbxtc/cve20146271_remote_code_execution_through_bash/&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
Shows an example of the bash exploit on an apache server.  It even shows that SELinux was enforcing when the exploit happened.&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SELinux does not block the exploit but it would prevent escallation of confined domains.&lt;br /&gt;&lt;pre&gt;
&lt;b&gt;Why didn't SELinux block it?&lt;/b&gt;

SELinux controls processes based on their types, if the process is doing what it was designed to do then SELinux will not block it.

In the defined exploit the apache server is running as httpd_t and it is executing a cgi script which would be labeled httpd_sys_script_exec_t.  

When httpd_t executes a script labeled httpd_sys_script_exec_t SELinux will transition the new process to httpd_sys_script_t.

SELinux policy allowd processes running as httpd_sys_script_t is to write to /tmp, so it was successfull in creating&lt;code&gt; /tmp/aa.

If you did this and looked at the content in /tmp it would be labeled httpd_tmp_t

httpd_tmp_t.

Lets look at which files httpd_sys_script_t is allowed to write to on my Rawhide box.

&lt;span&gt;# sesearch -A -s httpd_sys_script_t -c file -p write -C | grep open | grep -v ^D
   allow httpd_sys_script_t httpd_sys_rw_content_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; 
   allow httpd_sys_script_t anon_inodefs_t : file { ioctl read write getattr lock append open } ; 
   allow httpd_sys_script_t httpd_sys_script_t : file { ioctl read write getattr lock append open } ; 
   allow httpd_sys_script_t httpd_tmp_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; 
&lt;/span&gt;
httpd_sys_script_t is a process label which only applies to content in /proc.  This means processes running as httpd_sys_script_t can write to there process data.

anon_inodefs_t is an in memory label, most likely not on your disk.

The only on disk places it can write files labeled httpd_sys_rw_content_t and /tmp.

&lt;span&gt;grep httpd_sys_rw_content_t /etc/selinux/targeted/contexts/files/file_contexts&lt;/span&gt;

or on my box

&lt;span&gt;# find /etc -context &amp;quot;*:httpd_sys_rw_content_t:*&amp;quot;
/etc/BackupPC
/etc/BackupPC/config.pl
/etc/BackupPC/hosts
/etc/glpi&lt;/span&gt;

&lt;/code&gt;&lt;code&gt;&lt;code&gt;With SELinux disabled, this hacked process would be allowed to write any content that is world writable on your system as well as any content owned by the apache user or group.

&lt;/code&gt;&lt;b&gt;Lets look at what it can read.&lt;/b&gt;

&lt;span&gt;sesearch -A -s httpd_sys_script_t -c file -p read -C | grep open | grep -v ^D | grep -v exec_t
   allow domain locale_t : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t iso9660_t : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t httpd_sys_ra_content_t : file { ioctl read create getattr lock append open } ; 
   allow httpd_sys_script_t httpd_sys_rw_content_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; 
   allow httpd_sys_script_t squirrelmail_spool_t : file { ioctl read getattr lock open } ; 
   allow domain ld_so_t : file { ioctl read getattr execute open } ; 
   allow httpd_sys_script_t anon_inodefs_t : file { ioctl read write getattr lock append open } ; 
   allow httpd_sys_script_t sysctl_kernel_t : file { ioctl read getattr lock open } ; 
   allow domain base_ro_file_type : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t httpd_sys_script_t : file { ioctl read write getattr lock append open } ; 
   allow nsswitch_domain cert_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type etc_runtime_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type fonts_cache_t : file { ioctl read getattr lock open } ; 
   allow domain mandb_cache_t : file { ioctl read getattr lock open } ; 
   allow domain abrt_t : file { ioctl read getattr lock open } ; 
   allow domain lib_t : file { ioctl read getattr lock execute open } ; 
   allow domain man_t : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t cifs_t : file { ioctl read getattr lock execute execute_no_trans entrypoint open } ; 
   allow domain sysctl_vm_overcommit_t : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t nfs_t : file { ioctl read getattr lock execute execute_no_trans entrypoint open } ; 
   allow kernel_system_state_reader proc_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain passwd_file_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain sssd_public_t : file { ioctl read getattr lock open } ; 
   allow domain cpu_online_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type public_content_rw_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain etc_runtime_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain hostname_etc_t : file { ioctl read getattr lock open } ; 
   allow domain ld_so_cache_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain sssd_var_lib_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type public_content_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain krb5_conf_t : file { ioctl read getattr lock open } ; 
   allow domain abrt_var_run_t : file { ioctl read getattr lock open } ; 
   allow domain textrel_shlib_t : file { ioctl read getattr execute execmod open } ; 
   allow httpd_sys_script_t httpd_tmp_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; 
   allow domain machineid_t : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t mysqld_etc_t : file { ioctl read getattr lock open } ; 
   allow domain rpm_script_tmp_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain samba_var_t : file { ioctl read getattr lock open } ; 
   allow domain sysctl_crypto_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain net_conf_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type etc_t : file { ioctl read getattr execute execute_no_trans open } ; 
   allow httpd_script_type fonts_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type ld_so_t : file { ioctl read getattr execute execute_no_trans open } ; 
   allow nsswitch_domain file_context_t : file { ioctl read getattr lock open } ; 
   allow httpd_sys_script_t httpd_squirrelmail_t : file { ioctl read getattr lock append open } ; 
   allow httpd_script_type base_ro_file_type : file { ioctl read getattr lock execute execute_no_trans open } ; 
   allow httpd_sys_script_t snmpd_var_lib_t : file { ioctl read getattr lock open } ; 
   allow nsswitch_domain samba_etc_t : file { ioctl read getattr lock open } ; 
   allow domain man_cache_t : file { ioctl read getattr lock open } ; 
   allow httpd_script_type bin_t : file { ioctl read getattr lock execute execute_no_trans open } ; 
   allow httpd_script_type lib_t : file { ioctl read getattr lock execute execute_no_trans open } ; 
   allow httpd_sys_script_t httpd_sys_content_t : file { ioctl read getattr lock execute execute_no_trans entrypoint open } ; 
   allow nsswitch_domain etc_t : file { ioctl read getattr lock open } ; 
ET allow nsswitch_domain cert_t : file { ioctl read getattr lock open } ; [ authlogin_nsswitch_use_ldap ]
ET allow nsswitch_domain slapd_cert_t : file { ioctl read getattr lock open } ; [ authlogin_nsswitch_use_ldap ]
ET allow nsswitch_domain net_conf_t : file { ioctl read getattr lock open } ; [ authlogin_nsswitch_use_ldap ]
ET allow domain sysctl_kernel_t : file { ioctl read getattr lock open } ; [ fips_mode ]
&lt;/span&gt;
Looks like a lot of types, but most of these are System Types bin_t, lib_t ld_so_t, man_t fonts_t,  most stuff under /usr etc.

It would be allowed to read /etc/passwd (passwd_t) and most content in /etc.  

It can read apache static content, like web page data.

&lt;b&gt;Well what can't it read?&lt;/b&gt;

user_home_t - This is where I keep my credit card data
usr_tmp_t where an admin might have left something
Other content in /var
*db_t - No database data.
It can not read most of apache runtime data like apache content in /var/lib or /var/log or /etc/httpd

With SELinux disabled, this process would be allowed to read any content that is world readable on your system as well as any content owned by the apache user our group.

&lt;b&gt;We also need to look at what domains httpd_sys_script_t can transition to?&lt;/b&gt;

&lt;span&gt;# sesearch -T -s httpd_sys_script_t -c process -C | grep -v ^D
Found 9 semantic te rules:
   type_transition httpd_sys_script_t httpd_rotatelogs_exec_t : process httpd_rotatelogs_t; 
   type_transition httpd_sys_script_t abrt_helper_exec_t : process abrt_helper_t; 
   type_transition httpd_sys_script_t antivirus_exec_t : process antivirus_t; 
   type_transition httpd_sys_script_t sepgsql_ranged_proc_exec_t : process sepgsql_ranged_proc_t; 
   type_transition httpd_sys_script_t sepgsql_trusted_proc_exec_t : process sepgsql_trusted_proc_t; &lt;/span&gt;

SELinux would also block the process executing a setuid process to raise its capabilities.

&lt;b&gt;Now this is a horrible exploit but as you can see SELinux would probably have protected a lot/most of your valuable data on your machine.  It would buy you time for you to patch your system.&lt;/b&gt;

&lt;b&gt;Did you setenforce 1?&lt;/b&gt;
&lt;/code&gt;&lt;/pre&gt;</description>
	<pubDate>Thu, 25 Sep 2014 21:37:39 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Confusion with sesearch.</title>
	<guid>http://danwalsh.livejournal.com/70855.html</guid>
	<link>http://danwalsh.livejournal.com/70855.html</link>
	<description>I just saw an email where a user was asking why sesearch is showing access but the access is still getting denied.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I'm running CentOS 6. I've httpd running which accesses a file but it results in access denied with the following --&lt;br /&gt;&lt;br /&gt;type=AVC msg=audit(1410680693.979:40): avc:&amp;nbsp; denied&amp;nbsp; { read } for pid=987 comm=&amp;quot;httpd&amp;quot; name=&amp;quot;README.txt&amp;quot; dev=dm-0 ino=12573 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file&lt;br /&gt;&lt;br /&gt;However,&lt;br /&gt;&lt;br /&gt;sesearch -A | grep 'allow httpd_t' | grep ': file' | grep user_home_t&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t user_home_t : file { ioctl read getattr lock open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t user_home_t : file { ioctl read getattr lock open } ; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sesearch&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;sesearch is a great tool that we use all the time.&amp;nbsp; It allows you to analyze and look the the SELInux policy.&amp;nbsp; It is part of the setools-console package.&amp;nbsp; It uses the &amp;quot;Apol&amp;quot; libraries to examine policy, the same libraries we have used to build the new tool set &lt;i&gt;sepolicy&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;The problem was that he was using sesearch incorrectly.&amp;nbsp; sesearch -A shows you all possible, allow rules not just the allow rules that are currently in effect.&lt;br /&gt;&lt;br /&gt;The user needs to add a -C option to the sesearch.&amp;nbsp; The -C options shows you the booleans required for that access.&amp;nbsp; It also shows a capital E or D indicating whether or not the boolean is enabled or disabled in policy at the beginning of the line.&lt;br /&gt;&lt;br /&gt;On my machine, I will use a more complicated command, this command says show the allow rules for a source type of httpd_t, and a target type of user_home_t, permission=read on a class=file.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch -A -C -s httpd_t -t user_home_t -p read -c file&lt;br /&gt;Found 1 semantic av rules:&lt;br /&gt;DT allow httpd_t user_home_type : file { ioctl read getattr lock open } ; [ httpd_read_user_content ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As you can see on my machine the boolean is disabled, so Apache is not allowed to read general content in my homedir, which I assume was true for the user.&amp;nbsp;&amp;nbsp; If&amp;nbsp; the user wants to allow httpd_t to read all general content in the users homedir you can turn on the httpd_read_user_content boolean.&lt;br /&gt;&lt;br /&gt;If you want to allow it to read just a certain directories/files, recommended,&amp;nbsp; you should change the label on the directory.&amp;nbsp; BTW ~/public_html and ~/www already have the correct labeling.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;matchpathcon ~/public_html ~/www&lt;br /&gt;/home/dwalsh/public_html&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_u:object_r:httpd_user_content_t:s0&lt;br /&gt;/home/dwalsh/www&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_u:object_r:httpd_user_content_t:s0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I would not want to let the apache process read general content in my homedir, since I might be storing critical stuff like credit card data, passwords, and unflattering pictures of me in there. :^)</description>
	<pubDate>Mon, 15 Sep 2014 11:07:47 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: What is this new unconfined_service_t type I see on Fedora 21 and RHEL7?</title>
	<guid>http://danwalsh.livejournal.com/70577.html</guid>
	<link>http://danwalsh.livejournal.com/70577.html</link>
	<description>&lt;div&gt;&lt;span&gt;Everyone that has ever used SELinux knows that the unconfined_t domain is a process label that is not confined.&amp;nbsp; But this is not the only unconfined domain on a SELinux system.&amp;nbsp; It is actually the default domain of a user that logs onto a system.&amp;nbsp; In a lot of ways we should have used the type unconfined_user_t rather then unconfined_t.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;By default in an SELinux Targeted system there are lots of other &lt;a href=&quot;https://danwalsh.livejournal.com/42394.html&quot; rel=&quot;nofollow&quot;&gt;unconfined domains&lt;/a&gt;.&amp;nbsp; We have these so that users can run programs/services without SELinux interfering if SELinux does not know about them.&lt;/span&gt; You can list the unconfined domains on your system using the following command.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;seinfo -aunconfined_domain_type -x&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;In RHEL6 and older versions of Fedora, we used to run system services as initrc_t by default.&amp;nbsp; Unless someone has written a policy for them.&amp;nbsp; initrc_t is an unconfined domain by default, unless you&lt;a href=&quot;http://danwalsh.livejournal.com/9031.html&quot; rel=&quot;nofollow&quot;&gt; disabled the unconfined.pp module&lt;/a&gt;. &lt;/span&gt;&lt;span&gt; Running unknown serivices as initrc_t allows administrators to run an application service, even if no policy has never been written for it.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;In RHEL6 we have these rules:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;init_t @initrc_exec_t -&amp;gt; initrc_t &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;init_t @bin_t -&amp;gt; initrc_t &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;If an administrator added an executable service to /usr/sbin or /usr/bin, the init system would run the service as initrc_t.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;We found this to be problematic, though.&amp;nbsp; &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The problem was that we have lots of transition rules out of initrc_t.&amp;nbsp; If a program we did not know about was running as initrc_t and executed a program like rsync to copy data between servers, SELinux would transition the program to rsync_t and it would blow up.&amp;nbsp; SELinux mistakenly would think that rsync was set up in server mode, not client mode.&amp;nbsp; Other transition rules could also cause breakage.&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;We decided we needed a new unconfined domain to run services with, that would have no transition rules.&amp;nbsp; We introduced the unconfined_service_t domain.&amp;nbsp; Now we have:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;init_t @bin_t -&amp;gt; unconfined_service_t &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;A process running as unconfined_service_t is allowed to execute any confined program, but stays in the unconfined_service_t domain.&amp;nbsp; SELinux will not block any access.&lt;/span&gt; This means by default, if you install a service that does not have policy written for it, it should work without SELinux getting in the way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;Sometimes applications are installed in fairly random directories under /usr or /opt (Or in oracle's case /u01), which end up with the label of usr_t, therefore we added these transition rules to policy.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;# sesearch -T -s init_t&amp;nbsp; | grep unconfined_service_t&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;  type_transition init_t bin_t : process unconfined_service_t; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;span&gt;  type_transition init_t usr_t : process unconfined_service_t; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;You can see it in Fedora21.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Bottom Line&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Hopefully unconfined_service_t will make leaving SELinux enabled easier on systems that have to run third party services, and protect the other services that run on your system.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;Thanks to Simon Sekidde and Miroslav Grepl for helping to write this blog.&lt;/div&gt;</description>
	<pubDate>Wed, 10 Sep 2014 20:18:36 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Interview on Docker Security on SDTimes.com</title>
	<guid>http://danwalsh.livejournal.com/70279.html</guid>
	<link>http://danwalsh.livejournal.com/70279.html</link>
	<description>&lt;a href=&quot;http://sdtimes.com/red-hat-open-source-community-fortifying-docker&quot; rel=&quot;nofollow&quot;&gt;http://sdtimes.com/red-hat-open-source-community-fortifying-docker&lt;/a&gt;</description>
	<pubDate>Mon, 08 Sep 2014 18:44:54 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Think before you just blindly audit2allow -M mydomain</title>
	<guid>http://danwalsh.livejournal.com/69958.html</guid>
	<link>http://danwalsh.livejournal.com/69958.html</link>
	<description>&lt;span&gt;&lt;b&gt;Don't Allow Domains to write Base SELinux Types&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A few years ago I wrote a blog and paper on the&lt;a href=&quot;https://danwalsh.livejournal.com/30837.html&quot; rel=&quot;nofollow&quot;&gt; four causes of SELinux errors&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The first two most common causes were labeling issues and SELinux needs to know.&lt;br /&gt;&lt;br /&gt;Easiest way to explain this is a daemon wants to write to a certain file and SELinux blocks&lt;br /&gt;the application from writing.&amp;nbsp; In SELinux terms the Process DOMAIN (httpd_t) wants to write to the file type (var_lib_t)&lt;br /&gt;and it is blocked.&amp;nbsp; Users have potentially three ways of fixing this.&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Change the type of the file being written.&lt;ul&gt;&lt;br /&gt;&lt;li&gt;The object might be mislabeled and restorecon of the object fixes the issue&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Change the label to httpd_var_lib_t using semanage and restorecon&lt;ul&gt;semanage fcontext -a -t httpd_var_lib_t '/var/lib/foobar(/.*)?'&lt;/ul&gt;&lt;ul&gt;restorecon -R -v /var/lib/foobar&lt;/ul&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;There might be a boolean available to allow the Process Domain to write to the file type&lt;ul&gt;setsebool -P HTTP_BOOLEAN 1&lt;/ul&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Modify policy using audit2allow&lt;ul&gt;grep httpd_t /var/log/audit/audit.log | audit2allow -M myhttp&lt;/ul&gt;&lt;ul&gt;semodule -i myhttpd.pp&lt;/ul&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;b&gt;Sadly the third option is the least recommended and the most often used.&amp;nbsp; &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The problem is it requires no thought and gets SELinux to just shut up.&lt;br /&gt;&lt;br /&gt;In RHEL7 and latest Fedoras, the audit2allow tools will suggest a boolean when you run the AVC's through it.&amp;nbsp; And setroubleshoot has been doing this for years. setroubleshoot even will suggest potential types that you could change the destination object to use.&lt;br /&gt;&lt;br /&gt;The thing we really want to stop is domains writing to BASE types.&amp;nbsp; If I allow a confined domain to write to a BASE type like etc_t or usr_t, then a hacked system can attack other domains, since almost all other domains need to read some etc_t or usr_t content.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;BASE TYPES&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;One other feature we have added in RHEL7 and Fedora is a list of base types.&amp;nbsp; SELinux has a mechanism for grouping types based on an attribute.&lt;br /&gt;We have to new attributes base_ro_file_type and base_file_type.&amp;nbsp; You can see the objects associated with these attributes using the seinfo command.&lt;br /&gt;&lt;br /&gt;seinfo -abase_ro_file_type -x&lt;br /&gt;&amp;nbsp;&amp;nbsp; base_ro_file_type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc_runtime_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; src_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shell_exec_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system_db_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bin_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boot_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lib_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usr_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system_conf_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textrel_shlib_t&lt;br /&gt;&lt;br /&gt;$ seinfo -abase_file_type -x&lt;br /&gt;&amp;nbsp;&amp;nbsp; base_file_type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc_runtime_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unlabeled_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; device_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; src_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shell_exec_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; home_root_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system_db_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_lock_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bin_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boot_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lib_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mnt_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; root_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usr_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system_conf_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textrel_shlib_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lost_found_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_spool_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; default_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_lib_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_run_t&lt;br /&gt;&lt;br /&gt;If you use audit2allow to add a rule to allow a domain to write to one of the base types:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Most likely you are WRONG&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If you have a domain that is attempting to write to one of these base types, then you most likely need to change the type of the destination object using the semanage/restorecon commands mentioned above.&lt;br /&gt;The difficult thing for the users to figure out; &amp;quot;What type should I change the object to?&amp;quot;&lt;br /&gt;&lt;br /&gt;We have added new man pages that show you the types that you program is allowed to write&lt;br /&gt;&lt;br /&gt;man httpd_selinux&lt;br /&gt;&lt;br /&gt;Look for writable types?&lt;br /&gt;&lt;br /&gt;If your domain httpd_t is attempting to write to var_lib_t then look for httpd_var_lib_t. &amp;quot;sepolicy gui&amp;quot; is a new gui tool to help you understand the types also.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Call to arms:&lt;/b&gt;&lt;br /&gt;If an enterprising hacker wanted to write some code, it would be nice to build this knowledge into audit2allow.&amp;nbsp; Masters Thesis anyone???</description>
	<pubDate>Fri, 05 Sep 2014 12:35:01 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>James Morris: New GPG Key</title>
	<guid>http://blog.namei.org/?p=584</guid>
	<link>http://blog.namei.org/2014/09/05/new-gpg-key-2/</link>
	<description>&lt;p&gt;Just an FYI, I lost my GPG key a few months back during an upgrade, and have created a new one.  This was signed by folk at LinuxCon/KS last month.&lt;/p&gt;
&lt;p&gt;The new key ID / fingerprint is: D950053C / 8327 23D0 EF9D D46D 9AC9  C03C AD98 4BBF D950 053C&lt;/p&gt;
&lt;p&gt;Please use this key and not the old one!&lt;/p&gt;
&lt;pre&gt;&lt;/pre&gt;</description>
	<pubDate>Thu, 04 Sep 2014 21:38:18 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>James Morris: Linux Security Summit 2014 Schedule Published</title>
	<guid>http://blog.namei.org/?p=577</guid>
	<link>http://blog.namei.org/2014/07/16/linux-security-summit-2014-schedule-published/</link>
	<description>&lt;p&gt;The schedule for the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2014&quot;&gt;2014 Linux Security Summit&lt;/a&gt; (LSS2014) is now &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2014#Schedule&quot;&gt;published.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The event will be held over two days (18th &amp;amp; 19th August), starting with &lt;a href=&quot;http://www.linux.com/news/special-feature/linux-developers/678568-30-linux-kernel-developers-in-30-weeks-james-bottomley&quot;&gt;James Bottomley&lt;/a&gt; as the keynote speaker.  The keynote will be followed by referred talks, group discussions, kernel security subsystem updates, and break-out sessions.&lt;/p&gt;
&lt;p&gt;The refereed talks are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Verified Component Firmware &amp;#8211; Kees Cook, Google&lt;/li&gt;
&lt;li&gt;Protecting the Android TCB with SELinux &amp;#8211; Stephen Smalley, NSA&lt;/li&gt;
&lt;li&gt;Tizen, Security and the Internet of Things &amp;#8211; Casey Schaufler, Intel&lt;/li&gt;
&lt;li&gt;Capsicum on Linux &amp;#8211; David Drysdale, Google&lt;/li&gt;
&lt;li&gt;Quantifying and Reducing the Kernel Attack Surface -  Anil Kurmus, IBM&lt;/li&gt;
&lt;li&gt;Extending the Linux Integrity Subsystem for TCB Protection &amp;#8211; David Safford &amp;amp; Mimi Zohar, IBM&lt;/li&gt;
&lt;li&gt;Application Confinement with User Namespaces &amp;#8211; Serge Hallyn &amp;amp; Stéphane Graber, Canonical&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Discussion session topics include Trusted Kernel Lock-down Patch Series, led by Kees Cook; and EXT4 Encryption, led by Michael Halcrow &amp;amp; Ted Ts&amp;#8217;o.   There&amp;#8217;ll be kernel security subsystem updates from the SELinux, AppArmor, Smack, and Integrity maintainers.  The break-out sessions are open format and a good opportunity to collaborate face-to-face on outstanding or emerging issues.&lt;/p&gt;
&lt;p&gt;See the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2014#Schedule&quot;&gt;schedule&lt;/a&gt; for more details.&lt;/p&gt;
&lt;p&gt;LSS2014 is open to all registered attendees of &lt;a href=&quot;http://events.linuxfoundation.org/events/linuxcon-north-america&quot;&gt;LinuxCon&lt;/a&gt;.  Note that discounted registration is available until the 18th of July (end of this week).&lt;/p&gt;
&lt;p&gt;See you in Chicago!&lt;/p&gt;</description>
	<pubDate>Tue, 15 Jul 2014 23:00:31 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Russell Coker (security): Fixing Strange Directory Write Access</title>
	<guid>http://etbe.coker.com.au/?p=4082</guid>
	<link>http://etbe.coker.com.au/2014/06/25/strange-directory-write-access/</link>
	<description>&lt;p&gt;type=AVC msg=audit(1403622580.061:96): avc:&amp;nbsp; denied&amp;nbsp; { write } for&amp;nbsp; pid=1331 comm=&quot;mysqld_safe&quot; name=&quot;/&quot; dev=&quot;dm-0&quot; ino=256 scontext=system_u:system_r:mysqld_safe_t:s0 tcontext=system_u:object_r:root_t:s0 tclass=dir&lt;br /&gt;
type=SYSCALL msg=audit(1403622580.061:96): arch=c000003e &lt;b&gt;syscall=269&lt;/b&gt; success=yes exit=0 a0=ffffffffffffff9c a1=7f5e09bfe798 a2=2 a3=2 items=0 ppid=1109 pid=1331 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=&quot;mysqld_safe&quot; exe=&quot;/bin/dash&quot; subj=system_u:system_r:mysqld_safe_t:s0 key=(null)&lt;/p&gt;
&lt;p&gt;For a long time (probably years) I&amp;#8217;ve been seeing messages like the above in the log from auditd (/var/log/audit/audit.log) when starting mysqld. I haven&amp;#8217;t fixed it because the amount of work exceeded the benefit, it&amp;#8217;s just a couple of lines logged at every system boot. But today I decided to fix it.&lt;/p&gt;
&lt;p&gt;The first step was to find out what was going on, I ran a test system in permissive mode and noticed that there were no attempts to create a file (that would have been easy to fix). Then I needed to discover which system call was triggering this. The syscall number is 269, the file linux/x86_64/syscallent.h in the strace source shows that 269 is the system call &lt;b&gt;faccessat&lt;/b&gt;. faccessat(2) and access(2) are annoying cases, they do all the permission checks for access but don&amp;#8217;t involve doing the operation so when a program uses those system calls but for some reason doesn&amp;#8217;t perform the operation in question (in this case writing to the root directory) then we just get a log entry but nothing happening to examine.&lt;/p&gt;
&lt;p&gt;A quick look at the shell script didn&amp;#8217;t make the problem obvious, note that this is probably obvious to people who are more skilled at shell scripting than me &amp;#8211; but it&amp;#8217;s probably good for me to describe how to solve these problems every step of the way. So the next step was to use gdb. Here is the start of my gdb session:&lt;/p&gt;
&lt;p&gt;# gdb /bin/sh&lt;br /&gt;
[skipped]&lt;br /&gt;
Reading symbols from /bin/dash&amp;#8230;(no debugging symbols found)&amp;#8230;done.&lt;br /&gt;
(gdb) b faccessat&lt;br /&gt;
Breakpoint 1 at 0&amp;#215;3960&lt;br /&gt;
(gdb) r -x /usr/bin/mysqld_safe&lt;br /&gt;
[lots skipped]&lt;br /&gt;
+ test -r /usr/my.cnf&lt;br /&gt;
Breakpoint 1, 0x00007ffff7b0c7e0 in faccessat ()&lt;br /&gt;
   from /lib/x86_64-linux-gnu/libc.so.6&lt;/p&gt;
&lt;p&gt;After running gdb on /bin/sh (which is a symlink to /bin/dash) I used the &amp;#8220;&lt;b&gt;b&lt;/b&gt;&amp;#8221; command to set a breakpoint on the function faccessat (which is a library call from glibc that calls the system call sys_faccessat()). A breakpoint means that program execution will stop when the function is called. I run the shell script with &amp;#8220;&lt;b&gt;-x&lt;/b&gt;&amp;#8221; as the first parameter to instruct the shell to show me the shell commands that are run so I can match shell commands to system calls. The above output shows the first call to faccessat() which isn&amp;#8217;t interesting (it&amp;#8217;s testing for read access).&lt;/p&gt;
&lt;p&gt;I then ran the &amp;#8220;&lt;b&gt;c&lt;/b&gt;&amp;#8221; command in gdb to continue execution and did so a few times until I found something interesting.&lt;/p&gt;
&lt;p&gt;+ test -w / -o root = root&lt;br /&gt;
Breakpoint 1, 0x00007ffff7b0c7e0 in faccessat ()&lt;br /&gt;
   from /lib/x86_64-linux-gnu/libc.so.6&lt;/p&gt;
&lt;p&gt;Above is the interesting part of the gdb output. It shows that the offending shell command is &amp;#8220;&lt;b&gt;test -w /&lt;/b&gt;&amp;#8220;.&lt;/p&gt;
&lt;p&gt;I filed &lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752593&quot;&gt;Debian bug #752593 [1]&lt;/a&gt; with a patch to fix this problem.&lt;/p&gt;
&lt;p&gt;I also filed &lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752595&quot;&gt;a wishlist bug against strace asking for an easier way to discover the name of a syscall [2]&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752593&quot;&gt; http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752593&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[2]&lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752595&quot;&gt; http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752595&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2010/07/12/write-execute-mmap-ld-preload/&quot; rel=&quot;bookmark&quot; title=&quot;Tracking down Write/Execute mmap() calls with LD_PRELOAD&quot;&gt;Tracking down Write/Execute mmap() calls with LD_PRELOAD &lt;/a&gt; &lt;small&gt;One of the access controls in SE Linux is for...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2009/06/02/the-way-dumb-people-think-smart-people-write/&quot; rel=&quot;bookmark&quot; title=&quot;How not to write the way dumb people think smart people write&quot;&gt;How not to write the way dumb people think smart people write &lt;/a&gt; &lt;small&gt;Don Marti has written an amusing and informative little post...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2008/09/12/fixing-execmod-textrel-problems-in-lenny/&quot; rel=&quot;bookmark&quot; title=&quot;Fixing execmod (textrel) Problems in Lenny&quot;&gt;Fixing execmod (textrel) Problems in Lenny &lt;/a&gt; &lt;small&gt;I&amp;#8217;ve just updated my repository of SE Linux related packages...&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Wed, 25 Jun 2014 02:40:42 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Dan Walsh: pam_mkhomedir versus SELinux -- Use pam_oddjob_mkhomedir</title>
	<guid>http://danwalsh.livejournal.com/69837.html</guid>
	<link>http://danwalsh.livejournal.com/69837.html</link>
	<description>SELinux is all about separation of powers, minamal privs or reasonable privs.&lt;br /&gt;&lt;br /&gt;If&amp;nbsp; you can break a program into several separate applications, then you can use SELinux to control what each application is allowed.&amp;nbsp; Then SELinux could prevent a hacked application from doing more then expected.&lt;br /&gt;&lt;br /&gt;The pam stack was invented a long time ago to allow customizations of the login process.&amp;nbsp; One problem with the pam_stack is it allowed programmers to slowly hack it up to give the programs more and more access.&amp;nbsp; I have seen pam modules that do some crazy stuff.&lt;br /&gt;&lt;br /&gt;Since we confine login applications with SELinux, we sometimes come in conflict with some of the more powerful pam modules.&lt;br /&gt;We in the SELinux world want to control what login programs can do.&amp;nbsp; For example we want to stop login programs like sshd from reading/writing all content in your homedir.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Why is this important?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Over the years it has been shown that login programs have had bugs that led to information leakage without the users ever being able to login to a system.&lt;br /&gt;&lt;br /&gt;One use case of pam, was the requirement of creating a homedir, the first time a user logs into a system.&amp;nbsp; Usually colleges and universities use this for students logging into a shared service.&amp;nbsp; But many companies use it also. &lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;man pam_mkhomedir&lt;/b&gt;&lt;br /&gt;&amp;nbsp; The pam_mkhomedir PAM module will create a users home directory if it does not exist when the session begins. This allows&amp;nbsp;&amp;nbsp;&amp;nbsp; users to be present in central database (such as NIS, kerberos or LDAP) without using a distributed file system or pre-creating a large number of directories. The skeleton directory (usually /etc/skel/) is used to copy default files and also sets a umask for the creation.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This means with pam_mkhomedir, login programs have to be allowed to create/read/write all content in your homedir.&amp;nbsp; This means we would have to allow sshd or xdm to read the content even if the user was not able to login, meaning a bug in one of these apps could allow content to be read or modified without the attacker ever logging into the machine.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;man pam_oddjob_mkhomedir&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The pam_oddjob_mkhomedir.so module checks if the user's home&amp;nbsp; directory exists,&amp;nbsp; and&amp;nbsp; if it does not, it invokes the mkhomedirfor method of the com.redhat.oddjob_mkhomedir service for the PAM_USER if the&amp;nbsp; module&amp;nbsp; is running with superuser privileges.&amp;nbsp; Otherwise, it invokes the mkmyhome‐dir method.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The location of the skeleton directory and the default umask are deter‐mined&amp;nbsp; by&amp;nbsp; the&amp;nbsp; configuration for the corresponding service in oddjobd-mkhomedir.conf, so they can not be specified as arguments to this&amp;nbsp; module.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp; D-Bus&amp;nbsp; has&amp;nbsp; not been configured to allow the calling application to invoke these methods provided as part of the&amp;nbsp; com.redhat.oddjob_mkhome‐dir interface of the / object provided by the com.redhat.oddjob_mkhome‐dir service, then oddjobd will not receive the&amp;nbsp; request&amp;nbsp; and&amp;nbsp; an&amp;nbsp; error&amp;nbsp; will be returned by D-Bus.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Nalin Dahyabhai wrote pam_oddjob_mkhomedir many years ago to separate out the ability to create a home directory and all of the content from the login programs.&amp;nbsp; Basically the pam module sends a dbus signal to a dbus service oddjob, which launches a tool to create the homedir and its content.&amp;nbsp; SELinux policy is written to allow this application to succeed.&amp;nbsp;&amp;nbsp; We end up with much less access required for the login programs.&lt;br /&gt;&lt;br /&gt;If you want the home directory created at login time if it does not exist. Use pam_oddjob_mkhomedir instead of pam_mkhomedir.</description>
	<pubDate>Wed, 04 Jun 2014 15:24:33 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: DAC_READ_SEARCH/DAC_OVERRIDE - common SELinux issue that people handle badly.</title>
	<guid>http://danwalsh.livejournal.com/69478.html</guid>
	<link>http://danwalsh.livejournal.com/69478.html</link>
	<description>&lt;span&gt;&lt;b&gt;MYTH: ROOT is all powerful.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Root is all powerful is a common misconception by administrators and users of Unix/Linux systems.&amp;nbsp; Many years ago the Linux kernel tried to break the power of root down into a series of capabilities.&amp;nbsp; Originally there were 32 capabilities, but recently that grew to 64.&amp;nbsp; Capabilities allowed programmers to code application in such a way that the ping command can create rawip-sockets or httpd can bind to a port less then 1024 and then drop all of the other capabilities of root.&lt;br /&gt;&lt;br /&gt;SELinux also controls the access to all of the capabilities for a process.&amp;nbsp;&amp;nbsp;&amp;nbsp; A common bugzilla is for a process requiring the DAC_READ_SEARCH or DAC_OVERRIDE capability.&amp;nbsp; DAC stands for Discretionary Access Control.&amp;nbsp; DAC Means standard Linux Ownership/permission flags.&amp;nbsp; Lets look at the power of the capabilities.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;more /usr/include/linux/capability.h&lt;br /&gt;...&lt;br /&gt;/* Override all DAC access, including ACL execute access if&lt;br /&gt;&amp;nbsp;&amp;nbsp; [_POSIX_ACL] is defined. Excluding DAC access covered by&lt;br /&gt;&amp;nbsp;&amp;nbsp; CAP_LINUX_IMMUTABLE. */&lt;br /&gt;&lt;br /&gt;#define CAP_DAC_OVERRIDE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;br /&gt;&lt;br /&gt;/* Overrides all DAC restrictions regarding read and search on files&lt;br /&gt;&amp;nbsp;&amp;nbsp; and directories, including ACL restrictions if [_POSIX_ACL] is&lt;br /&gt;&amp;nbsp;&amp;nbsp; defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */&lt;br /&gt;&lt;br /&gt;#define CAP_DAC_READ_SEARCH&amp;nbsp; 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you read the descriptions these basically say a process running as UID=0 with DAC_READ_SEARCH can read any file on the system, even if the permission flags would not allow a root process to read it.&amp;nbsp; Similarly DAC_OVERRIDE, means the process can ignore all permission/ownerships of all files on the system.&amp;nbsp; Usually when I see AVC messages that require this access, I take a look at the process UID, and almost always I see the process is running as uid=0.&lt;br /&gt;&lt;br /&gt;What users often do when they see this access denial is to add the permissions, which is almost always wrong.&amp;nbsp; These AVC's indicate to me that you have permission flags to tight on a file. Usually a config file.&lt;br /&gt;&lt;br /&gt;Imagine the httpd process needs to read /var/lib/myweb/content which is owned by the httpd user and has permissions 600 set on it.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;ls -l /var/lib/myweb/content&lt;br /&gt;-rw-------. 1 apache apache 0 May 12 13:50 /var/lib/myweb/content&lt;br /&gt;&lt;br /&gt;If for some reason the httpd process needs to read this file while it is running as UID=0, the system will deny access and generate a DAC_* AVC.&amp;nbsp; A simple fix would be to change the permission on the file to be 644.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# chmod 644 /var/lib/myweb/content&lt;br /&gt;# ls -l /var/lib/myweb/content&lt;br /&gt;-rw-r--r--. 1 apache apache 0 May 12 13:50 /var/lib/myweb/content&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which would now allow a root process to read the file using the &amp;quot;other&amp;quot; permissions. &lt;br /&gt;&lt;br /&gt;Another option would be to change the group to root and change the permissions to 640.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# chmod 640 /var/lib/myweb/content&lt;br /&gt;# chgrp root /var/lib/myweb/content&lt;br /&gt;# ls -l /var/lib/myweb/content&lt;br /&gt;-rw-r-----. 1 apache root 0 May 12 13:50 /var/lib/myweb/content&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now root can read the file based on the group permissions. but others can not read it.&amp;nbsp; You could also use ACLs to provide access.&amp;nbsp;&amp;nbsp;&amp;nbsp; Bottom line this is probably not an SELinux issue, and not something you want to loosen SELinux security around.&lt;br /&gt;&lt;br /&gt;One problem with SELinux system here is the capabilities AVC message does not tell you which object on the file system blocked the access by default.&amp;nbsp; The reason for this is performance as I explained in previous blog.&lt;br /&gt;&lt;dl&gt;&lt;br /&gt;&lt;dt&gt;&lt;br /&gt;&lt;a href=&quot;https://danwalsh.livejournal.com/34903.html&quot; rel=&quot;nofollow&quot;&gt;Why doen't SELinux give me the full path in an error message?&lt;/a&gt;&lt;/dt&gt;&lt;br /&gt;&lt;/dl&gt;&lt;br /&gt;If you turn on full auditing and regenerate the AVC, you will get the path of the object with the bad DAC Controls, as I explained in the blog.</description>
	<pubDate>Mon, 12 May 2014 18:02:57 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Writing custom policy for an Apache Application.</title>
	<guid>http://danwalsh.livejournal.com/69221.html</guid>
	<link>http://danwalsh.livejournal.com/69221.html</link>
	<description>&lt;b&gt;&lt;span&gt;Received the following email this week:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I've a PHP application that sends data to a USB tty device e.g. /dev/usbDataCollector&lt;br /&gt;&lt;br /&gt;Unfortunately selinux is blocking this action. When set to permissive, the alert browser suggests the command: &lt;br /&gt;&lt;br /&gt;setsebool -P daemons_use_tty 1&lt;br /&gt;&lt;br /&gt;The documentation says Allow all daemons the ability to use unallocated ttys. This naturally doesn't sound like a good idea although admittedly it probably won't hurt in this particular installation. However, I thought it would be good to find the 'correct' solution to this.&lt;br /&gt;&lt;br /&gt;But I am unable to find a more fine grain SELinux control for this, Fedora 20 has no documentation and the only vaguely relevant one I could find elsewhere is httpd_tty_com which appears unrelated as it is about allow httpd to communicate with terminal.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;So the question is whether there is any way to do this or is allowing all daemons the only option?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;My Answer&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Simplest would be to just use&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;# grep usbDataCollector /var/log/audit/audit.log | audit2allow -M myhttp&lt;br /&gt;# semodule -i myhttp.pp&lt;br /&gt;&lt;br /&gt;This would allow all httpd_t processes the ability to use usb_device_t, of course if you had other usb_device_t devices on your system, your apache processes would also gain access to them.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Tighter Controls &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;SELinux is a labeling system, so you can manipulate the labels on the system to get tighter controls.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;If you really wanted to tighten it up, you could build a custom policy that put a different label on /dev/usbDataCollector and allow httpd_t processes access to this label.&lt;br /&gt;&lt;br /&gt;Something like&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# cat myhttp.te&lt;br /&gt;policy_module(myhttp, 1.0)&lt;br /&gt;gen_require(`&lt;br /&gt;    type httpd_t;&lt;br /&gt;')&lt;br /&gt;&lt;br /&gt;type httpd_device_t;&lt;br /&gt;dev_node(httpd_device_t)&lt;br /&gt;&lt;br /&gt;allow httpd_t httpd_device_t:chr_file rw_chr_file_perms;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that I am create a new type httpd_device_t, and I define it as a device node, which gives it attributes to allow domains that manage devices to manage this new device.  Then I allow the apache process type, httpd_t, to be able to read/write chr_files with this label.&lt;br /&gt;&lt;span&gt;&lt;br /&gt;# cat myhttpd.fc&lt;br /&gt;/dev/usbDataCollector        -c   &lt;br /&gt;gen_context(system_u:object_r:httpd_device_t,s0)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I also want to put the label on the device automatically so I add a file context file with the /dev/usbDataCollector labeled as httpd_device_t.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# make -f /usr/share/selinux/devel/Makefile&lt;br /&gt;# semodule -i myhttpd.pp&lt;br /&gt;# restorecon -v /dev/usbDataCollector&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Finally I compile the myhttpd.te an myhttpd.fc file into a myhttpd.pp policy package, and install it on the system.  Since the device is probably already created I need to run restorecon on it to fix the label.  udev will set the label automatically on the next reboot.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now httpd_t processes would only be able to use the &lt;span&gt;/dev/usbDataCollector chr_file and not other usb devices on the system.&lt;/span&gt;&lt;br /&gt;&amp;lt;/div&amp;gt;</description>
	<pubDate>Tue, 06 May 2014 12:42:51 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>James Morris: Linux Security Summit 2014 (Chicago) -– Call for Participation</title>
	<guid>http://blog.namei.org/?p=572</guid>
	<link>http://blog.namei.org/2014/04/29/linux-security-summit-2014-chicago-%e2%80%93-call-for-participation/</link>
	<description>&lt;p&gt;The CFP for the 2014 Linux Security Summit is &lt;a href=&quot;http://marc.info/?l=linux-security-module&amp;amp;m=139876957318328&amp;amp;w=2&quot;&gt;announced&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;LSS 2014 will be co-located with LinuxCon North America in Chicago, on the 18th and 19th of August.  We&amp;#8217;ll also be co-located with the Kernel Summit this year.&lt;/p&gt;
&lt;p&gt;Note that, as always, we&amp;#8217;re looking for participation from the general Linux community &amp;#8212; not just kernel people, and not just developers.  We&amp;#8217;re interested in hearing about feedback from users, and discussing what kinds of security problems we need to be addressing into the future.&lt;/p&gt;
&lt;p&gt;This year, we&amp;#8217;re looking for discussion topics as well as paper presentations, so if you have anything interesting to talk about, send in a proposal.&lt;/p&gt;
&lt;p&gt;The CFP closes on &lt;span&gt;6th June&lt;/span&gt; &lt;strong&gt;21st June&lt;/strong&gt;.&lt;/p&gt;</description>
	<pubDate>Tue, 29 Apr 2014 11:41:10 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Russell Coker (security): Replacement Credit Cards and Bank Failings</title>
	<guid>http://etbe.coker.com.au/?p=3978</guid>
	<link>http://etbe.coker.com.au/2014/04/12/replacement-credit-cards-and-bank-failings/</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://krebsonsecurity.com/2014/02/card-backlog-extends-pain-from-target-breach/&quot;&gt;I just read an interesting article by Brian Krebs about the difficulty in replacing credit cards [1]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The main reason that credit cards need to be replaced is that they have a single set of numbers that is used for all transactions. If credit cards were designed properly for modern use (IE since 2000 or so) they would act as a smart-card as the recommended way of payment in store. Currently I have a Mastercard and an Amex card, the Mastercard (issued about a year ago) has no smart-card feature and as Amex is rejected by most stores I&amp;#8217;ve never had a chance to use the smart-card part of a credit card. If all American credit cards had a smart card feature which was recommended by store staff then the problems that Brian documents would never have happened, the attacks on Target and other companies would have got very few card numbers and the companies that make cards wouldn&amp;#8217;t have a backlog of orders.&lt;/p&gt;
&lt;p&gt;If a bank was to buy USB smart-card readers for all their customers then they would be very cheap (the hardware is simple and therefore the unit price would be low if purchasing a few million). As banks are greedy they could make customers pay for the readers and even make a profit on them. Then for online banking at home the user could use a code that&amp;#8217;s generated for the transaction in question and thus avoid most forms of online banking fraud &amp;#8211; the only possible form of fraud would be to make a $10 payment to a legitimate company become a $1000 payment to a fraudster but that&amp;#8217;s a lot more work and a lot less money than other forms of credit card fraud.&lt;/p&gt;
&lt;p&gt;A significant portion of all credit card transactions performed over the phone are made from the customer&amp;#8217;s home. Of the ones that aren&amp;#8217;t made from home a significant portion would be done from a hotel, office, or other place where a smart-card reader might be conveniently used to generate a one-time code for the transaction.&lt;/p&gt;
&lt;p&gt;The main remaining problem seems to be the use of raised numbers. Many years ago it used to be common for credit card purchases to involve using some form of &amp;#8220;carbon paper&amp;#8221; and the raised numbers made an impression on the credit card transfer form. I don&amp;#8217;t recall ever using a credit card in that way, I&amp;#8217;ve only had credit cards for about 18 years and my memories of the raised numbers on credit cards being used to make an impression on paper only involve watching my parents pay when I was young. It seems likely that someone who likes paying by credit card and does so at small companies might have some recent experience of &amp;#8220;carbon paper&amp;#8221; payment, but anyone who prefers EFTPOS and cash probably wouldn&amp;#8217;t.&lt;/p&gt;
&lt;p&gt;If the credit card number (used for phone and Internet transactions in situations where a smart card reader isn&amp;#8217;t available) wasn&amp;#8217;t raised then it could be changed by posting a sticker with a new number that the customer could apply to their card. The customer wouldn&amp;#8217;t even need to wait for the post before their card could be used again as the smart card part would never be invalid. The magnetic stripe on the card could be changed at any bank and there&amp;#8217;s no reason why an ATM couldn&amp;#8217;t identify a card by it&amp;#8217;s smart-card and then write a new magnetic stripe automatically.&lt;/p&gt;
&lt;p&gt;These problems aren&amp;#8217;t difficult to solve. The amounts of effort and money involved in solving them are tiny compared to the costs of cleaning up the mess from a major breach such as the recent Target one, the main thing that needs to be done to implement my ideas is widespread support of smart-card readers and that seems to have been done already. It seems to me that the main problem is the incompetence of financial institutions. I think the fact that there&amp;#8217;s no serious competitor to Paypal is one of the many obvious proofs of the incompetence of financial companies.&lt;/p&gt;
&lt;p&gt;The effective operation of banks is essential to the economy and the savings of individuals are guaranteed by the government (so when a bank fails a lot of tax money will be used). It seems to me that we need to have national banks run by governments with the aim of financial security. Even if banks were good at their business (and they obviously aren&amp;#8217;t) I don&amp;#8217;t think that they can be trusted with it, an organisation that&amp;#8217;s &amp;#8220;too big to fail&amp;#8221; is too big to lack accountability to the citizens.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://krebsonsecurity.com/2014/02/card-backlog-extends-pain-from-target-breach/&quot;&gt; http://tinyurl.com/msfby5q&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2008/04/11/football-cards-and-kittens/&quot; rel=&quot;bookmark&quot; title=&quot;Football Cards and Free Kittens&quot;&gt;Football Cards and Free Kittens &lt;/a&gt; &lt;small&gt;My cousin Greg Coker has created an eBay auction for...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2009/06/11/millennium-seed-bank/&quot; rel=&quot;bookmark&quot; title=&quot;The Millennium Seed Bank&quot;&gt;The Millennium Seed Bank &lt;/a&gt; &lt;small&gt;Jonathan Drori gave an interesting TED talk about the Millenium...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2010/05/16/systemd-init/&quot; rel=&quot;bookmark&quot; title=&quot;systemd &amp;#8211; a Replacement for init etc&quot;&gt;systemd &amp;#8211; a Replacement for init etc &lt;/a&gt; &lt;small&gt;The systemd projecct is an interesting concept for replacing init...&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Sat, 12 Apr 2014 00:25:39 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Dan Walsh: DAC check before MAC check.  SELinux will stop wine'ing.</title>
	<guid>http://danwalsh.livejournal.com/69035.html</guid>
	<link>http://danwalsh.livejournal.com/69035.html</link>
	<description>When it comes to SELinux, one of the most aggravating bugs we see are when the kernel does a MAC check before a DAC Check.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;This means SELinux checks happen before normal ownership/permission checks.&amp;nbsp; I always prefer to have the DAC check happen first.&amp;nbsp; This is important because code that is attempting the denied access usually will handle the EPERM silently and go down a different code path.&amp;nbsp;&amp;nbsp;&amp;nbsp; But if a MAC Failure happens, SELinux writes an AVC to the audit log, and setroubleshoot reports it to the user.&lt;br /&gt;&lt;br /&gt;One of the biggest offenders of this was the mmap_zero check.&amp;nbsp; Every time a process tries to map low kernel memory, the kernel denies it, in both DAC and MAC.&amp;nbsp; Wine applications are notorious for this.&amp;nbsp; We block mmap_zero because it can potentially trigger kernel bugs which can lead to privilege escalation.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://eparis.livejournal.com/891.html&quot; rel=&quot;nofollow&quot;&gt;Eric Paris explains the vulnerability here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Since the MAC check was done before the DAC check, the wine applications tend to work correctly.&amp;nbsp; When the wine application attempts to mmap low memory, it gets denied, and then reattempts the mmap with a higher memory value.&amp;nbsp; On an SELinux system the kernel generates AVC.&amp;nbsp; The user sees something like:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SELinux is preventing /usr/bin/wine-preloader from 'mmap_zero' accesses on the memprotect.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Reading about the mmap_zero, scares the user and they think their machine is vulnerable.&amp;nbsp; The only thing SELinux policy writers can do is write a dontaudit rule or allow the access, which defeats the purpose of the check.&lt;br /&gt;&lt;br /&gt;We still want to block this access if a privileged confined process got it and report the SELinux violation. &amp;nbsp; If an confined application running as root, attempts a mmap_zero access, SELinux should block it and report the AVC.&amp;nbsp; If a normal unprivileged process triggered the access check, we would prefer to allow DAC to handle it, and not print the message.&lt;br /&gt;&lt;br /&gt;To give you an idea of how often people have seen this; Google &amp;quot;SELinux mmap_zero&amp;quot; and you will get more then 13,000 hits.&lt;br /&gt;&lt;br /&gt;Today the upstream kernel has been fixed to report check for mmap_zero for MAC &lt;b&gt;AFTER&lt;/b&gt; DAC. &lt;br /&gt;&lt;br /&gt;Thanks to Eric Paris and Paul Moore for fixing this issue.</description>
	<pubDate>Wed, 05 Mar 2014 13:53:10 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: SELinux Transitions do not happen on mountpoints mounted with nosuid.</title>
	<guid>http://danwalsh.livejournal.com/68723.html</guid>
	<link>http://danwalsh.livejournal.com/68723.html</link>
	<description>Today one of our customers was trying to run openshift enterprise and it was blowing up because of SELinux.&lt;br /&gt;Openshift sets up the Apache daemon to run /var/www/openshift/broker/script/broker_ruby.&lt;br /&gt;&lt;br /&gt;When looked at the log, it was stating that Apache was not allowed to execute broker_ruby permission denied.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;ls -lZ /var/www/openshift/broker/script/broker_ruby&lt;/span&gt;&lt;br /&gt;Shows that broker_ruby is labeled as&lt;span&gt; httpd_sys_content_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I went and looked at policy, I saw.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch -A -s httpd_t -t httpd_sys_content_t -p execute -C&lt;br /&gt;DT allow httpd_t httpdcontent : file { ioctl read write create getattr setattr lock append unlink link rename execute open } ; [ httpd_enable_cgi httpd_unified &amp;amp;&amp;amp; httpd_builtin_scripting &amp;amp;&amp;amp; ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This shows that the httpd_t (Apache) process is allowed to execute the broker_ruby script if all of the following booleans are enabled.&lt;br /&gt;&lt;span&gt;httpd_enable_cgi, httpd_unified, httpd_builtin_scripting&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Turns out the were.&amp;nbsp; I then went back and looked at the AVC.&lt;br /&gt;&lt;br /&gt;type=AVC msg=audit(28/02/14 13:56:52.702:24992) : avc:&amp;nbsp; denied&amp;nbsp; {&lt;span&gt; execute_no_trans&lt;/span&gt; } for&amp;nbsp; pid=6031 comm=PassengerHelper path=/var/www/openshift/broker/script/broker_ruby dev=dm-3 ino=817 scontext=unconfined_u:system_r:&lt;span&gt;httpd_t&lt;/span&gt;:s0 tcontext=unconfined_u:object_r:&lt;span&gt;httpd_sys_content_t&lt;/span&gt;:s0 tclass=&lt;span&gt;file &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This AVC means that the Apache daemon (httpd_t) is not allowed to execute the broker_ruby application (httpd_sys_content_t) without a transition, meaning in the current label (httpd_t).&lt;br /&gt;&lt;br /&gt;Which I understood, since when the above booleans are turned on httpd_t is supposed to transition to httpd_sys_script_t when executing httpd_sys_content_t.&amp;nbsp; This sesearch command shows the transition rule.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch -T -s httpd_t -t httpd_sys_content_t -c process -C&lt;br /&gt;DT type_transition httpd_t httpd_sys_content_t : process httpd_sys_script_t; [ httpd_enable_cgi httpd_unified &amp;amp;&amp;amp; httpd_builtin_scripting &amp;amp;&amp;amp; ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Why wasn't the process transitioning?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Then I remembered that SELinux transitions do not happen on mounted partitions that are mounted with the nosuid flag.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;man mount&lt;br /&gt;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nosuid Do not allow set-user-identifier or set-group-identifier bits to take effect. (This seems safe, but is in fact rather&amp;nbsp; unsafe&amp;nbsp; if&amp;nbsp; you have suidperl(1) installed.)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SELinux designers feel that a transition can be a potential privilege escalation similar to a suid root application.&amp;nbsp; Therefore if an administrator has told the system that no suid apps should be allowed on a mount point, then it also means no SELinux transitions will happen.&lt;br /&gt;&lt;br /&gt;Removing the nosuid flag from the mount point fixes the problem.</description>
	<pubDate>Fri, 28 Feb 2014 18:43:37 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>James Morris: Save the Date: 2014 Linux Security Summit in Chicago</title>
	<guid>http://blog.namei.org/?p=570</guid>
	<link>http://blog.namei.org/2014/02/13/save-the-date-2014-linux-security-summit-in-chicago/</link>
	<description>&lt;p&gt;The 2014 &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2014&quot;&gt;Linux Security Summit&lt;/a&gt; will be held on the 18th and 19th of August, co-located with &lt;a href=&quot;http://events.linuxfoundation.org/events/linuxcon-north-america&quot;&gt;LinuxCon&lt;/a&gt; in Chicago, IL, USA.  The Kernel Summit and several other events will also be co-located there this year.&lt;/p&gt;
&lt;p&gt;The Call for Participation will be announced later via the &lt;a href=&quot;http://vger.kernel.org/vger-lists.html#linux-security-module&quot;&gt;LSM mailing list&lt;/a&gt;.&lt;/p&gt;</description>
	<pubDate>Thu, 13 Feb 2014 13:55:38 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Russell Coker (security): Fingerprints and Authentication</title>
	<guid>http://etbe.coker.com.au/?p=3855</guid>
	<link>http://etbe.coker.com.au/2014/02/10/fingerprints-authentication/</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://blog.dustinkirkland.com/2013/10/fingerprints-are-user-names-not.html&quot;&gt;Dustin Kirkland wrote an interesting post about fingerprint authentication [1]&lt;/a&gt;. He suggests using fingerprints for identifying users (NOT authentication) and gives an example of a married couple sharing a tablet and using fingerprints to determine who&amp;#8217;s apps are loaded.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://err.no/personal/blog/tech/2013-10-03-11-20_fingerprints_as_lightweight_auth.html&quot;&gt;In response Tollef Fog Heen suggests using fingerprints for lightweight authentication, such as resuming a session after a toilet break [2]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I think that &lt;a href=&quot;http://xkcd.com/1200/&quot;&gt;one of the best comments on the issue of authentication for different tasks is in XKCD comic 1200 [3]&lt;/a&gt;. It seems obvious that the division between administrator (who installs new device drivers etc) and user (who does everything from playing games to online banking with the same privileges) isn&amp;#8217;t working, and never could work well &amp;#8211; particularly when the user in question installs their own software.&lt;/p&gt;
&lt;p&gt;I think that one thing which is worth considering is the uses of a signature. A signature can be easily forged in many ways and they often aren&amp;#8217;t checked well. It seems that there are two broad cases of using a signature, one is to enter into legally binding serious contract such as a mortgage (where wanting to sign is the relevant issue) and the other is cases where the issue doesn&amp;#8217;t matter so much (EG signing off on a credit card purchase where the parties at risk can afford to lose money on occasion for efficient transactions). Signing is relatively easy but that&amp;#8217;s because it either doesn&amp;#8217;t matter much or because it&amp;#8217;s just a legal issue which isn&amp;#8217;t connected to authentication. The possibility of serious damage (sending life savings or incriminating pictures to criminals in another jurisdiction) being done instantly never applied to signatures. It seems to me that in many ways signatures are comparable to fingerprints and both of them aren&amp;#8217;t particularly good for authentication to a computer.&lt;/p&gt;
&lt;p&gt;In regard to Tollef&amp;#8217;s ideas about &amp;#8220;lightweight&amp;#8221; authentication I think that the first thing that would be required is direct user control over the authentication required to unlock a system. I have read about some Microsoft research into a computer monitoring the office environment to better facilitate the user&amp;#8217;s requests, an obvious extension to such research would be to have greater unlock requirements if there are more unknown people in the area or if the device is in a known unsafe location. But apart from that sort of future development it seems that having the user request a greater or lesser authentication check either at the time they lock their session or by policy would make sense. Generally users have a reasonable idea about the risk of another user trying to login with their terminal so user should be able to decide that a toilet break when at home only requires a fingerprint (enough to keep out other family members) while a toilet break at the office requires greater authentication. Mobile devices could use GPS location to determine unlock requirements, GPS can be forged, but if your attacker is willing and able to do that then you have a greater risk than most users.&lt;/p&gt;
&lt;p&gt;Some users turn off authentication on their phone because it&amp;#8217;s too inconvenient. If they had the option of using a fingerprint most of the time and a password for the times when a fingerprint can&amp;#8217;t be read then it would give an overall increase in security.&lt;/p&gt;
&lt;p&gt;Finally it should be possible to unlock only certain applications. Recent versions of Android support widgets on the lock screen so you can perform basic tasks such as checking the weather forecast without unlocking your phone. But it should be possible to have different authentication requirements for various applications. Using a fingerprint scan to allow playing games or reading email in the mailing list folder would be more than adequate security. But reading the important email and using SMS probably needs greater authentication. This takes us back to the XKCD cartoon.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://blog.dustinkirkland.com/2013/10/fingerprints-are-user-names-not.html&quot;&gt; http://blog.dustinkirkland.com/2013/10/fingerprints-are-user-names-not.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[2]&lt;a href=&quot;http://err.no/personal/blog/tech/2013-10-03-11-20_fingerprints_as_lightweight_auth.html&quot;&gt; http://tinyurl.com/lak528z&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[3]&lt;a href=&quot;http://xkcd.com/1200/&quot;&gt; http://xkcd.com/1200/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2012/06/20/sasl-authentication-wheezy/&quot; rel=&quot;bookmark&quot; title=&quot;SASL Authentication and Debian/Wheezy&quot;&gt;SASL Authentication and Debian/Wheezy &lt;/a&gt; &lt;small&gt;After upgrading a mail server to Debian/Unstable (which will soon...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2006/11/16/biometrics-and-passwords/&quot; rel=&quot;bookmark&quot; title=&quot;biometrics and passwords&quot;&gt;biometrics and passwords &lt;/a&gt; &lt;small&gt;In a comment on my post more about securing an...&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Mon, 10 Feb 2014 05:07:12 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Dan Walsh: Containers your time is now.  Lets look at Namespaces.</title>
	<guid>http://danwalsh.livejournal.com/68480.html</guid>
	<link>http://danwalsh.livejournal.com/68480.html</link>
	<description>Lately I have been spending a lot of time working on Containers.&amp;nbsp; Containers are a mechanism for controlling what a process does on a system.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Resource Constraints can be considered a form of containerment.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In Fedora and RHEL we use cgroups for this, and with the new systemd controls in Fedora and RHEL7, managing cgroups has gotten a lot easier.&amp;nbsp; Out of the box all of your processes are put into a cgroup based on whether they are a user, system service or a Machine (VMs).&amp;nbsp; These processes are grouped at the unit level, meaning two users logged into a system will get and &amp;quot;Fair Share&amp;quot; of the system, even if one user forks off thousands of processes.&amp;nbsp; Similarly if you run an httpd service and a mariadb service, they each get an equal share of the system, meaning that httpd can not fork 1000 process while mariadb only runs three, the httpd 1000 processes can not dominate the machine leaving no memory of cpu for mariadb.&amp;nbsp; Of course you can go into the unit files for httpd or mariadb and add a couple of simple resource constraints to further limit them&lt;br /&gt;&lt;br /&gt;Adding&lt;br /&gt;&lt;br /&gt;MemoryLimit: 500m&lt;br /&gt;&lt;br /&gt;to httpd.service&amp;nbsp; unit file&lt;br /&gt;&lt;br /&gt;For example will limit the service to only use 500 megabytes to httpd processes.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Security Containment&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Some could say I have been working on containers for years since SELinux is a container technology for controlling what a process does on the system.&amp;nbsp; I will talk about SELinux and advanced containers in my next blog.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Process Separation Containment&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The last component of containers is Namespaces.&amp;nbsp; The linux kernel implements a few namespaces for process separation.&amp;nbsp; There are currently 6 namespaces.&lt;br /&gt;&lt;br /&gt;Namespaces can be used to Isolate processes. They can create a new environment where changes to the process are not reflected in other namespace.&lt;br /&gt;Once set up, namespaces are transparent for processes.&lt;br /&gt;&lt;br /&gt;Red Hat Enterprise Linux&amp;nbsp; and Fedora currently support 5 namespace&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;ipc&lt;/li&gt;&lt;br /&gt;&lt;li&gt;ipc namespace allows you to have shared memory, semaphores with only processes within the namespace.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;pid&lt;/li&gt;&lt;br /&gt;&lt;li&gt;pid namespace eliminates the view of other processes on the system and restarts pids at pid 1.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;mnt&lt;/li&gt;&lt;br /&gt;&lt;li&gt;mnt namespace allows processes within the container to mount file systemd over existing files/directories without affecting file systems outside the namespace&lt;/li&gt;&lt;br /&gt;&lt;li&gt;net&lt;/li&gt;&lt;br /&gt;&lt;li&gt;net namespace creates network devices that can have IP Addresses assigned to them, and even configure iptables rules and routing tables&lt;/li&gt;&lt;br /&gt;&lt;li&gt;uts&lt;/li&gt;&lt;br /&gt;&lt;li&gt;uts namespace allows you to assign a different hostname to processes within the container. Often useful with the network namespace&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div&gt;&lt;div&gt;Rawhide also supports the user namespace.&amp;nbsp; We hope to add the user namespace support to a&amp;nbsp; future Red Hat Enterprise Linux 7.&lt;br /&gt;&lt;br /&gt;User namespace allows you to map real user ids on the host to container uids.&amp;nbsp; For example you can map UID 5000-5100 to 0-100 within the container.&amp;nbsp; This means you could have uid=0 with rights to manipulate other namespaces within the container.&amp;nbsp; You could for example set the IP Address on the network namespaced ethernet device.&amp;nbsp; Outside of the container your process would be treated as a non privileged process.&amp;nbsp; User namespace is fairly young and people are just starting to use it.&lt;br /&gt;&lt;br /&gt;I have put together a video showing namespaces in Red Hat Enterprise Linux 7.&lt;br /&gt;&lt;/div&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=e4NXJ5nM-_M&amp;amp;feature=youtu.be&quot; rel=&quot;nofollow&quot;&gt;https://www.youtube.com/watch?v=e4NXJ5nM-_M&amp;amp;feature=youtu.be&lt;/a&gt;&lt;/div&gt;</description>
	<pubDate>Fri, 31 Jan 2014 16:44:17 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: file_t we hardly new you...</title>
	<guid>http://danwalsh.livejournal.com/68189.html</guid>
	<link>http://danwalsh.livejournal.com/68189.html</link>
	<description>file_t disappeared as a file type in Rawhide today.&amp;nbsp; It is one of the oldest types in SELinux policy.&amp;nbsp; It has been aliased to unlabeled_t.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Why did we remove it?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Let's look at the comments written in the policy source to describe file_t.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# file_t is the default type of a file that has not yet been&lt;br /&gt;# assigned an extended attribute (EA) value (when using a filesystem&lt;br /&gt;# that supports EAs).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now lets look at the description of unlabeled_t&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# unlabeled_t is the type of unlabeled objects.&lt;br /&gt;# Objects that have no known labeling information or that&lt;br /&gt;# have labels that are no longer valid are treated as having this type.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Notice the conflict.&lt;br /&gt;&lt;br /&gt;If a file object does not have a labeled assigned to it, then it would be labeled unlabeled_t.&amp;nbsp; Unless it is on a file system that supports extended attributes then it would be file_t? &lt;br /&gt;&lt;br /&gt;I always hated explaining this, and we have finally removed the conflict for future Fedora's.&amp;nbsp; Sadly this change has not been made in RHEL7 or any older RHELs or Fedoras.&lt;br /&gt;&lt;br /&gt;We also added a type alias for unlabeled_t to file_t. &lt;br /&gt;&lt;br /&gt;Note: Seandroid made this change when the policy was first being written.&lt;br /&gt;&lt;br /&gt;One other conflict I would like to fix is that a file with a label that the kernel does not understand, is labeled unlabeled_t. (IE It has a label but it is invalid.)&amp;nbsp; I have argued for having the kernel differentiate the two situations. &lt;ul&gt;&lt;br /&gt;&lt;li&gt;No label -&amp;gt; unlabeled_t&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Invalid Label -&amp;gt; invalid_t.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;Upstream has pointed out from a practical/security point of view you really need to treat them both as the same thing.&amp;nbsp; Confined domains are not allowed to use unlabeled_t objects.&amp;nbsp; And if it is a file system object you should run restorecon on it.&amp;nbsp; Putting a legitimate label on the object.&amp;nbsp; Probably I will not get this change, but I can always hope.&amp;nbsp;</description>
	<pubDate>Mon, 13 Jan 2014 15:01:24 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Russell Coker (security): Dr Suelette Dreyfus LCA Keynote</title>
	<guid>http://etbe.coker.com.au/?p=3864</guid>
	<link>http://etbe.coker.com.au/2014/01/08/suelette-dreyfus-lca/</link>
	<description>&lt;p&gt;Dr Suelette Dreyfus gave an interesting LCA keynote speech on Monday (&lt;a href=&quot;http://mirror.linux.org.au/pub/linux.conf.au/2014/&quot;&gt;it&amp;#8217;s online now for people who aren&amp;#8217;t attending LCA [1]&lt;/a&gt;). One of the interesting points she made was regarding the greater support for privacy protection in Germany, this is apparently due to so many German citizens having read their own Stasi files.&lt;/p&gt;
&lt;p&gt;The section of her talk about the technology that is being used against us today was very concerning. I wonder whether we should plan to move away from using any hardware or closed source software from the US, China, and probably most countries other than Germany. &lt;/p&gt;
&lt;p&gt;We really need to consider these issues at election time. &lt;a href=&quot;http://etbe.coker.com.au/2013/12/23/political-advocacy-clubs/&quot;&gt;I have previously blogged some rough ideas about having organisations such as Linux Australia poll parties to determine how well they represent the interests of citizens who use Linux [2]&lt;/a&gt;. I think that such things are even more important now. &lt;a href=&quot;http://www.wired.com/threatlevel/2014/01/how-the-us-almost-killed-the-internet/all/&quot;&gt;Steven Levy wrote an interesting summary of the situation for Wired [3]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;At the end of her talk Suelette suggested that Aspies might be more likely to be whistle-blowers due to being unable to recognise the social signals about such things (IE managers say that they won&amp;#8217;t punish people for speaking out but most people recognise that to be lies). It&amp;#8217;s a plausible theory but I&amp;#8217;m worried that managers might decide to avoid hiring Aspies because of this. I wonder how many managers plan to have illegal activity as an option. But I guess that having criminals refuse to hire me wouldn&amp;#8217;t be such a bad thing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://mirror.linux.org.au/pub/linux.conf.au/2014/&quot;&gt; http://mirror.linux.org.au/pub/linux.conf.au/2014/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[2]&lt;a href=&quot;http://etbe.coker.com.au/2013/12/23/political-advocacy-clubs/&quot;&gt; http://etbe.coker.com.au/2013/12/23/political-advocacy-clubs/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[3]&lt;a href=&quot;http://www.wired.com/threatlevel/2014/01/how-the-us-almost-killed-the-internet/all/&quot;&gt; http://tinyurl.com/lz4h4e6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss yarpp-related-none&quot;&gt;
&lt;p&gt;No related posts.&lt;/p&gt;
&lt;/div&gt;</description>
	<pubDate>Wed, 08 Jan 2014 00:37:20 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Dan Walsh: How come somethings get blocked by SELinux in permissive mode?</title>
	<guid>http://danwalsh.livejournal.com/67855.html</guid>
	<link>http://danwalsh.livejournal.com/67855.html</link>
	<description>SELinux can be setup to run in three modes.&lt;br /&gt;&lt;br /&gt;* Enforcing (My favorite)&lt;br /&gt;* Permissive&lt;br /&gt;* Disabled&lt;br /&gt;&lt;br /&gt;Often permissive is described as the same as enforcing except everything is allowed and logged.&lt;br /&gt;&lt;br /&gt;For the most part this is true, except when their are bugs or a &amp;quot;Access Control Manager&amp;quot; does not respect the permissive flag.&lt;br /&gt;&lt;br /&gt;Most of SELinux is written where the kernel control's access, and it would be very strange for the kernel to block an access in permissive mode.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;But there are several situations where we want to check access outside the kernel.&amp;nbsp; For example.&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Can an application connect to a particular dbus daemon? &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Can a service start a particular systemd daemon? &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Can a root process change the password of something?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Will sshd allow dwalsh to login as unconfined_t? &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;All of these checks are not seen by the kernel.&amp;nbsp; We implement SELinux checks in places like dbus daemon, systemd, X Server, sshd, passwd ...&amp;nbsp; When one of these services denies access you will see a USER_AVC generated rather then an AVC.&amp;nbsp; If these SELinux checks are not written correctly to check the permissive flag when an access is denied, you could get a real denial in permissive mode. &lt;br /&gt;&lt;br /&gt;Usually we see these as bugs, but in certain situations the upstream does not want to accept patches to check the permissive flag.&lt;br /&gt;&lt;br /&gt;If you know of a situation where this happens, open a bugzilla on it and we can work with the packager to fix the problem.&lt;br /&gt;&lt;br /&gt;When you see an AVC or USER_AVC that is generated in permissive mode, you should see a flag that states &amp;quot;success=yes&amp;quot; in the AVC record, this indicates that the AVC was generated but still allowed.&amp;nbsp; If it says &amp;quot;success=no&amp;quot; in permissive mode then that should be considered a bug.</description>
	<pubDate>Thu, 02 Jan 2014 15:33:11 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Awesome new coreutils with improved SELinux support</title>
	<guid>http://danwalsh.livejournal.com/67751.html</guid>
	<link>http://danwalsh.livejournal.com/67751.html</link>
	<description>&lt;p&gt;When I first started working on SELinux over 10 years ago, one of the first packages I worked on was coreutils.&amp;nbsp;&amp;nbsp;&amp;nbsp; We were adding SELinux support to insure proper handling of labeling.&amp;nbsp; After that we did not touch it for several years. &lt;br /&gt;&lt;br /&gt;Last year, I decided to investigate if I could improve coreutils handling of labels on initial content creation.&amp;nbsp;&amp;nbsp; Well it took a while but my patches were finally accepted, with lots of fixes from the upstream, and coreutils-8.22 just showed up today in&amp;nbsp; Rawhide.&lt;br /&gt;&lt;br /&gt;I am very excited about this release.&amp;nbsp; I believe it can allow Administrators to fix one of the biggest problems users have with SELinux, objects getting created with the incorrect context.&lt;br /&gt;&lt;br /&gt;My patches basically standardized &amp;quot;-Z&amp;quot; with no options to indicate you wanted the target directory to get the &amp;quot;default&amp;quot; label. &lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# touch /tmp/foobar&lt;br /&gt;# mv /tmp/foobar /etc&lt;br /&gt;# ls -lZ /etc/foobar&lt;br /&gt;# -rw-r--r--. root root staff_u:object_r:&lt;b&gt;user_tmp_t&lt;/b&gt;:s0&amp;nbsp;&amp;nbsp; /etc/foobar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As opposed to:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# touch /tmp/foobar&lt;br /&gt;# mv -Z /tmp/foobar /etc&lt;br /&gt;# ls -lZ /etc/foobar&lt;br /&gt;# -rw-r--r--. root root staff_u:object_r:&lt;b&gt;etc_t&lt;/b&gt;:s0&amp;nbsp;&amp;nbsp; /etc/foobar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The traditional use of a command like mv was to maintain the &amp;quot;Security&amp;quot; of an object you are moving.&amp;nbsp; mv command would maintain the ownership, permissions, and SELinux Labels.&amp;nbsp; The problem with this is users/administrators would not expect this, by adding the &amp;quot;-Z&amp;quot; to the mv command, the administrator guarantees that the object will get he correct label based on the destination path, which over the years, I believe is what the administrator would expect.&amp;nbsp; The &amp;quot;-Z&amp;quot; option in coreutils now indicates the equivalent of running restorecon on the target, except in most cases the label is correct on creation of the content.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;&amp;quot;mv -Z /tmp/foobar /etc/foobar&amp;quot; &lt;/b&gt;&lt;/span&gt;&lt;span&gt;&lt;b&gt;==&lt;/b&gt;&lt;/span&gt;&lt;span&gt;&lt;b&gt; &amp;quot;mv /tmp/foobar /etc/foobar; restorecon /tmp/foobar&lt;/b&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of the reasons we did not do this sooner, was the speed of reading in the labeling database.&amp;nbsp; The latest SELinux toolchain loads the labeling database in a fraction of the previous time, allowing us to make these changes.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Setting up coreutils alias&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I would even suggest that it would be a good idea to alias&lt;br /&gt;&lt;br /&gt;&lt;span&gt;alias mv='mv -Z'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;for most users.&lt;br /&gt;&lt;br /&gt;A common mistake is to mv content around in the homedir.&amp;nbsp;&amp;nbsp; A mistake I have made in the past was to an html file to a my account on people.fedoraproject.org and then to ssh into the machine and then mv it to the public_html directory.&amp;nbsp; ~/public_html is labeled httpd_user_content_t which is readable by default from the apache server, while the default label of my homedir is not, user_home_t.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;mv ~/content.html ~/public_html/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This command would end up with the ~/public_html/content.html being labeled user_home_t, and the page would not show up on the web site.&amp;nbsp; Users would not know why, and would probably not no about SELinux.&amp;nbsp; But if the admistrator changed the alias for the mv command, everything would just work.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Other Commands&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Similarly the -Z option has been implemented for all of the commands that create content in coreutils. &lt;br /&gt;&lt;br /&gt;&lt;span&gt;mknod -Z, mkdir -Z, mkfifo -Z, install -Z&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Currently in init scripts we have lots of code that does; \&lt;br /&gt;&lt;br /&gt;&lt;span&gt;mkdir /run/myapp; restorecon /run/myapp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which can be replaced with&lt;br /&gt;&lt;br /&gt;&lt;span&gt;mkdir -Z /run/myapp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What about Disabled Machines, or machines that do not support SELinux?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On an SELinux disabled system, the -Z option will be ignored.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Getting the Label correct at file creation has been improved greatly in the current Fedora's with the introduction of file name transitions.&amp;nbsp; Fixing coreutils to allow administrators to change the default of standard tools to set default labels on object creation is nice.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;alias mv='mv -iZ'&lt;br /&gt;alias cp='cp -iZ'&lt;br /&gt;alias mkdir='mkdir -Z&amp;quot;&lt;br /&gt;alias mknod='mknod -Z&amp;quot;&lt;br /&gt;alias install='install -Z&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I hope to get this new coreutils backported into RHEL7...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Security&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;One thing to remember about this from a security point of view.&amp;nbsp; A calling confined domain would still be prevented from creating content with the default label, if it was not allowed by SELinux policy to create content with that label.&amp;nbsp; The change to coreutils, just allows the process to attempt to create the content with the correct label.&lt;br /&gt;&lt;br /&gt;Thanks to coreutils upstream for working on these patches with us.&lt;br /&gt;&lt;/p&gt;</description>
	<pubDate>Wed, 18 Dec 2013 13:19:06 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: golang support for libselinux in Rawhide.</title>
	<guid>http://danwalsh.livejournal.com/67373.html</guid>
	<link>http://danwalsh.livejournal.com/67373.html</link>
	<description>Every so often I get to spend a couple of days working on a new computer language, but it has been a while.&lt;br /&gt;&lt;br /&gt;I am working on a project to bring SELinux support to &lt;a href=&quot;http://www.docker.com/about_docker/&quot; rel=&quot;nofollow&quot;&gt;docker&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;The basic idea is to launch containers with a specific SELinux type and Random MCS label.&amp;nbsp; Using pretty much the same technology as we use with &lt;a href=&quot;http://danwalsh.livejournal.com/44090.html&quot; rel=&quot;nofollow&quot;&gt;sVirt&lt;/a&gt;.&amp;nbsp; We do this using libvirt and virt-sandbox-service in Fedora now, but we want to implement similar support for docker.&lt;br /&gt;&lt;br /&gt;One problem I had when I first starting working on this project was that docker is written in the &lt;a href=&quot;http://golang.org/&quot; rel=&quot;nofollow&quot;&gt;go programming language.&lt;/a&gt;  I did not know the go language and there were no libselinux bindings for go. &lt;br /&gt;&lt;br /&gt;Luckily go is fairly easy to bind to the C Language using cgo.&amp;nbsp; After a couple of weeks work, I put together selinux.go which implements all of the functions that I needed to get containers running with SELinux labels.&amp;nbsp; Going forward it would be nice to hook up all of the libselinux functions. (Patches welcomed).&lt;br /&gt;&lt;br /&gt;Package will show up in libselinux-2.2.1-3.fc21&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/selinux.go&quot; rel=&quot;nofollow&quot;&gt;/usr/share/gocode/selinux/selinux.go&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Any input for improvements to go code would be welcome.</description>
	<pubDate>Tue, 17 Dec 2013 16:26:33 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dominick Grift: finding file context files that do not end with a newline</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-1465249180516359840</guid>
	<link>http://selinux-mac.blogspot.com/2013/12/finding-file-context-files-that-do-not.html</link>
	<description>file context files not ending with a newline cause annoying situations.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt; #!/bin/bash --  &lt;br /&gt; #  &lt;br /&gt; # This script looks for file context files  &lt;br /&gt; # that do not end with a newline  &lt;br /&gt; #  &lt;br /&gt; REF_PATH=&quot;/home/dominick/Git/refpolicy&quot;  &lt;br /&gt; for i in $(/bin/find $(printf &quot;%s&quot; &quot;$REF_PATH&quot;) -type f -name &quot;*.fc&quot;) ; do  &lt;br /&gt;     [[ &quot;$(/bin/tail -c 1 $i | /bin/tr -dc '\n' | /bin/wc -c)&quot; -ne 1 ]] &amp;amp;&amp;amp; printf &quot;%s\n&quot; &quot;Fix me: $i&quot;  &lt;br /&gt; done  &lt;br /&gt; exit $?  &lt;br /&gt; #EOF  &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</description>
	<pubDate>Sun, 15 Dec 2013 11:04:03 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dominick Grift: quick script to check for unsupported device nodes by SELinux</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-8147383063876069621</guid>
	<link>http://selinux-mac.blogspot.com/2013/12/quick-script-to-check-for-unsupported.html</link>
	<description>&lt;pre&gt;&lt;code&gt; #!/bin/bash --  &lt;br /&gt; #  &lt;br /&gt; # This script checks for device nodes that are unsupported by SELinux  &lt;br /&gt; # Unsupported device nodes fall back to the device_t generic type identifier for content in /dev   &lt;br /&gt; # The script just finds all chars and blocks, then looks if any of them as associated with the device_t type identifier  &lt;br /&gt; # If any device node is associated with device_t sid then the script uses matchpathcon to determine if SELinux is aware of the device node  &lt;br /&gt; # If matchpathcon thinks the device node should be associated with the device_t type then the device node is unsupported by SELinux one way or another  &lt;br /&gt; #  &lt;br /&gt; IFS=$'\n'  &lt;br /&gt; recurse_char() {  &lt;br /&gt;  for i in &quot;$1&quot;/*;do  &lt;br /&gt;   if [ -d &quot;$i&quot; ];then  &lt;br /&gt;     recurse_char &quot;$i&quot;  &lt;br /&gt;   elif [ -c &quot;$i&quot; -a ! -L &quot;$i&quot; ]; then  &lt;br /&gt;     echo &quot;$(ls -alZ &quot;$i&quot;)&quot;  &lt;br /&gt;   fi  &lt;br /&gt;  done  &lt;br /&gt; }  &lt;br /&gt; recurse_block() {  &lt;br /&gt;  for i in &quot;$1&quot;/*;do  &lt;br /&gt;   if [ -d &quot;$i&quot; ];then  &lt;br /&gt;     recurse_block &quot;$i&quot;  &lt;br /&gt;   elif [ -b &quot;$i&quot; -a ! -L &quot;$i&quot; ]; then  &lt;br /&gt;     echo &quot;$(ls -alZ &quot;$i&quot;)&quot;  &lt;br /&gt;   fi  &lt;br /&gt;  done  &lt;br /&gt; }  &lt;br /&gt; for s in $(recurse_char /dev); do  &lt;br /&gt;      if [ &quot;$(echo $s | /usr/bin/awk -F &quot; &quot; '{ print $4 }' | /usr/bin/awk -F &quot;:&quot; '{ print $3 }')&quot; == &quot;device_t&quot; ] ; then  &lt;br /&gt;           IFS=&quot; &quot;  &lt;br /&gt;           read -r bits owner group context char &amp;lt;&amp;lt;&amp;lt; &quot;$s&quot;  &lt;br /&gt;           mpc=$(/usr/sbin/matchpathcon &quot;$char&quot;)  &lt;br /&gt;           if [ &quot;$(echo $mpc | /usr/bin/awk -F &quot; &quot; '{ print $2 }' | /usr/bin/awk -F &quot;:&quot; '{ print $3 }')&quot; == &quot;device_t&quot; ] ; then  &lt;br /&gt;                echo &quot;unsupported char device: $char&quot;  &lt;br /&gt;           fi  &lt;br /&gt;      fi  &lt;br /&gt; done  &lt;br /&gt; for s in $(recurse_block /dev); do  &lt;br /&gt;      if [ &quot;$(echo $s | /usr/bin/awk -F &quot; &quot; '{ print $4 }' | /usr/bin/awk -F &quot;:&quot; '{ print $3 }')&quot; == &quot;device_t&quot; ] ; then  &lt;br /&gt;           IFS=&quot; &quot;  &lt;br /&gt;           read -r bits owner group context block &amp;lt;&amp;lt;&amp;lt; &quot;$s&quot;  &lt;br /&gt;           mpc=$(/usr/sbin/matchpathcon &quot;$block&quot;)  &lt;br /&gt;           if [ &quot;$(echo $mpc | /usr/bin/awk -F &quot; &quot; '{ print $2 }' | /usr/bin/awk -F &quot;:&quot; '{ print $3 }')&quot; == &quot;device_t&quot; ] ; then  &lt;br /&gt;                echo &quot;unsupported block device: $block&quot;  &lt;br /&gt;           fi  &lt;br /&gt;      fi  &lt;br /&gt; done  &lt;br /&gt; exit 0;  &lt;br /&gt; #EOF  &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;</description>
	<pubDate>Wed, 11 Dec 2013 08:18:37 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dominick Grift: Another idea</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-4273949940542934033</guid>
	<link>http://selinux-mac.blogspot.com/2013/12/another-idea.html</link>
	<description>We have the sepolicy tool that has functionality that aims to make policy development easier. One great benefit is the single point of failure aspect it provides. By using the tool for policy development you reduce risk of typo's and syntax errors. If you have to type everything yourself manually then much can go wrong.&lt;br /&gt;&lt;br /&gt;The tool also has it's drawback because you are bound to the functionality the tool provides but nothing stops you from manually editing the generated policy, and so that is pretty much a non-issue.&lt;br /&gt;&lt;br /&gt;For some reason typo's and syntax errors are a pretty common thing for many policy developers, and so from that perspective it is probably a good idea to use the tool more often.&lt;br /&gt;&lt;br /&gt;Anyhow, The reference policy provides a api &quot;mechanism&quot;, and api's make life easier. The issue is that these api's are not checked until they are actually called or until a tool like sepolgen-ifgen is run on them. So if one writes api's manually then those api's might not work due to some stupid typos, but the typos are often not identified until some one calls the api's.&lt;br /&gt;&lt;br /&gt;Back earlier we had this policy of not adding api's unless they are actually used. However the point was made that audit2allow cannot suggest an api to use if its not available and so we agreed that it is probably better to add various api's even if they are not used.&lt;br /&gt;&lt;br /&gt;So adding api's that aren't used, and that might be written manually thus contain typos and syntax errors. That means that api's that have typo's in them might not work and we don't know about it because we do not use them.&lt;br /&gt;&lt;br /&gt;He/She who fits the shoes wears them. I make typos in unused api's often. Just a few days ago i fixed two typos in admin interfaces that i made myself, and it annoys me. Because i am the type of person that likes to manually write his policy rather than depend on a tool (even though i know the tools purpose and i appreciate the issues it solves) I guess i am just stubborn sometimes.&lt;br /&gt;&lt;br /&gt;To keep a long story short: It might be a good idea to create an api test script. Again not an all-inclusive test but just to determine whether it can be called or not. The sepolgen-ifgen tool might be able to help identifying issues as well. &lt;br /&gt;&lt;br /&gt;Basically a script that just calls interfaces, templates, patterns etc to see if they build.&lt;br /&gt;&lt;br /&gt;Api's are our calling cards. It's how callers see us. If we provide broken interfaces then that leaves a bad impression. That is why i think they deserve more attention because they are not there just for us but also for others.&lt;br /&gt;</description>
	<pubDate>Mon, 09 Dec 2013 08:39:18 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dominick Grift: How I think distribution maintainers can enhance quality assurance</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-8649904920273881619</guid>
	<link>http://selinux-mac.blogspot.com/2013/12/how-i-think-distribution-maintainers.html</link>
	<description>Here is a list with things distribution maintainers can do to enhance quality assurance&lt;br /&gt;&lt;br /&gt;1. Do proof reading.&lt;br /&gt;&lt;br /&gt;This enhancement applies to some distributions more than others. Lets define those &quot;active&quot; distribution and &quot;passive&quot; distributions.&lt;br /&gt;&lt;br /&gt;An active distribution is one that is constantly changing. Whereas a passive distribution is mostly &quot;stale&quot;, and changes less frequent.&lt;br /&gt;&lt;br /&gt;A property of active distributions is their activity. Fast development where Security policy must constantly be adapted to support these fast developments.&lt;br /&gt;&lt;br /&gt;Maintaining policy for such scenarios is just hard work often. Things must be &quot;fixed&quot; quick and often. This is a recipe for human error.&lt;br /&gt;&lt;br /&gt;Because often in the rush one tends to make assumptions, plain types and syntax errors, or other relatively simple mistakes.&lt;br /&gt;&lt;br /&gt;Proof reading commits, and a fresh pair of eyes can save time here. By just spending a little day each day reviewing new commits such errors can be identified and fixed quickly.&lt;br /&gt;&lt;br /&gt;Some of this proof reading requires humans for example identifying mistakes due to assumptions. Other proof reading can be automated, for example typos and syntax errors.&lt;br /&gt;&lt;br /&gt;These human mistakes are often relatively harmless but sometimes they are harmful. The point i am trying to make is that this can be easily prevented.&lt;br /&gt;&lt;br /&gt;For the record, i am not suggesting that this proof reading is for identifying complex issues. Because that is a but more complicated and probably takes a little more time&lt;br /&gt;&lt;br /&gt;No instead i am suggesting that this method can filter out obvious errors. I can tell you from experience that this pay's off. Besides how hard is it to spend a little time regularly running a couple scripts on new commits to spot typos, syntax errors, and to spend five minutes a day reviewing yesterdays commits.&lt;br /&gt;&lt;br /&gt;2. Test you policy for all common scenarios.&lt;br /&gt;&lt;br /&gt;Policy can be built with various options. Distributions often do not use all these options. Problems can arise when you do not test building the policy with all options. This might be irrelevant in the short term because i head distribution maintainers think, if it works for us then why bother?&lt;br /&gt;&lt;br /&gt;There are two reasons for that:&lt;br /&gt;&lt;br /&gt;A. Your priorities might not align with the priorities of upstream, and for your own sake it is better to work with upstream. The more you divert the harder it gets to maintain your project. Merging new upstream releases becomes harder and take more time. By just making sure things work for all scenarios you increase chances of your changes being applied upstream. If you policy only works with a subset of options than upstream has little choice than to refuse the patch. To waste your time, upstreams time. its inefficient.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;B. Besides. We know what SELinux is right. What defines SELinux. Its the flexibility and configurability. That's why i use SELinux as opposed to any of the other LSM-Based MAC systems. So as a distro maintainer i would actually advertise these properties. One obvious and easy way to do that is to make sure you project builds and installs in all common scenarios.&lt;br /&gt;&lt;br /&gt;Sure there are limits to what you can support. Lets just use the same limits are upstream since we depend on eachother.&lt;br /&gt;&lt;br /&gt;So, every once in a while. build your policy with different sets op options, to make sure that it builds. Also You might want to every onces in a while install it with various options that way you can identify bugs in the user space component.&lt;br /&gt;&lt;br /&gt;Because this is not only an issue with policy, its also an issue with user space. User space must support all common policy and all its options.&lt;br /&gt;&lt;br /&gt;3. Make sure that what you target at least works in common configurations.&lt;br /&gt;&lt;br /&gt;If you target a daemon then it might be good to write a simple test for some of the common configurations. I am not suggesting all-inclusive tests. Just some default test to make sure the most obvious functionality works. It obviously requires some investments, at least initially but it might just mean the difference between a good or a bad impression.&lt;br /&gt;&lt;br /&gt;4. Test your security goals.&lt;br /&gt;&lt;br /&gt;Good, the processes you target can function and you have a way to verify that. But what about security? thats what we do all this for. Simple changes to the policy can have huge effects. By defining your security goals, and crucial properties of your security identifiers, you make it possible to verify that they meet your requirements over time. Run simple tests. We have great tools for that.&lt;br /&gt;This can be automated perfectly&lt;br /&gt;&lt;br /&gt;5. Other processes and SELinux&lt;br /&gt;&lt;br /&gt;In essence SELinux is transparent to the user space. However  user space components can be made aware of SELinux or can even be expected to manage parts of SELinux. For example setting security contexts on files. These programs are often written by parties that might not understand SELinux principles and concepts as well as some of us do. &lt;br /&gt;&lt;br /&gt;This can affect the SELinux experience as a whole so its in our interest that these processes make the right decisions. One common mistakes is processes hardcoding security identifiers. Generally harmless but it harms experience and it can easily be prevented by loading a bare (dummy) policy and then checking dmesg or whatever to see if some processes are trying to use identifiers that do not exist. There are more conceivable tests imaginable.&lt;br /&gt;&lt;br /&gt;These are just some ways distribution maintained can enhance quality assurance. Many of these point apply to both the security policy component as well as the user space component&lt;br /&gt;</description>
	<pubDate>Thu, 05 Dec 2013 03:28:29 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dominick Grift: Can SELinux be made simpler?</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-2551141012954963717</guid>
	<link>http://selinux-mac.blogspot.com/2013/12/can-selinux-be-made-simpler.html</link>
	<description>&lt;b&gt;Disclaimer: this is just my opinion&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This must be a trick question. There is no easy answer for this.&lt;br /&gt;&lt;br /&gt;First we should define SELinux to be able to put the question into a context&lt;br /&gt;&lt;br /&gt;SELinux has three components: The LSM-Based system in the kernel, the tools and libraries, and lastly security policy&lt;br /&gt;&lt;br /&gt;We also need to determine what defines SELinux in compared to other LSM-Based systems in the kernel&lt;br /&gt;&lt;br /&gt;The answer to the latter question is Flexibility and configurability. Thats what defines SELinux. It a main property of SELinux. There are other LSM-Based system with other properties for example SMAC (simple mandatory access control) That system is defined by simplicity (but needless to say it lacks flexibility/configurability, at least compared to SELinux)&lt;br /&gt;&lt;br /&gt;It is easy to translate flexibility to complexity but the end result does not always have to be relatively complex&lt;br /&gt;&lt;br /&gt;Another thing to consider are constraints, with that i mean that for example SELinux must be optional, additional. It must be an add-on to the existing Linux DAC framework&lt;br /&gt;&lt;br /&gt;This prerequisite brings some more &quot;complexity&quot;, There 3 more of those prerequisites (one of them is not optional for SELinux to work). To enforce mandatory integrity processes must be able to change type (role base access control). &lt;br /&gt;&lt;br /&gt;The other two prerequisites are optional (must be able to compartmentalise, must be able to enforce confidentiality) (multi category security/multi level security)&lt;br /&gt;&lt;br /&gt;Back to the question. We now have most considerations briefly explained.&lt;br /&gt;&lt;br /&gt;I Believe The core of SELinux (the LSM-Based System) cannot be made simpler. It is already as simple as can be considering all the requirrments.&lt;br /&gt;Can the tools and libraries make the experience simpler? Maybe a bit, but the main concepts and principles will still apply there is little one can do about that.&lt;br /&gt;&lt;br /&gt;The last component is what most people experience: the security policy&lt;br /&gt;&lt;br /&gt;So Lets look at the state of that. The policy can be build with the minimal set of requirements (e.g. only enforce integrity optionally/additionally e.g. by complementing traditional DAC)&lt;br /&gt;&lt;br /&gt;So we already can exclude some complexity and we do. We have different policy models for different requirements. For example if you have confidentiality requirements, which adds complexity, then you need the mls policy model.&lt;br /&gt;&lt;br /&gt;Lets look at a operating system: Fedora currently is a single distro that can basically considered general purpose. You can use it as a workstation, server, or your use case can be even more specific.&lt;br /&gt;But a vendor does not know beforehand how you are going to use it, and so every scenario must be supported.&lt;br /&gt;&lt;br /&gt;Here is the dilemma: security is never general. If you want to implement mandatory integrity/confidentiality in a flexible/configurable way by complementing traditional DAC on a general purpose system then you have a complex challenge on your hand which requires complex policy.&lt;br /&gt;&lt;br /&gt;So compromises were made: Lets not enforce mandatory integrity on the whole system, but only a part of it. Its give and take. Fine now things are a bit simpler but its not cheap. Now user sessions by default are not contained. To me this is already a great compromise because it basically says, were leaving workstation scenarios out in the cold with regard to mandatory integrity in the user space&lt;br /&gt;&lt;br /&gt;fortunately some level of mandatory integrity in the user space is still optionally available, but its a compromise and it does not get the attention that i think it deserves&lt;br /&gt;&lt;br /&gt;So its all about compromises. We have some ability to make things &quot;simpler&quot; and we already apply it.&lt;br /&gt;&lt;br /&gt;So how to make things (a bit) simpler and actually achieve security goals?&lt;br /&gt;&lt;br /&gt;We could create &quot;profiles&quot;. For example Fedora webs erver edition. is a profile for a web server. web servers have (relatively) specific properties. So that from a security perspective enables us to implement a relatively specific security policy for that profile. We just target the web server. This makes the policy &quot;simpler&quot;&lt;br /&gt;&lt;br /&gt;Fedora Desktop edition has a policy that targets the user space.&lt;br /&gt;&lt;br /&gt;Does this solve anything? Not really if you still end up focussing on specific cases. it might help a bit but its still a compromise. Unless of course you really commit to all the profules you defined.&lt;br /&gt;&lt;br /&gt;There are more (less obvious) options but its all give and take, and its all with regard to the security policy implemented. The core of SELinux cannot be simplified ( with any significance) without SELinux losing its identity.&lt;br /&gt;&lt;br /&gt;So what about setroubleshoot? That is a great success story when it comes to simplifying SELinux?! Not really. Its just a buffed audit2why with a lot of bloat. (no offence) Is still a program that cannot make security decisions for you. All it can do is parse. reference and make it easy to report issues. It does not know when to transition or not.&lt;br /&gt;&lt;br /&gt;That is not because its a bad piece of software. its just that security policy is not something that is fixed so you cant hard-code solutions. and to put things into context and determine the security requirements and act on it requires a huge base of logic. Is it even worth trying to create that?&lt;br /&gt;&lt;br /&gt;Think about it from a security perspective: do you easily trust a third party with security decisions that affect your lively hood? Do you trust some code to make security decisions for you?&lt;br /&gt;&lt;br /&gt;And even if you do, youll miss out on the good still: configurability/flexibility.&lt;br /&gt;&lt;br /&gt;Why not instead focus on learning the core principles/concepts, and enable people to implement mandatory integrity that is tailored to their specific requirement?&lt;br /&gt;&lt;br /&gt;So how do you do that? CIL is a abstraction language/ compiler that aims to make this easier. Its is relatively simple and it can be used as a layer between a policy management program and the SElinux policy language. It makes things less pain full but still wont change the core principles and concepts.&lt;br /&gt;&lt;br /&gt;What it does do is optimise. Optimization can, i guess, in some ways be translated to making things more pleasurable and there by perceivably simpler.&lt;br /&gt;&lt;br /&gt;You ask me the question can SELinux be made simpler. my answer is no. but things can be improved and optimized. compromises can also be made&lt;br /&gt;&lt;br /&gt;But it does not change anything to the core principles and concepts.&lt;br /&gt;&lt;br /&gt;If you want (relatively) simple: look into Simple mandatory access control. You want &quot;flexibility/configurability&quot; embrace selinux&lt;br /&gt;&lt;br /&gt;For example on the one hand we make things &quot;simpler&quot; by by default not targeting user sessions, But on the other hand we enable an optional security model that adds a layer of complexity to achieve compartmentalization.&lt;br /&gt;&lt;br /&gt;Its all a matter of priorities&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Thu, 05 Dec 2013 02:46:43 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: さらばドイツ</title>
	<guid>hatenablog://entry/12921228815713594479</guid>
	<link>http://kaigai.hatenablog.com/entry/2013/12/01/165444</link>
	<description>&lt;p&gt;2011年2月にドイツへ赴任し、以降2年10ヵ月間、SAP社とのアライアンス業務に携わっていたわけですが、11月末で任地での業務を終了し日本へと戻る事になりました。&lt;/p&gt;&lt;p&gt;振り返れば、初めてフランクフルトの空港に到着した後、一歩外へ出たら氷点下の世界（注：ドイツの2月です）で『こりゃトンデモない場所に来たもんだ』と思ったものですが、まぁ、住めば都で何とかなるもんですな。&lt;/p&gt;&lt;p&gt;オフィスはドイツ南西のWalldorf市（SAP本社がある）。住むには少し規模が小さな街なので、隣のHeidelberg市の旧市街のマンションを借り、1月遅れで嫁さんも日本からやってきました。&lt;br /&gt;
&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120331/20120331145434.jpg&quot; alt=&quot;f:id:kaigai:20120331145434j:plain&quot; title=&quot;f:id:kaigai:20120331145434j:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;お仕事的には、2011年前後というのはちょうどSAP社が&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SUSE&quot;&gt;SUSE&lt;/a&gt; &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Linux&quot;&gt;Linux&lt;/a&gt;ベースのインメモリDB製品 &quot;SAP HANA&quot; をぶち上げ始めた頃で、主に技術面でSAPや&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SUSE&quot;&gt;SUSE&lt;/a&gt;との折衝や、HANA認定取得の実作業というのが駐在中のメインのお仕事でした。&lt;/p&gt;&lt;p&gt;■ &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NEC&quot;&gt;NEC&lt;/a&gt;　SAP HANA向け&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%A2%A5%D7%A5%E9%A5%A4%A5%A2%A5%F3%A5%B9&quot;&gt;アプライアンス&lt;/a&gt;サーバを販売開始&lt;br /&gt;
&lt;a href=&quot;http://www.nec.co.jp/press/ja/1203/0901.html&quot;&gt;http://www.nec.co.jp/press/ja/1203/0901.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;その他にも、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NEC&quot;&gt;NEC&lt;/a&gt;のHA製品CLUSTERPROで、SAP NW～HA製品間で連携するためのインターフェース認証を取得したりとか。&lt;/p&gt;&lt;p&gt;■ &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NEC&quot;&gt;NEC&lt;/a&gt;、「SAP HA Interface Certification」認定を取得した「CLUSTERPRO X 3.1 for SAP NetWeaver」を発売&lt;br /&gt;
&lt;a href=&quot;http://jpn.nec.com/press/201210/20121002_01.html&quot;&gt;http://jpn.nec.com/press/201210/20121002_01.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;この手の &quot;○○認証&quot; という仕事が多かったのですが、SAPの認定プログラムはちょくちょくおかしくて、例えば SAP &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Linux&quot;&gt;Linux&lt;/a&gt; 認証プログラムは80コア/160HTの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NEC&quot;&gt;NEC&lt;/a&gt;サーバの認定を通すために、SAPの認定プログラムの方を手直しして認定を通したりとか。&lt;/p&gt;&lt;p&gt;一方、OSS活動は工数の20%～30%を充当して良いという事を条件に赴任したので、まだ中途であるSE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;の開発も継続する事ができた。これは会社に感謝。ただ、OSS活動に専従という訳ではないので、MLでの反応が遅れたりと、コミュニティに対して少し申し訳ない。&lt;br /&gt;
ドイツに居る間に新たに開発してみたのが PG-Strom というモジュールで、クリスマス休暇の間にCUDAを使ってプロトタイプの実装を行ってみた。これがもう一つ、自分にとって軸となるソフトウェアになるかもしれない。&lt;br /&gt;
&lt;a href=&quot;http://kaigai.hatenablog.com/entry/20120106/1325852100&quot;&gt;http://kaigai.hatenablog.com/entry/20120106/1325852100&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20131201/20131201153401.jpg&quot; alt=&quot;f:id:kaigai:20131201153401j:plain&quot; title=&quot;f:id:kaigai:20131201153401j:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
これをプラハでのPGconf.EUで発表した際に、非常に大きな反響があった事は&quot;コレは行けるんじゃないか？&quot;という確信に繋がった。これは&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NEC&quot;&gt;NEC&lt;/a&gt;に限った事なのか分からないけども、自分の組織の外に対して何かを発表し、フィードバックを得るという機会が極端に少ない、あるいはナイーブになっているような気がする。&lt;br /&gt;
そうすると、自分の提案したい事が第三者の視点から見て価値ある事なのか、そうでないのか確信できないので、上司にちょっとダメ出しされただけで萎縮してしまうという事に繋がらないか。&lt;br /&gt;
先日、晴れて四捨五入したらオッサン年代に突入したので偉そうな事を書くと、若い人は公式非公式を問わず、自分のアイデアを社外で発表する機会を持った方がよい。そうすると、上司のダメ出しが的を得ているのか、的外れなのか、自分の判断基準を持てるようになるから。&lt;/p&gt;&lt;p&gt;この辺SAPが偉いなと思うのが、SCN(SAP Community Network)という仕組みを用意し、Wikiやブログを通して開発者やパートナー企業とエンドユーザが直接意見交換できる仕組みが機能している事。例えば製品の変な使い方やプロトタイプ的に作ってみた機能（当然公式にはサポート外）をオープンにして、それに対するフィードバックを受けられるようにしている。&lt;br /&gt;
もちろん、これはSAPのように非常に強力なパートナー網、顧客網というエコシステムを持っているからこそできる事。同じ事ができる企業は非常に限られている。&lt;br /&gt;
ただ、エコシステムの主催者でなくともコントリビュータとして社外の意見フィードバックを活用するというのは可能。まさにOSSコミュニティが日常的に行っている事で、だからこそイノベーションがそこにある。&lt;/p&gt;&lt;p&gt;仕事環境で言うとドイツ人が偉いのは、きっかり時間通りに仕事を切り上げる事。&lt;br /&gt;
2011～2013シーズンはBaden-Hillsカーリングクラブでプレーしていたのだけども、毎週火曜日19:30～のリーグ戦に皆きっちり集まるのがすごい。日本のカルチャーでは難しい所もあるけど、ぜひ見習いたい。目前の業務にばかり時間を費やして、別の領域にアンテナを張る時間や余暇の時間がなければ新しい発想なんて生まれないし、それが中長期的には組織を徐々に蝕んでいく事になるんじゃないかと思った。&lt;br /&gt;
&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20111011/20111011183217.jpg&quot; alt=&quot;f:id:kaigai:20111011183217j:plain&quot; title=&quot;f:id:kaigai:20111011183217j:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;その他、生活面では嫁さんが考えて日本食を作ってくれたので、病気をする事もなくきっちり職務を遂行する事ができた。感謝。結婚してからの３年間、風邪をひく事すら無くなった。&lt;br /&gt;
ヨーロッパに住んでいる事で、なかなか日本からは行きにくい場所を旅行できた事は役得だけど、書き出すとキリがないのでないのでこれはまた別の機会に。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120331/20120331154344.jpg&quot; alt=&quot;f:id:kaigai:20120331154344j:plain&quot; title=&quot;f:id:kaigai:20120331154344j:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;日本に帰った後は、SAPから離れて再びOSSの仕事に戻ります。&lt;br /&gt;
自分で手を動かしてコードを書くと同時に、それをお金に換えていく方法をデザインする事が求められているので、タフな仕事だけども、一つの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%ED%A1%BC%A5%EB%A5%E2%A5%C7%A5%EB&quot;&gt;ロールモデル&lt;/a&gt;として後進に示せれば良いかなと。&lt;/p&gt;&lt;p&gt;それでは明日、ドイツを発ちます。&lt;/p&gt;</description>
	<pubDate>Sun, 01 Dec 2013 07:54:44 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>Dan Walsh: SELinux Halloween Release</title>
	<guid>http://danwalsh.livejournal.com/67308.html</guid>
	<link>http://danwalsh.livejournal.com/67308.html</link>
	<description>Red Hat had the famous &lt;a href=&quot;https://fedoraproject.org/wiki/History_of_Red_Hat_Linux&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Halloween Release&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Coincidentally a &lt;a href=&quot;http://userspace.selinuxproject.org/trac/wiki/Releases&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;major release of SELinux tool chain&lt;/a&gt; went out yesterday.&amp;nbsp; It should be showing up in the Rawhide mirrors now.&amp;nbsp; Most of these code was already in Fedora, and RHEL7,&amp;nbsp; but we were able to upstream some very large patches, and I just thought I would point out the changes that went into this release.&amp;nbsp; The last release of the tool chain April 4, 2013.&amp;nbsp; We still have some small patches in Fedora but most of our code is now upstream.&amp;nbsp;&amp;nbsp;&amp;nbsp; The change logs below give you some idea of what changes have been made.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;libsepol&lt;/b&gt;&lt;br /&gt;2.2 2013-10-30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Allow constraint denial cause to be determined from Richard Haines.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Add kernel policy version 29.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Add modular policy version 17.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Add sepol_compute_av_reason_buffer(), sepol_string_to_security_class(), sepol_string_to_av_perm().&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support overriding Makefile RANLIB from Sven Vermeulen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix man pages from Laurent Bigonville.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Checkpolicy&lt;/b&gt;&lt;br /&gt;2.2 2013-10-30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix hyphen usage in man pages from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * handle-unknown / -U required argument fix from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support overriding Makefile PATH and LIBDIR from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support space and : in filenames from Red Hat.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sepolgen&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Return additional constraint information.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix bug in calls to attributes from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add support for filename transitions from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix sepolgen tests from Red Hat.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;libselinux&lt;/b&gt;&lt;br /&gt;2.2 2013-10-30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix avc_has_perm() returns -1 even when SELinux is in permissive mode.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support overriding Makefile RANLIB from Sven Vermeulen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Update pkgconfig definition from Sven Vermeulen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Mount sysfs before trying to mount selinuxfs from Sven Vermeulen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix man pages from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support overriding PATH&amp;nbsp; and LIBBASE in Makefiles from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix LDFLAGS usage from Laurent Bigonville&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Avoid shadowing stat in load_mmap from Joe MacDonald.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support building on older PCRE libraries from Joe MacDonald.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix handling of temporary file in sefcontext_compile from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix procattr cache from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Define python constants for getenforce result from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix label substitution handling of / from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add selinux_current_policy_path from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Change get_context_list to only return good matches from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support udev-197 and higher from Sven Vermeulen and Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add support for local substitutions from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Change setfilecon to not return ENOSUP if context is already correct from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Python wrapper leak fixes from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Export SELINUX_TRANS_DIR definition in selinux.h from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add selinux_systemd_contexts_path from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add selinux_set_policy_root from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add man page for sefcontext_compile from Red Hat.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;libsemanage&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;2.2 2013-10-30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Avoid duplicate list entries from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add audit support to libsemanage from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Remove policy.kern and replace with symlink from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Apply a MAX_UID check for genhomedircon from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix man pages from Laurent Bigonville.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;policycoreutils&lt;/b&gt;&lt;br /&gt;2.2 2013-10-30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Properly build the swig exception file from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix man pages from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support overriding PATH and INITDIR in Makefile from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix LDFLAGS usage from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix init_policy warning from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix semanage logging from Laurent Bigonville.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Open newrole stdin as read/write from Sven Vermeulen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix sepolicy transition from Sven Vermeulen.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support overriding CFLAGS from Simon Ruderich.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create correct man directory for run_init from Russell Coker.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * restorecon GLOB_BRACE change from Michal Trunecka.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Extend audit2why to report additional constraint information.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Catch IOError errors within audit2allow from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * semanage export/import fixes from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Improve setfiles progress reporting from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Document setfiles -o option in usage from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Change setfiles to always return -1 on failure from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Improve setsebool error r eporting from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Major overhaul of gui from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix sepolicy handling of non-MLS policy from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support returning type aliases from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add sepolicy tests from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add org.selinux.config.policy from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Improve range and user input checking by semanage from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Prevent source or target arguments that end with / for substitutions from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Allow use of &amp;lt;&amp;lt;none&amp;gt;&amp;gt; for semanage fcontext from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Report customized user levels from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Support deleteall for restoring disabled modules from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Improve semanage error reporting from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Only list disabled modules for module locallist from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix logging from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Define new constants for file type character codes from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Improve bash completions from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Convert semanage to argparse from Red Hat (originally by Dave Quigley).&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add semanage tests from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Split semanage man pages from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Move bash completion scripts from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Replace genhomedircon script with a link to semodule from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Fix fixfiles from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add support for systemd service for restorecon from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Spelling corrections from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Improve sandbox support for home dir symlinks and file caps from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Switch sandbox to openbox window manager from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Coalesce audit2why and audit2allow from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Change audit2allow to append to output file from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Update translations from Red Hat.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Change audit2why to use selinux_current_policy_path from Red Hat.</description>
	<pubDate>Fri, 01 Nov 2013 12:39:42 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Mistaking a Process label type for a File label type.</title>
	<guid>http://danwalsh.livejournal.com/67007.html</guid>
	<link>http://danwalsh.livejournal.com/67007.html</link>
	<description>Yesterday there was an email from an administrator complaining about semanage.&lt;br /&gt;&lt;br /&gt;The administrator was attempting to setup a new directory with a label for cgi scripts.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage fcontext -a -t httpd_sys_script_t &amp;quot;///cgi-bin/.*\.cgi&amp;quot;&lt;br /&gt;ValueError: Type httpd_sys_script_t is invalid, must be a file or device type.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The tool told the administrator that he had made a mistake and attempted to assign a type to a file that was neither a file or device type.&lt;br /&gt;&lt;br /&gt;This is a fairly common mistake with SELinux.&amp;nbsp; httpd_sys_script_t is a process label, and SELinux prevents process labels from being placed on files systems.&amp;nbsp; His valid complaint was it is not easy to know whether a particular type was a process type or a file type.&lt;br /&gt;&lt;br /&gt;He then suggested that we should have coded something in the name of the type to indicate the&lt;b&gt; type of the type&lt;/b&gt;. For example httpd_sys_script_p_t and httpd_sys_script_exec_f_t.&amp;nbsp; This might not be a bad idea, and should be brought up for discussion on the SELinux Policy list.&lt;br /&gt;&lt;br /&gt;I looked at semanage code and saw that the tool was checking a list of valid file types against the type field on the command.&amp;nbsp;&amp;nbsp; I saw a fairly easy enhancement would be to strip the &amp;quot;_t&amp;quot; off the type and search the list of &amp;quot;file types&amp;quot; that matched the prefix.&lt;br /&gt;&lt;br /&gt;This change would at least help the administrator a little.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage fcontext -a -t httpd_sys_script_t &amp;quot;///cgi-bin/.*\.cgi&amp;quot;&lt;br /&gt;ValueError: Type httpd_sys_script_t is invalid, must be a file or device type.&lt;br /&gt;Alternative: httpd_sys_script_exec_t.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Another example.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage fcontext -a -t apcupsd_t /etc/dan&lt;br /&gt;ValueError: Type apcupsd_t is invalid, must be a file or device type.&lt;br /&gt;Alternatives: apcupsd_var_run_t, apcupsd_initrc_exec_t, apcupsd_log_t, apcupsd_exec_t, apcupsd_lock_t, apcupsd_unit_file_t, apcupsd_tmp_t.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One problem with this change would be Apache (httpd_t), which comes out with 146 matches.&amp;nbsp; :^(&lt;br /&gt;&lt;br /&gt;The new semanage will show up in Rawhide and will be back ported to RHEL7 and Fedora 20.&lt;br /&gt;&lt;br /&gt;The seinfo command from the setools-cmdline package can list all file types on a system using the file_type attribute and all process types using the domain attribute.&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&amp;gt; seinfo -afile_type -x | wc -l&amp;nbsp;&amp;nbsp; &lt;br /&gt;2603&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;&amp;gt; seinfo -adomain -x | wc -l &lt;br /&gt;743&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/27571.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;b&gt;File System Equivalance &lt;/b&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The administrator could have made a better labeling decision by using file equivalence labeling.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage fcontext -a -e /var/www &amp;quot;/&amp;lt;pathtowebsite&amp;gt;/&amp;lt;website&amp;gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which would have told SELinux to label everything under &amp;quot;&lt;span&gt;/&amp;lt;pathtowebsite&amp;gt;/&amp;lt;website&amp;gt;&lt;/span&gt;&amp;quot; as if it was under /var/www</description>
	<pubDate>Sat, 19 Oct 2013 10:10:26 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Difference between a Confined User (staff_u) and a Confined Administrator.</title>
	<guid>http://danwalsh.livejournal.com/66587.html</guid>
	<link>http://danwalsh.livejournal.com/66587.html</link>
	<description>Confined users have been around for a while, and several people have used them.&amp;nbsp; I use the staff_u user for my logins.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;staff_u:staff_r:staff_t:s0-s0:c0.c1023&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One common mistake people make when they use confined users is they expect them to work when running as root.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Which of course the don't!!!&amp;nbsp; They are &lt;b&gt;CONFINED&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The idea of a confined user is to control the access is available to a logged in user.&amp;nbsp; If the user needs to do administrative tasks as root, he needs to become a &lt;b&gt;Confined Administrator.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This means if you are logged in as a confined user SELinux will prevent you from running most programs that will make you root including &amp;quot;su&amp;quot;.&lt;br /&gt;&lt;br /&gt;In SELinux we have the concept of a process transition.&amp;nbsp; When we use confined users we like to transition the Confined User process to a Confined Administrator when the process needs to run as root.&amp;nbsp;&amp;nbsp;&amp;nbsp; Another way to look at this is &lt;i&gt;Roles Based Access Control (RBAC)&lt;/i&gt;.&amp;nbsp; Which means that when I log into a machine I have one Role, but if I want to administrate the machine I need to switch to a different Role.&lt;br /&gt;&lt;br /&gt;In SELinux we currently have two different ways to change Roles, or to switch from a Confined User to a Confined Administrator.&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;newrole - This command can be executed by a user and will request to the SELinux Kernel to change its role, if allowed by policy.&amp;nbsp; The problem with this tool is you still need to change to root, via su or sudo.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;sudo - We allow you to change both your SELinux Role/Type in sudo as well as become root.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;In my case I run my login as staff_u:staff_r:staff_t:s0-s0:c0.c1023, and when I execute a command through sudo, sudo transitions my process to staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023.&amp;nbsp; If you want to run with a slightly confined administrator you could setup a transition to staff_u:sysadm_r:sysadm_t:s0-s0:c0.c1023, which I like to call the drunken unconfined_t, it can do everything unconfined_t can do, but stumbles around alot.&lt;br /&gt;&lt;br /&gt;We also have a few other confined administrators like:&lt;ol&gt;&lt;br /&gt;&lt;li&gt;webadm_t, which can only administrate apache types.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;dbadm_t which can administrate types associated with mysql and postgresql.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;logadm_t which can administrate types associated with syslog and auditlog&lt;/li&gt;&lt;br /&gt;&lt;li&gt;secadm_t which can only administrate SELinux controls&lt;/li&gt;&lt;br /&gt;&lt;li&gt;auditadm_t which can only administrate the audit subsystem.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;It is fairly easy to add additional confined administrator types using sepolicy/sepolgen.&lt;br /&gt;&lt;br /&gt;To configure an Confined User/Confined Administrator pair, you need to do a few steps.&lt;br /&gt;&lt;br /&gt;Note: You could skip the first two steps and just use staff_u&lt;br /&gt;&lt;br /&gt;Step 1:&amp;nbsp; Create a Brand New SELinux User Definition &lt;i&gt;confined_u&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage user -a -r s0-s0:c0.c1023 -R &amp;quot;staff_r unconfined_r webadm_r sysadm_r system_r&amp;quot; confined_u&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: I added roles staff_r which will be the role of the confined user when he logs in.&amp;nbsp; The other roles are potential roles that the user will use when he is an administrator.&amp;nbsp; Only one of these roles is required &amp;quot;unconfined_r webadm_r sysadm_r &amp;quot; but I added them all to give you options.&amp;nbsp; system_r is in there to allow you to restart system services.&amp;nbsp; You would not need this on a systemd system, or if you were going to user run_init.&amp;nbsp; But if you want to just use &amp;quot;service restart foobar&amp;quot; on a system V system like RHEL6 you need to have this role.&lt;br /&gt;&lt;br /&gt;Step 2:&amp;nbsp; We need to setup the default context file to tell programs like sshd or xdm which one of the roles/types we would like to use by default.&amp;nbsp; We are simply going to copy the staff_u context file.&amp;nbsp; You could also use IPA to override this selection.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# cp /etc/selinux/targeted/contexts/users/staff_u /etc/selinux/targeted/contexts/users/confined_u&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 3: Now we want to configure our Linux Account to use the SELinux User&lt;br /&gt;&lt;span&gt;# semanage login -a -s confined_u -rs0:c0.c1023 dwalsh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: In stead of using a user name you could use a linux group like wheel, by specifying %wheel.&amp;nbsp; Also if you want to modify the default for all users that are not specified you could use the name __default__.&lt;br /&gt;&lt;br /&gt;Step 4:&amp;nbsp; Now you need to configure sudo to transition your Confined User process to a Confined Administrator&lt;br /&gt;You can either modify the /etc/sudoers file with a line like the following.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;echo &amp;quot;%wheel&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL=(ALL)&amp;nbsp; TYPE=unconfined_t ROLE=unconfined_r&amp;nbsp;&amp;nbsp;&amp;nbsp; ALL&amp;quot; &amp;gt;&amp;gt; /etc/sudoers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Or add a file to /etc/sudoers.d&lt;br /&gt;&lt;br /&gt;echo &lt;span&gt;&amp;quot;dwalsh &amp;nbsp; ALL=(ALL)&amp;nbsp; TYPE=webadm_t ROLE=webadm_r&amp;nbsp;&amp;nbsp; /bin/sh &amp;quot; &amp;gt; /etc/sudoers.d/dwalsh &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It would not hurt to relabel your homedir at this point.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# restorecon -R -v /home/dwalsh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now if you were already logged in as you user account, you were probably running processes as unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023, so you might want to reboot to make sure everything is cleaned up.&lt;br /&gt;&lt;br /&gt;After reboot, when you login you should see your processes running as&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; id -Z&lt;br /&gt;confined_u:staff_r:staff_t:s0-s0:c0.c1023&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now you should not be allowed to run the su command (unless you newrole to an admin role), but if you execute&lt;br /&gt;&lt;br /&gt;&amp;gt; sudo -i&lt;br /&gt;&lt;span&gt;# id -Z&lt;br /&gt;confined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;/span&gt;</description>
	<pubDate>Fri, 18 Oct 2013 14:05:32 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Setroubleshoot does a nice job nowadays but do people read it?</title>
	<guid>http://danwalsh.livejournal.com/66379.html</guid>
	<link>http://danwalsh.livejournal.com/66379.html</link>
	<description>&lt;pre&gt;
&amp;lt;whine&amp;gt;
&lt;b&gt;Frustrating&lt;/b&gt;:
Getting a bugzillas with an setroubleshoot alert mesage that tells the user user exactly 
what the problem and solution is, and yet the user goes through the GUI looking for the 
Report the Bug button.  

I call this the &lt;u&gt;Bug Dan Walsh Button&lt;/u&gt;, although I guess I could call it the &lt;u&gt;Bug Miroslav Grepl 
Button&lt;/u&gt; now. 

Then the user waits for a response from a human saying to say 

&amp;quot;Did you read the alert?  It told you what to do.&amp;quot; Bugzilla Closed NotABug

All the time the user sits with a broken tool or in permissive mode, when the user could 
have fixed the problem in seconds.  Lots of bugzillas say, XYZ is mislabeled just run restorecon XYZ  :^(

&amp;lt;/whine&amp;gt;

&lt;b&gt;Setroubleshoot did a great job of diagnosing this problem.  &lt;/b&gt;

It gave the user two good solutions, and one fall back.

&lt;span&gt;&lt;b&gt;Bottom Line, Please read the alert information before reporting a bugzilla.&lt;/b&gt;&lt;/span&gt;

Of course the tooling in NetworkManager should have done this automatically, but we have a 
bugzilla open for that.

&lt;span&gt;Description of problem:
Upon trying to activate the VPN interface, I received the pop-up advising me that it was blocked. 
SELinux is preventing /usr/sbin/openvpn from 'open' accesses on the file /home/dwalsh/personalVPN/CN00318823.crt.

*****  Plugin openvpn (47.5 confidence) suggests  ****************************

If you want to mv CN00318823.crt to standard location so that openvpn can have open access
Then you must move the cert file to the ~/.cert directory
Do
# mv /home/dwalsh/personalVPN/CN00318823.crt ~/.cert
# restorecon -R -v ~/.cert


*****  Plugin openvpn (47.5 confidence) suggests  ****************************

If you want to modify the label on CN00318823.crt so that openvpn can have open access on it
Then you must fix the labels.
Do
# semanage fcontext -a -t home_cert_t /home/dwalsh/personalVPN/CN00318823.crt
# restorecon -R -v /home/dwalsh/personalVPN/CN00318823.crt


*****  Plugin catchall (6.38 confidence) suggests  ***************************

If you believe that openvpn should be allowed open access on the CN00318823.crt file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep openvpn /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:openvpn_t:s0
Target Context                unconfined_u:object_r:user_home_t:s0
Target Objects                /home/dwalsh/personalVPN/CN00318823.crt [ file ]
Source                        openvpn
Source Path                   /usr/sbin/openvpn
Port                          &amp;lt;Unknown&amp;gt;
Host                          (removed)
Source RPM Packages           openvpn-2.3.2-1.fc19.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.12.1-73.fc19.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 3.10.10-200.fc19.x86_64 #1 SMP Thu
                              Aug 29 19:05:45 UTC 2013 x86_64 x86_64
Alert Count                   2
First Seen                    2013-09-03 16:46:59 EDT
Last Seen                     2013-09-05 17:57:28 EDT
Local ID                      f008846c-ad32-4676-925c-4a86a1b87a2b

Raw Audit Messages
type=AVC msg=audit(1378418248.924:702): avc:  denied  { open } for  pid=1996 comm=&amp;quot;openvpn&amp;quot; path=&amp;quot;/home/dwalsh/personalVPN/CN00318823.crt&amp;quot; dev=&amp;quot;dm-2&amp;quot; ino=11141302 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file


type=SYSCALL msg=audit(1378418248.924:702): arch=x86_64 syscall=open success=no exit=EACCES a0=7fffcf992f0e a1=0 a2=1b6 a3=7fffcf990410 items=0 ppid=1992 pid=1996 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm=openvpn exe=/usr/sbin/openvpn subj=system_u:system_r:openvpn_t:s0 key=(null)

Hash: openvpn,openvpn_t,user_home_t,file,open
&lt;/span&gt;

&lt;/pre&gt;</description>
	<pubDate>Sat, 07 Sep 2013 10:58:05 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: Custom Executor 試作版</title>
	<guid>hatenablog://entry/11696248318757277788</guid>
	<link>http://kaigai.hatenablog.com/entry/2013/09/01/000750</link>
	<description>&lt;p&gt;現状、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;のエグゼキュータを拡張するにはいくつか方法が考えられる。&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Executor(Start|Run|End)_hookを使う
&lt;ul&gt;
&lt;li&gt;エグゼキュータ全体を乗っ取る。逆に言えば、一部の処理（例えば集約演算）だけを俺様実装にしたい時には、本体側のコードをコピーするなりしないとダメ。&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Foreign Data Wrapperを使う
&lt;ul&gt;
&lt;li&gt;特定のテーブルスキャンに限定すればアリ。しかし、集約演算やJOIN、ソートといった処理を俺様実装にする用途には使用できない。&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;ブランチして俺様パッチを当てる
&lt;ul&gt;
&lt;li&gt;まぁ、これならどうにでもできますがね…。&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;しかし、あまり使い勝手がよろしくない。&lt;br /&gt;
例えば、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;を使って集約演算を1000倍早くしたいと考えても、それを実装するために、モジュール側でエグゼキュータ全体のお守りをしなければならないというのは、全く嬉しくない。&lt;br /&gt;
という訳で、プラン木の一部を差し替えて、特定のエグゼキュータ・ノードだけをモジュール側で実装したコードで実行できるよう機能拡張にトライしてみた。名称は Custom Executor Node で、名付け主はRobert &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Haas&quot;&gt;Haas&lt;/a&gt;なり。&lt;/p&gt;&lt;p&gt;イメージとしては以下の通り。&lt;br /&gt;
&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20130831/20130831231525.png&quot; alt=&quot;f:id:kaigai:20130831231525p:plain&quot; title=&quot;f:id:kaigai:20130831231525p:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;planner_hookを利用して、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;のプラナーがPlannedStmtを作成した&quot;後&quot;でモジュールがプラン木の一部を書き換え、CustomExecノードを追加する、あるいはCustomExecノードで既存のエグゼキュータ・ノードを差し替える。&lt;/p&gt;&lt;p&gt;で、クエリ実行の開始、一行取り出し、クエリ実行の終了時にそれぞれモジュール側で実装されたコードが呼び出されるというワケだ。&lt;/p&gt;&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/API&quot;&gt;API&lt;/a&gt;は以下の通り。機能的に似ているのでFDWの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/API&quot;&gt;API&lt;/a&gt;に似ておる。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;void BeginCustomExec(CustomExecState *cestate, int eflags);
TupleTableSlot *GetNextCustomExec(CustomExecState *node);
void ReScanCustomExec(CustomExecState *node);
void EndCustomExec(CustomExecState *node);
void ExplainCustomExec(CustomExecState *node, ExplainState *es);&lt;/pre&gt;&lt;p&gt;PoCとして、クエリ実行に要した時間を出力する xtime という拡張を自作してみた。&lt;br /&gt;
Custom Executorとして本体からコールバックを受けるには、予め自分自身を登録しておく必要がある。これがRegisterCustomExec()関数で、ここでは一連のコールバックの組に対して&quot;xtime&quot;という名前を付けている。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;void
_PG_init(void)
{
    CustomExecRoutine   routine;
        :
    /*
     * Registration of custom executor provider
     */
    strcpy(routine.CustomExecName, &quot;xtime&quot;);
    routine.BeginCustomExec   = xtime_begin;
    routine.GetNextCustomExec = xtime_getnext;
    routine.ReScanCustomExec  = xtime_rescan;
    routine.EndCustomExec     = xtime_end;
    routine.ExplainCustomExec = xtime_explain;
    RegisterCustomExec(&amp;amp;routine);
        :
}&lt;/pre&gt;&lt;p&gt;そして、プラン木に&quot;xtime&quot;のCustomExecノードを挿入するのがplanner_hookでの処理。標準のプラナーが生成したPlannedStmtに手を加えてCustomExecノードを追加する。（ここでは再帰的にプラン木を捜査して、各ノードの頭にCustomExecノードを追加している）&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;static PlannedStmt *
xtime_planner(Query *parse,
              int cursorOptions,
              ParamListInfo boundParams)
{
    PlannedStmt *result;

    if (original_planner_hook)
        result = original_planner_hook(parse, cursorOptions,
                                       boundParams);
    else
        result = standard_planner(parse, cursorOptions,
                                  boundParams);

    /* walk on underlying plan tree to inject custom-exec node */
    result-&amp;gt;planTree = xtime_subplan_walker(result-&amp;gt;planTree, 0);

    return result;
}&lt;/pre&gt;&lt;p&gt;これによって、クエリ実行計画はどのように修正されるのか。&lt;br /&gt;
例えば以下のようなクエリを実行するとする。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;postgres=# EXPLAIN (costs off)
           SELECT * FROM t1 JOIN t2 ON t1.a = t2.x
                    WHERE a &amp;lt; 5000 LIMIT 100;
                    QUERY PLAN
--------------------------------------------------
 Limit
   -&amp;gt;  Hash Join
         Hash Cond: (t2.x = t1.a)
         -&amp;gt;  Seq Scan on t2
         -&amp;gt;  Hash
               -&amp;gt;  Index Scan using t1_pkey on t1
                     Index Cond: (a &amp;lt; 5000)
(7 rows)&lt;/pre&gt;&lt;p&gt;これが、xtimeモジュールにより以下のように書き換えられる。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;postgres=# LOAD '$libdir/xtime';
LOAD
postgres=# EXPLAIN (costs off)
           SELECT * FROM t1 JOIN t2 ON t1.a = t2.x
                    WHERE a &amp;lt; 5000 LIMIT 100;
                             QUERY PLAN
--------------------------------------------------------------------
 CustomExec:xtime
   -&amp;gt;  Limit
         -&amp;gt;  CustomExec:xtime
               -&amp;gt;  Hash Join
                     Hash Cond: (x = t1.a)
                     -&amp;gt;  CustomExec:xtime on t2
                     -&amp;gt;  Hash
                           -&amp;gt;  CustomExec:xtime
                                 -&amp;gt;  Index Scan using t1_pkey on t1
                                       Index Cond: (a &amp;lt; 5000)
(10 rows)&lt;/pre&gt;&lt;p&gt;数ヶ所にCustomExecノードが挿入されている。t2へのSeqScanが消えているのは、SeqScanの場合にはxtimeモジュールが自力でテーブルをスキャンするため（コードサンプルとして使う事を想定しているので）。&lt;/p&gt;&lt;p&gt;で、このクエリを実行すると以下のように表示される。CustomExecノードをプラン木の間に挟み込み、下位ノードの実行に要した時間を記録しているのである。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;postgres=# \timing
Timing is on.
postgres=# SELECT * FROM t1 JOIN t2 ON t1.a = t2.x WHERE a &amp;lt; 5000 LIMIT 100;
INFO:  execution time of Limit:  9.517 ms
INFO:   execution time of Hash Join:  9.487 ms
INFO:    execution time of CustomExec:xtime on t2:  0.047 ms
INFO:     execution time of Index Scan on t1:  4.947 ms
        ：
     （省略）
        ：
Time: 12.935 ms&lt;/pre&gt;&lt;p&gt;ひとまず、CommitFest:Sepまでにちゃんと提案できるブツを作れてよかった。&lt;br /&gt;
あとはドキュメントと&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%BD%A1%BC%A5%B9%A5%B3%A1%BC%A5%C9&quot;&gt;ソースコード&lt;/a&gt;コメントをちゃんと書いて投稿である。&lt;/p&gt;</description>
	<pubDate>Sat, 31 Aug 2013 15:07:50 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>Dan Walsh: New MLS videos at access.redhat.com</title>
	<guid>http://danwalsh.livejournal.com/66220.html</guid>
	<link>http://danwalsh.livejournal.com/66220.html</link>
	<description>&lt;p&gt;&lt;b&gt;We no how much you like SELinux!!!&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Well if you really want to turn up the enjoyment, why not try Multi Level Security (MLS) policy?&lt;br /&gt;&lt;br /&gt;Well you probably only want to do this if you need to store data on a machine that is truly multi level.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;b&gt;MLS Policy&lt;/b&gt; (selinux-policy-mls)&lt;br /&gt;&lt;br /&gt;We have been shipping MLS policy since RHEL5, and Fedora 6.&lt;br /&gt;&lt;br /&gt;RHEL5 and RHEL6 have achieved a government certification of EAL4+/LSPP.&amp;nbsp; This certification basically says that these Operating Systems are able to store and handle data that&amp;nbsp; has different Security levels, like Top Secret/Secret/Unclassified.&amp;nbsp; It is the same certification that Trusted Solaris achieved.&amp;nbsp; Bottom line is the Defense Organisations are using SELinux MLS on RHEL5 and RHEL6&amp;nbsp; in the most sensitive places.&amp;nbsp;&amp;nbsp; If you are an administrator of these types of machines, you need to see some new videos on access.redhat.com.&lt;br /&gt;&lt;br /&gt;Dave Egts is at it again.&lt;br /&gt;&lt;br /&gt;I absolutely loved Dave's videos on &lt;a href=&quot;https://access.redhat.com/site/videos/214723&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;confined users&lt;/a&gt;.&amp;nbsp; Whenever I teach SELinux Roles Based Access Control (RBAC), I show the videos.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;They are Must See TV&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Dave does a great job of explaining complex technology&amp;nbsp; in short easy to consume videos. &lt;br /&gt;&lt;br /&gt;Now Dave and the folks who build the content on access.redhat.com have put together 8 MLS Videos.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://access.redhat.com/site/videos/452063&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;span&gt;Multilevel Security with Red Hat Enterprise Linux and SELinux&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Check it out.&lt;/p&gt;</description>
	<pubDate>Thu, 29 Aug 2013 13:30:21 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: 単体型GPUへのDMA転送コストを考える</title>
	<guid>hatenablog://entry/11696248318757074089</guid>
	<link>http://kaigai.hatenablog.com/entry/2013/08/25/190908</link>
	<description>&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;の検索処理（特にスキャン周り）を&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;にオフロードするにあたって、できるだけCPU処理の負荷を軽減したい。というのも、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;は基本シングルスレッドなので、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;がバリバリ並列計算しようとしてもデバイスへのデータ供給が追い付かなければ計算機を遊ばせてしまう事になる。&lt;/p&gt;&lt;p&gt;大雑把に言うと、PG-Stromは以下のような構造を持ち、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;バックエンドがデータベースファイルから読み込んだデータを、共有メモリを介してOpenCL Serverが見える所に置いてあげる。OpenCL ServerはデータをDMA転送して&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt; Kernel関数を起動、計算結果をまた&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;バックエンドに戻してやる。&lt;br /&gt;
&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20130825/20130825174718.png&quot; alt=&quot;f:id:kaigai:20130825174718p:plain&quot; title=&quot;f:id:kaigai:20130825174718p:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;もう少し細かく仕事を分割すると、以下の通り。&lt;br /&gt;
&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20130825/20130825174734.png&quot; alt=&quot;f:id:kaigai:20130825174734p:plain&quot; title=&quot;f:id:kaigai:20130825174734p:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ストレージからデータをロード（共有バッファに載ってなければ）&lt;/li&gt;
&lt;li&gt;共有バッファからタプルを取り出す。この時、Snapshotとの比較でタプルの可視不可視チェックも。&lt;/li&gt;
&lt;li&gt;タプルを展開し、長大な配列としてデータを並べ替える。元々カラム指向なデータ構造で持っているので、配列への展開は&quot;すごく重い&quot;という訳ではない。&lt;/li&gt;
&lt;li&gt;DMA転送でこの配列を&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;デバイスへコピー。&lt;/li&gt;
&lt;li&gt;転送されたデータを使って、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;側で計算を実行。&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;現状の実装だと、(1)～(3)までが&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;バックエンドの仕事、(4)がOpenCL Serverで、(5)が&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;デバイスとなる。&lt;/p&gt;&lt;p&gt;ただ、これだとCPU側での処理がかさんでしまうので、理想としては以下のように&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;の共有バッファから直接&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;デバイスにDMA転送、そこでタプルからのデータ取り出しを行えれば、CPU負荷は下がる事になる。&lt;br /&gt;
&lt;span&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20130825/20130825181145.png&quot; alt=&quot;f:id:kaigai:20130825181145p:plain&quot; title=&quot;f:id:kaigai:20130825181145p:plain&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;しかし、問題が２つ。&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;タプルの可視性判定はIFブロックの鬼なので&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;で実行したくない。その上、不可視なタプルを&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;に転送するコストは完全に無駄&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;の共有バッファのブロック長は8KB（設定により最大32KB）なので、細切れのDMAを大量に発行する必要が出てくる。&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;後者に関しては、簡単に性能を計測できるのでやってみた。&lt;/p&gt;&lt;p&gt;128MBのブロックを1回のDMAで転送した場合。理論上、これが最も性能の出るパターン。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[kaigai@iwashi gpuinfo]$ ./gpudma -m async
DMA send/recv test result
device:         GeForce GT 640
size:           128MB
chunks:         128MB x 1
ntrials:        100
total_size:     12800MB
time:           4.18s
speed:          3063.97MB/s
mode:           async&lt;/pre&gt;&lt;p&gt;一方、128MBのブロックを8KBx16384個のチャンクに分けて転送した場合だと、転送性能は1/3程度に。うーん、これはちょっとヨロシクナイ…。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[kaigai@iwashi gpuinfo]$ ./gpudma -m async -c 8
DMA send/recv test result
device:         GeForce GT 640
size:           128MB
chunks:         8KB x 16384
ntrials:        100
total_size:     12800MB
time:           12.36s
speed:          1035.97MB/s
mode:           async&lt;/pre&gt;&lt;p&gt;当然、ブロック長が長くなればなるほどDMA発行の手間が減るので性能的には有利。&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;のコンフィグで変更可能な32KB相当のDMA単位にすると、本来の性能の85%程度は出てくれる。それでも結構痛いが。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[kaigai@iwashi gpuinfo]$ ./gpudma -m async -c 32
DMA send/recv test result
device:         GeForce GT 640
size:           128MB
chunks:         32KB x 4096
ntrials:        100
total_size:     12800MB
time:           5.06s
speed:          2531.70MB/s
mode:           async&lt;/pre&gt;&lt;p&gt;なかなか悩ましいところではあるが、8KBのチャンクを直接&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;にDMA転送するコストの高さを考えれば、CPU側である程度まとまった大きさに集約してからガツンとDMAを発行した方が効率はよさそう。その一方で、シングルスレッドの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;バックエンドを酷使するのも考え物なので、ベストミックスとしては、マルチスレッドで動作可能なOpenCL Serverにタプルの取り出しとDMAバッファへの展開を行わせても良さそう。&lt;br /&gt;
あと、現状ではDMAバッファへの展開時に圧縮データの展開を行っているけども、CPUの処理負荷を下げるだけでなく、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PCI-E&quot;&gt;PCI-E&lt;/a&gt;の帯域を節約するという観点からも、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;側で圧縮データの伸長を行った方が良いのかもしれない。&lt;/p&gt;</description>
	<pubDate>Sun, 25 Aug 2013 10:09:08 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>Dan Walsh: What would happen if an OpenShift gear became root?</title>
	<guid>http://danwalsh.livejournal.com/66037.html</guid>
	<link>http://danwalsh.livejournal.com/66037.html</link>
	<description>Here is a video I put together for the Red Hat Summit.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/Presentations/openshift_selinux.ogv&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;The video shows how SELinux would control an openshift gear if it somehow it got a privilege escalation and actually became root.&lt;/a&gt;</description>
	<pubDate>Mon, 05 Aug 2013 20:18:50 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 20 Part 1: Setroubleshoot - Journald integration</title>
	<guid>http://danwalsh.livejournal.com/65777.html</guid>
	<link>http://danwalsh.livejournal.com/65777.html</link>
	<description>A little early to start this series, but I am pretty excited about all the new features coming in Fedora 20.&lt;br /&gt;&lt;br /&gt;A while ago a fellow worker M&amp;aacute;ir&amp;iacute;n Duffy was very proud of herself for figuring out an SELinux issue.&amp;nbsp; Basically she had a problem that is fairly common struggle people have with SELinux.&amp;nbsp; She had created some content for her web server in her home directory, and then mv'd it into a /var/www subdir and tried to look at it in here web browser and got a screen like the following.&lt;br /&gt;&lt;br /&gt;&lt;img alt=&quot;Screenshot from 2013-08-02 08:02:04&quot; height=&quot;270.5&quot; src=&quot;http://ic.pics.livejournal.com/danwalsh/9465280/3385/3385_900.png&quot; title=&quot;Screenshot from 2013-08-02 08:02:04&quot; width=&quot;450&quot; /&gt;&lt;br /&gt;&lt;br /&gt;When she went to look at the&lt;b&gt; /var/log/httpd/error_log&lt;/b&gt;, she saw something like:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;# tail /var/log/httpd/error_log&lt;/b&gt;&lt;br /&gt;[Fri Aug 02 08:05:43.347080 2013] [core:error] [pid 10556] (13)Permission denied: [client ::1:38045] AH00132: file permissions deny server access: /var/www/html/index.html&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Instead of thinking there was a problem with Ownership or Permission flags, she thought of SELinux and&amp;nbsp; figured their might be&amp;nbsp; problem with the labels,&amp;nbsp; so she ran:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;# restorecon -R -v /var/www&lt;/b&gt;&lt;br /&gt;restorecon reset /var/www/html/index.html context unconfined_u:object_r:user_home_t:s0-&amp;gt;unconfined_u:object_r:httpd_sys_content_t:s0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Well if she had continued to investigate she would have seen the following in other logs.&lt;br /&gt;&lt;br /&gt;In the&lt;b&gt; /var/log/audit/audit.log&lt;/b&gt; the kernel had reported an AVC message like the following.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;# ausearch -m avc -ts recent -i&lt;/b&gt;&lt;br /&gt;type=PATH msg=audit(08/02/2013 08:05:43.346:1197) : item=0 name=&lt;b&gt;/var/www/html/index.html &lt;/b&gt;inode=3145858 dev=08:03 mode=file,644 ouid=root ogid=root rdev=00:00 obj=unconfined_u:object_r:user_home_t:s0&lt;br /&gt;type=CWD msg=audit(08/02/2013 08:05:43.346:1197) :&amp;nbsp; cwd=/&lt;br /&gt;type=SYSCALL msg=audit(08/02/2013 08:05:43.346:1197) : arch=x86_64 syscall=open success=no exit=-13(Permission denied) a0=0x7f476595da40 a1=O_RDONLY|O_CLOEXEC a2=0x0 a3=0x7fffe27e11b0 items=1 ppid=10552 &lt;/span&gt;&lt;span&gt;&lt;b&gt;pid=10556&lt;/b&gt;&lt;/span&gt;&lt;span&gt; auid=unset uid=apache gid=apache euid=apache suid=apache fsuid=apache egid=apache sgid=apache fsgid=apache ses=unset tty=(none) comm=httpd exe=&lt;b&gt;/usr/sbin/httpd&lt;/b&gt; subj=system_u:system_r:httpd_t:s0 key=(null)&lt;br /&gt;type=AVC msg=audit(08/02/2013 08:05:43.346:1197) : &lt;b&gt;avc:&amp;nbsp; denied&lt;/b&gt; { &lt;b&gt;read&lt;/b&gt; } for&amp;nbsp; pid=10556 comm=httpd name=index.html dev=&amp;quot;sda3&amp;quot; ino=3145858 scontext=system_u:system_r:httpd_t:s0 tcontext=&lt;b&gt;unconfined_u:object_r:user_home_t&lt;/b&gt;:s0 tclass=file &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;SETroubleshoot received this message and reported in&lt;b&gt; /var/log/messages&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span&gt;# grep setroubleshoot /var/log/messages&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span&gt;Aug&amp;nbsp; 2 08:01:46 redsox setroubleshoot: SELinux is preventing /usr/sbin/httpd from read access on the file /var/www/html/index.html. For complete SELinux messages. run &lt;b&gt;sealert -l fd6b9022-1ced-4065-905a-8f0e884f9915&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If she finally ran this sealert command specified in the log file she would have found setroubleshoot had written its analysis in&lt;b&gt; /var/lib/setroubleshoot/setroubleshoot_database.xml &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;# sealert -l fd6b9022-1ced-4065-905a-8f0e884f9915&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;SELinux is preventing /usr/sbin/httpd from read access on the file /var/www/html/index.html.&lt;br /&gt;&lt;br /&gt;*****&amp;nbsp; Plugin restorecon (92.2 confidence) suggests&amp;nbsp; *************************&lt;br /&gt;&lt;br /&gt;If you want to fix the label.&lt;br /&gt;/var/www/html/index.html default label should be httpd_sys_content_t.&lt;br /&gt;Then you can run restorecon.&lt;br /&gt;Do&lt;br /&gt;# /sbin/restorecon -v /var/www/html/index.html&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Nice that M&amp;aacute;ir&amp;iacute;n figured out her problem so quickly, but as you see the system had scattered little clues all over the system to help her.&amp;nbsp; And who says SELinux is not easy.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Ok Dan get to the point?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If you have been following the Fedora-devel list their has been a large discussion going on about whether or not to enable syslog (rsyslog) in the default install.&amp;nbsp; The idea is to consolidate logging into journald which I talked about in a previous &lt;a href=&quot;http://danwalsh.livejournal.com/58647.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;blog&lt;/a&gt;.&amp;nbsp; And get log analysis tools to start relying on its data rather then scanning /var/log/messages. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;SETroubleshot integration with journald.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Back in Fedora 18 or 19 we started dumping setroubleshoot data into the journal.&amp;nbsp; The problem with this data is that it was setroubleshoot reporting on the httpd process, but there was no way for journald/systemd to know this.&amp;nbsp; I asked the journald team to add a mechanism for a privileged application to specify a Process ID (PID) to which the log message pertained.&amp;nbsp; Well systemd/journald has added this in systemd-206-1.&amp;nbsp; I added the functionality to setroubleshoot-3.2.11-1.fc20.x86_64&lt;br /&gt;&lt;br /&gt;Now if M&amp;aacute;ir&amp;iacute;n had simply checked the status of the httpd service, she would see a message like:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;# systemctl status httpd&lt;/b&gt;&lt;br /&gt;httpd.service - The Apache HTTP Server&lt;br /&gt;&amp;nbsp;&amp;nbsp; Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)&lt;br /&gt;&amp;nbsp;&amp;nbsp; Active: active (running) since Fri 2013-08-02 08:01:35 EDT; 30min ago&lt;br /&gt;&amp;nbsp;Main PID: 10552 (httpd)&lt;br /&gt;&amp;nbsp;&amp;nbsp; Status: &amp;quot;Total requests: 4; Current requests/sec: 0; Current traffic:&amp;nbsp;&amp;nbsp; 0 B/sec&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; CGroup: /system.slice/httpd.service&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10552 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10553 /usr/libexec/nss_pcache 196611 off /etc/httpd/alias&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10554 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10555 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10556 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10557 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ├─10558 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; └─10569 /usr/sbin/httpd -DFOREGROUND&lt;br /&gt;&lt;br /&gt;Aug 02 08:01:35 redsox.boston.devel.redhat.com systemd[1]: Started The Apache HTTP Server.&lt;br /&gt;Aug 02 08:01:46 redsox.boston.devel.redhat.com python[10564]: SELinux is preventing /usr/sbin/httpd from read access on the file /va...html.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *****&amp;nbsp; Plugin restorecon (&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then if she used the journalctl command she could see the full analysis.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;# journalctl&amp;nbsp; -r -o verbose -u httpd.service&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;-- Logs begin at Tue 2013-04-09 15:19:05 EDT, end at Fri 2013-08-02 08:32:35 EDT. --&lt;br /&gt;Fri 2013-08-02 08:05:45 EDT [s=3087834a63d74580811c9e1088ac7fdf;i=1195d;b=71667fa0d7074a3f8bdf1c0da22fe234;m=22b877728;t=4e2f5c7552cb6;x=908&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _UID=0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _GID=0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _BOOT_ID=71667fa0d7074a3f8bdf1c0da22fe234&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _MACHINE_ID=8835be49c83449d3b4581853df82eafa&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _HOSTNAME=redsox.boston.devel.redhat.com&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _TRANSPORT=journal&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _CAP_EFFECTIVE=3fffffffff&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _SYSTEMD_CGROUP=/system.slice/dbus.service&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _SYSTEMD_UNIT=dbus.service&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _EXE=/usr/bin/python2.7&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _COMM=setroubleshootd&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _CMDLINE=/usr/bin/python -Es /usr/sbin/setroubleshootd -f&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _SELINUX_CONTEXT=system_u:system_r:setroubleshootd_t:s0-s0:c0.c1023&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;MESSAGE=SELinux is preventing /usr/sbin/httpd from read access on the file /var/www/html/index.html.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *****&amp;nbsp; Plugin restorecon (92.2 confidence) suggests&amp;nbsp; *************************&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want to fix the label.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /var/www/html/index.html default label should be httpd_sys_content_t.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Then you can run restorecon.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # /sbin/restorecon -v /var/www/html/index.html&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *****&amp;nbsp; Plugin catchall_boolean (7.83 confidence) suggests&amp;nbsp; *******************&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want to allow httpd to read user content&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Then you must tell SELinux about this by enabling the 'httpd_read_user_content' boolean.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can read 'user_selinux' man page for more details.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setsebool -P httpd_read_user_content 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *****&amp;nbsp; Plugin catchall (1.41 confidence) suggests&amp;nbsp; ***************************&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you believe that httpd should be allowed read access on the index.html file by default.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Then you should report this as a bug.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can generate a local policy module to allow this access.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; allow this access for now by executing:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # grep httpd /var/log/audit/audit.log | audit2allow -M mypol&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # semodule -i mypol.pp&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CODE_FILE=/usr/lib64/python2.7/site-packages/setroubleshoot/server.py&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CODE_LINE=196&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CODE_FUNC=report_problem&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SYSLOG_IDENTIFIER=python&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OBJECT_UID=48&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OBJECT_GID=48&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OBJECT_COMM=httpd&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OBJECT_EXE=/usr/sbin/httpd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pretty cool!&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;All of the information is now consolidated into a single tool chain, and if administrators start using &lt;i&gt;systemct status foobar&lt;/i&gt;, they will get important SELinux information in the main log, making &lt;a href=&quot;http://stopdisablingselinux.com/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;SELinux easier to use and thus getting more people to keep it enabled.&amp;nbsp; &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;BTW, this feature will be in Red Hat Enterprise 7.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Future:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I hope to work with the systemd/journald team to allow systemctl status to provide extended information, so the entire message could have been shown in that screen,&amp;nbsp; eliminating the need the next step, but this is a huge step forward in usability.&lt;br /&gt;&lt;br /&gt;In the coming fedora's I hope to eliminate the setroubleshoot database totally and just use journald as its information database.&lt;br /&gt;&lt;br /&gt;And I still want to push the kernel team forward on the &lt;a href=&quot;https://fedoraproject.org/wiki/Features/FriendlyEPERM&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Friendly EPERM.&lt;/a&gt;</description>
	<pubDate>Fri, 02 Aug 2013 12:54:06 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>James Morris: Linux Security Summit 2013 – Schedule Published!</title>
	<guid>http://blog.namei.org/?p=566</guid>
	<link>http://blog.namei.org/2013/08/02/linux-security-summit-2013-schedule-published/</link>
	<description>&lt;p&gt;The schedule for this year&amp;#8217;s &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2013&quot;&gt;Linux Security Summit&lt;/a&gt; in New Orleans is now &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2013#Schedule&quot;&gt;published&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;The keynote will be presented by &lt;a href=&quot;http://thunk.org/tytso/&quot;&gt;Ted Ts&amp;#8217;o&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Refereed talks include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Embedded Linux Security 	(David Safford, IBM)&lt;/li&gt;
&lt;li&gt; Extending AppArmor Mediation into the Userspace 	(John Johansen, Canonical)&lt;/li&gt;
&lt;li&gt; Multiple Concurrent Security Models? Really? 	(Casey Schaufler, Intel)&lt;/li&gt;
&lt;li&gt; Linux Kernel ASLR 	(Kees Cook, Google)&lt;/li&gt;
&lt;li&gt; The AppArmor Labeling Model (John Johansen, Canonical)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It looks like there&amp;#8217;s been quite a lot happening in AppArmor.  There&amp;#8217;ll also be general project updates for SELinux, Smack, AppArmor and the Integrity subsystem, as well as a discussion on kernel coding anti-patterns led by Kees Cook.&lt;/p&gt;
&lt;p&gt;There&amp;#8217;ll be break-out sessions on the second day, details of which will be posted on the schedule as they&amp;#8217;re known.  If you&amp;#8217;ll be at LSS (or LinuxCon/Plumbers generally) and would like to schedule a break-out session, contact the program committee per the details at the wiki page.&lt;/p&gt;
&lt;p&gt;See everyone on the 19th and 20th of September in New Orleans!&lt;/p&gt;</description>
	<pubDate>Fri, 02 Aug 2013 06:15:51 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Russell Coker (security): Security is Impossible</title>
	<guid>http://etbe.coker.com.au/?p=3742</guid>
	<link>http://etbe.coker.com.au/2013/07/23/security-is-impossible/</link>
	<description>&lt;h3&gt;The Scope of the Problem&lt;/h3&gt;
&lt;p&gt;Security is inherently complex because of the large number of ways of circumventing it. For example Internet facing servers have been successfully attacked based on vulnerabilities in the OS, the server application, public key generation, DNS, SSL key certificates (and many other programs and algorithms in use), as well as the infrastructure and employees of all companies in the chain. When all those layers work reasonably well (not perfectly but well enough to not obviously be the weakest link) there are attacks on the end user systems that access the servers (such as the trojan horse programs used to attack PCs used for online banking).&lt;/p&gt;
&lt;h3&gt;My Area of Interest&lt;/h3&gt;
&lt;p&gt;The area of security that interests me is Linux software development. There are many related areas such as documentation and default configurations to make it easier for people to secure their systems (instead of insecure systems being the default option) which are all important.&lt;/p&gt;
&lt;p&gt;There are also many related fields such as ensuring that all people with relevant access are trustworthy. There are many interesting problems to solve in such areas most of which aren&amp;#8217;t a good match for my skills or just require more time than I have available.&lt;/p&gt;
&lt;p&gt;I sometimes write blog posts commenting on random security problems in other areas. Sometimes I hope to inspire people to new research, sometimes I hope to just inform users who can consider the issues when implementing solutions to security problems.&lt;/p&gt;
&lt;h3&gt;Bugs&lt;/h3&gt;
&lt;p&gt;In the software development side there are ongoing problems of bugs in code that weaken security. The fact that the main area of concern for people who are interested in securing systems is fixing bugs is an indication that the problem of software quality needs a lot of work at the moment.&lt;/p&gt;
&lt;p&gt;The other area that gets a reasonable amount of obvious work is in access control. Again it&amp;#8217;s an area that needs a lot of work, but the fact that we&amp;#8217;re not done with that is an indication of how far there is to go in generally improving computer security.&lt;/p&gt;
&lt;h3&gt;Authenticating Software Releases&lt;/h3&gt;
&lt;p&gt;There have been cases where source code repositories have been compromised to introduce trojan horse code, the ones I&amp;#8217;ve read about have been discovered reasonably quickly with little harm done &amp;#8211; but there could be some which weren&amp;#8217;t discovered. Of course it&amp;#8217;s likely that such attacks will be discovered because someone will have the original and the copies can be compared.&lt;/p&gt;
&lt;p&gt;Repositories of binaries are a bigger problem, it&amp;#8217;s not always possible to recompile a program and get a binary which checks out as being identical (larger programs often include the build time in the binary). Even for build processes which don&amp;#8217;t include such data it can be very difficult to determine the integrity of a build process. For example programs compiled with different versions of libraries, header files, or compilers will usually differ slightly.&lt;/p&gt;
&lt;p&gt;As most developers frequently change the versions of such software they will often be unable to verify their own binaries and any automated verification of such binaries will be impossible for anyone else. So if a developer&amp;#8217;s workstation was compromised without their knowledge it might be impossible for them to later check whether they released trojan binaries &amp;#8211; without just running the binaries in question and looking for undesired behavior.&lt;/p&gt;
&lt;p&gt;The problem of verifying past binaries is solvable for large software companies, Linux distributions, and all other organisations that have the resources to keep old versions of all binaries and libraries used to build software. For proprietary software companies the verification process would have to start with faith in the vendor of their OS and compiler doing the right thing. For Linux distributions and other organisations based on free software it would start by having the source to everything which can then be verified in theory &amp;#8211; although in practice verifying all source for compilers, the OS, and libraries would be a huge undertaking.&lt;/p&gt;
&lt;h3&gt;Espionage&lt;/h3&gt;
&lt;p&gt;There is a well documented history of military espionage, people who are sworn to secrecy have been subverted by money, blackmail, and by having political beliefs which don&amp;#8217;t agree with their government. The history of corporate espionage is less well documented but as corporations perform less stringent background checks than military organisations I think it&amp;#8217;s safe to assume that corporate espionage is much more common.&lt;/p&gt;
&lt;p&gt;Presumably any government organisation that can have any success at subverting employees of a foreign government can be much more successful in subverting programmers (either in companies such as Microsoft or in the FOSS community). One factor that makes it easier to launch such attacks is the global nature of software development. Government jobs that involve access to secret data have requirements about where the applicant was born and has lived, corporate jobs and volunteer positions in free software development don&amp;#8217;t have such requirements.&lt;/p&gt;
&lt;p&gt;The effort involved in subverting an existing employee of a software company or contributor to free software or the effort involved in getting an agent accepted in such a project would be quite small when compared to a nuclear weapons program. Therefore I think we should assume that every country which is capable of developing nuclear weapons (even North Korea) can do such things if they wish.&lt;/p&gt;
&lt;p&gt;Would the government of such a country want to subvert a major software project that is used by hundreds of millions of people? I can imagine ways that such things could benefit a government and while there would be costs for such actions (both in local politics and international relations) it seems most likely that some governments would consider it to be worth the risk &amp;#8211; and North Korea doesn&amp;#8217;t seem to have much to lose.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;We would like every computer to be like a castle with a strong wall separating them from the bad things which can&amp;#8217;t be breached in ways that aren&amp;#8217;t obvious. But the way things are progressing with increasingly complex systems depending on more people and other systems it&amp;#8217;s becoming more like biology than engineering. We can think of important government systems as being comparable to the way people with compromised immune systems are isolated from any risk of catching a disease, the consequences of an infection are worse so greater isolation measures are required.&lt;/p&gt;
&lt;p&gt;For regular desktop PCs getting infected by a trojan is often regarded as being similar to getting a cold in winter. People just accept that their PC will be infected on occasion and don&amp;#8217;t bother making any serious effort to prevent it. After an infection is discovered the user (or their management for a corporate PC) tend not to be particularly worried about data loss in spite of some high profile data leaks from companies that do security work and the ongoing attacks against online banking and webcam spying on home PCs. I don&amp;#8217;t know what it will take for users to start taking security risks seriously.&lt;/p&gt;
&lt;p&gt;I think that a secure boot is a good step in the right direction, but it&amp;#8217;s a long way from being able to magically solve all security problems. &lt;a href=&quot;http://etbe.coker.com.au/2011/12/28/secure-boot-protecting-against-root/&quot;&gt;I&amp;#8217;ve previously described some of the ways that secure boot won&amp;#8217;t save you [1]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The problems of subverting developers don&amp;#8217;t seem to be an immediate concern (although we should consider the possibility that it might be happening already without anyone noticing). The ongoing trend is that the value of computers in society is steadily increasing which therefore increases the rewards for criminals and spy agencies who can compromise them. Therefore it seems that we will definitely face the problems of subverted developers if we can adequately address the current technical problems related to flaws in software and inadequate access control. We just need to fix some of the problems which are exploited more easily to force the attackers to use the more difficult and expensive attacks. Note that it is a really good thing to make attacks more difficult, that decreases the number of organisations that are capable of attack even though it won&amp;#8217;t stop determined attackers.&lt;/p&gt;
&lt;p&gt;For end user systems the major problem seems to be related to running random programs from the Internet without a security model that adequately protects the system. Both Android and iOS make good efforts at protecting a system in the face of random hostile applications, but they have both been shown to fail in practice (it might be a good idea to have a phone for games that is separate from the phone used for phone calls etc). More research into OS security is needed to address this. But in the mean time users need to refrain from playing games and viewing porn on systems that are used for work, Internet banking, and other important things. While PCs are small and cheap enough that having separate PCs for important and unimportant tasks is practical it seems that most users don&amp;#8217;t regard the problems as being serious enough to be worth the effort.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://etbe.coker.com.au/2011/12/28/secure-boot-protecting-against-root/&quot;&gt; http://etbe.coker.com.au/2011/12/28/secure-boot-protecting-against-root/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2006/11/09/a-good-security-design-for-an-office/&quot; rel=&quot;bookmark&quot; title=&quot;a good security design for an office&quot;&gt;a good security design for an office &lt;/a&gt; &lt;small&gt; One issue that is rarely considered is how to...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2009/08/20/mail-server-security/&quot; rel=&quot;bookmark&quot; title=&quot;Mail Server Security&quot;&gt;Mail Server Security &lt;/a&gt; &lt;small&gt;I predict that over the course of the next 10...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2011/07/08/multiple-filesystems-security/&quot; rel=&quot;bookmark&quot; title=&quot;Multiple Filesystems for Security&quot;&gt;Multiple Filesystems for Security &lt;/a&gt; &lt;small&gt;There is always been an ongoing debate about how to...&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Tue, 23 Jul 2013 04:34:01 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Joshua Brindle: SE for Android on the GS4 Google Play Edition</title>
	<guid>http://securityblog.org/2013/07/08/se-for-android-play-edition</guid>
	<link>http://securityblog.org/2013/07/08/se-for-android-gs4-gpe</link>
	<description>&lt;h2&gt;GS4 Google Play Edition != Nexus&lt;/h2&gt;

&lt;p&gt;Caveat: Everything here is based on the leaked images floating around and are not necessarilly represenative of what the final, released version will look like. That said, it is probably partially useful and my curiousity got the best of me...&lt;/p&gt;

&lt;p&gt;As you probably know by now the GS4 Google Play Edition is not a Nexus device. It does not get updates from Google and does not have only Google provided code. It was developed by Samsung but removes all of the TouchWiz features. However, it is an updated version of Android (4.3) and has some things that the standard GS4 does not.&lt;/p&gt;

&lt;p&gt;Since the standard GS4 SE for Android controls are Samsung-specific, and deeply embedded in the Knox libraries Google had to provide something else.&lt;/p&gt;

&lt;p&gt;Rather than using the management system proposed by the SE for Android community they invented another, third, system.&lt;/p&gt;

&lt;p&gt;It is a good bet that the interfaces I'll talk about here will show up in AOSP when 4.3 is released so getting a head start can't be a bad idea &lt;img src=&quot;http://securityblog.org/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;&lt;/p&gt;

&lt;h2&gt;State of SE for Android on the GS4 GPE&lt;/h2&gt;

&lt;p&gt;As you can see in screenshots released SELinux is present and set to permissive in the Settings app. The policy looks very similar to that of the standard GS4, including components that have been removed from this version:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cat seapp_contexts | grep samsung
user=_app seinfo=samsung domain=samsung_app type=app_data_file
user=_app seinfo=samsung name=com.sec.android.app.samsungapps domain=samsung_app type=app_data_file
user=_app seinfo=untrusted name=com.vlingo.midas domain=samsung_app type=app_data_file
user=_app seinfo=untrusted name=tv.peel.samsung.app domain=samsung_app type=app_data_file
user=_app seinfo=untrusted name=tv.peel.samsung.widget domain=samsung_app type=app_data_file
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, since this is basically the same policy hopefully enforcing mode will work fine, as it does on the standard version:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# setenforce 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Oh! The screen froze, I can't hit any buttons or even get back to home.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# setenforce 0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Doesn't fix it! Well... obviously this policy needs some work. Too bad the AVC messages are still removed from the kernel messages and no auditing is present... &lt;em&gt;sigh&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's move on to the management API.&lt;/p&gt;

&lt;h2&gt;Managing SE for Android on the GS4 GPE&lt;/h2&gt;

&lt;p&gt;As I already said, the Knox components have been removed so the previous client I posted won't work. Looking at the code there is a new interface. It is in the services framework and is triggered by an Intent:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Intent i = new Intent(&quot;android.intent.action.UPDATE_SEPOLICY&quot;);
i.putExtra(&quot;CONTENT_PATH&quot;, bundle_file_path);
i.putExtra(&quot;REQUIRED_HASH&quot;, &quot;NONE&quot;);
i.putExtra(&quot;SIGNATURE&quot;, &quot;...&quot;);
i.putExtra(&quot;VERSION&quot;, &quot;1&quot;);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The Intent can be triggered from anywhere, so a third party app can call it, a separate permission is not even required. The REQUIRED_HASH you see above short circuits the check against the previous policy and the VERSION must be higher than the last update (though can be 1 the first time you call it). The signature is the sticking point. The bundle (I'll get to that in a bit) has to be signed by the update certificate. The update certificate is stored in the Settings provider, though, and with root we can update that (you need to add sqlite3 to your system partition to do this):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# cd /data/data/com.android.providers.settings/databases
# sqlite3 settings.db &quot;INSERT into secure (name, value) VALUES('config_update_certificate','&amp;lt;your public DER cert&amp;gt;');&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you've done that can you sign the bundle, put it on the system where services can read it (/cache works well) and call the intent. Viola.&lt;/p&gt;

&lt;p&gt;Except not. After getting this to succeed (the certificate and signing stuff in here is really finicky) the policy was placed in /data/security/contexts with 'current' symlinked to it.. Strangely, none of the rest of the code appears to look there. Indeed the policy doesn't appear to be loaded either when the Intent is called or at boot time. Doh!&lt;/p&gt;

&lt;p&gt;Since this doesn't currently work I didn't see much value in posting code. I'll keep it up to date and when I get a real released version I'll post it if it works (or maybe if it doesn't)&lt;/p&gt;

&lt;p&gt;Enforcing mode is set with a global setting (selinux_status), and appears to be persistent, but since enforcing does not work it is not a good idea to set it.&lt;/p&gt;

&lt;h2&gt;The Bundle&lt;/h2&gt;

&lt;p&gt;So, Google made a new file format for bundling components of the policy, seapp_contexts, property_contexts, file_contexts, and the binary policy, in that order. Sadly mac_permissions.xml is not in the bundle, nor does there appear any way to update it.&lt;/p&gt;

&lt;p&gt;The bundle is simple, 4 32-bit (big endian!) integers representing the size of the policy component and then the components, base64 encoded.&lt;/p&gt;

&lt;h2&gt;The Signature&lt;/h2&gt;

&lt;p&gt;The signature isn't a standard openssl signature but it can be created in Java, using the standard API's:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Signature signer = Signature.getInstance(&quot;SHA512withRSA&quot;);
signer.initSign(privKey);
signer.update(bundle);
signer.update(Long.toString(version).getBytes());
signer.update(prevHash.getBytes());
byte [] signature = signer.sign();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You'll note that the signature includes the hash of the bundle itself, and also the version number and hash sent in the intent. This is likely to prevent downgrading by sending the intent with a lower version and different hash.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;So, my high hopes were dashed (I didn't really have high hopes... I've learned to have low expectations for these things).&lt;/p&gt;

&lt;p&gt;Enforcing mode doesn't work, auditing is still not present, the update API's are non-functional and even if they were functional, they can only be used by the person with the update certificate, which is the vendor. Once again, we have a device that does not allow its owner to protect themselves using mandatory access control, nor change the policy to meet different use cases than the vendor expected. It is very unfortunate that the best technology available for protecting our mobile devices has been locked away from us.&lt;/p&gt;</description>
	<pubDate>Mon, 08 Jul 2013 05:00:00 +0000</pubDate>
</item>
<item>
	<title>Joshua Brindle: SE for Android GS4 howto and exploit demo</title>
	<guid>http://securityblog.org/2013/06/28/se-for-android-galaxy-s4-demo</guid>
	<link>http://securityblog.org/2013/06/28/se-for-android-gs4-howto-and-exploit-demo</link>
	<description>&lt;h2&gt;The client&lt;/h2&gt;

&lt;p&gt;I've uploaded my changes to the SEAdmin client to &lt;a href=&quot;https://bitbucket.org/joshua_brindle/packages-apps-seandroidadmin&quot;&gt;bitbucket&lt;/a&gt; (be sure to check out the samsung-API branch) for brave souls who want to experiment with this. I also have an &lt;a href=&quot;http://securityblog.org/images/SEAndroidAdminActivity.apk&quot;&gt;apk&lt;/a&gt; for those who don't want to build their own. This &lt;em&gt;must&lt;/em&gt; be installed to the system partition in order to work. It is also crazy hacked together so don't blame me if your phone blows up.&lt;/p&gt;

&lt;p&gt;After rooting your phone with something like &lt;a href=&quot;http://forum.xda-developers.com/showthread.php?t=2252248&quot;&gt;motochopper&lt;/a&gt; put the apk onto /system:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ adb push SEAndroidAdminActivity.apk /sdcard/
2146 KB/s (758399 bytes in 0.345s)

$ adb shell
shell@android:/ $ su
su
root@android:/ # mount -orw,remount /system
mount -orw,remount /system
root@android:/ # cp /sdcard/SEAndroidAdminActivity.apk /system/app
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If it doesn't show up in your app list go ahead and reboot.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@android:/ # reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Run it and enable it as a device administrator by sliding the top slider and hitting activate. It isn't technically a device admin anymore but I didn't disable that code.&lt;/p&gt;

&lt;p&gt;After that go to SELinux Administration:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://securityblog.org/images/sel-admin-permissive.png&quot; alt=&quot;SELinux Administration - permissive&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Before you click on enforce it is a good idea to get an adb shell running as system so that you don't have to continually reboot your device:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ adb shell
shell@android:/ $ su
su
root@android:/ # runcon u:r:system:s0 sh
runcon u:r:system:s0 sh
root@android:/ # id -Z
id -Z
uid=0(root) gid=0(root) context=u:r:system:s0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We are all set, go ahead and click enforce:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://securityblog.org/images/sel-admin-enforcing.png&quot; alt=&quot;SELinux Administration - enforcing&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It will be checked now, unfortunately if you leave this screen and come back it won't be checked. This is due to the app not having permission to check enforcing status. You can always check whether you are enforcing by going to settings-&gt;More-&gt;About Device and scrolling to the bottom:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://securityblog.org/images/settings-enforcing.png&quot; alt=&quot;SELinux settings&quot; /&gt;&lt;/p&gt;

&lt;h2&gt;The exploit&lt;/h2&gt;

&lt;p&gt;Now, lets try to run motochopper on an phone in enforcing:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./run.sh 
&amp;lt;snip&amp;gt;
[*] 
[*] Waiting for device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
[*] Device found.
[*] Pushing exploit...
4382 KB/s (1283460 bytes in 0.286s)
[*] Pushing root tools...
5119 KB/s (366952 bytes in 0.070s)
4373 KB/s (1867568 bytes in 0.417s)
        pkg: /data/local/tmp/Superuser.apk
Success
4520 KB/s (1578585 bytes in 0.341s)
[*] Rooting phone...
[+] This may take a few minutes.
[-] Failure.
[*] Cleaning up...
[*] Exploit complete. Press enter to reboot and exit.
Press any key to continue . . .   
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see it failed.&lt;/p&gt;

&lt;h2&gt;Howto&lt;/h2&gt;

&lt;p&gt;You can continue running it with the default policy but apps that require root will not work. If you are interested in working on the policy you can use adb to pull it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ adb pull /sepolicy
3379 KB/s (134977 bytes in 0.039s)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then use the &lt;a href=&quot;https://bitbucket.org/joshua_brindle/sepolicy-inject&quot;&gt;policy injector&lt;/a&gt; to add rules. Afterward you'll need to reload the policy manually:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ adb push sepolicy /sdcard/
3138 KB/s (134977 bytes in 0.042s)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then on your system shell (you &lt;em&gt;did&lt;/em&gt; keep a system shell handy, right?)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# cd /data/security
# cp /sdcard/sepolicy .
# setprop selinux.reload_policy 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The system shell can also toggle enforcing and permissive (I know, that would have been easier than using a client but I wanted to see what real support there was first)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@android:/ # setenforce 0
setenforce 0
root@android:/ # getenforce
getenforce
Permissive
root@android:/ # setenforce 1
setenforce 1
root@android:/ # getenforce
getenforce
Enforcing
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Without denials working on the policy will be quite tedious. Hopefully I'll be able to post a modified kernel soon to turn auditing back on. In the mean time, have fun.&lt;/p&gt;</description>
	<pubDate>Fri, 28 Jun 2013 05:00:00 +0000</pubDate>
</item>
<item>
	<title>Joshua Brindle: Using SE for Android on the Samsung Galaxy S4</title>
	<guid>http://securityblog.org/2013/06/27/using-se-for-android-on-the-samsung-galaxy-s4</guid>
	<link>http://securityblog.org/2013/06/27/using-se-for-android-on-the-galaxy-s4</link>
	<description>&lt;h2&gt;So, you want to secure your Galaxy S4?&lt;/h2&gt;

&lt;p&gt;After my &lt;a href=&quot;http://securityblog.org/2013/04/30/SE-Android-and-the-motochopper-exploit&quot;&gt;last blog post&lt;/a&gt; I really wanted to get my hands on a Galaxy S4 to see what we could do with it, from an SE for Android perspective. Well, I got one yesterday and the answer is, unfortunately, not a whole lot, but not nothing, either.&lt;/p&gt;

&lt;p&gt;First, I wanted to try turning on enforcing from an MDM app without rooting the device. Turns out the APIs for working with SE for Android aren't part of the Samsung MDM API (nor do they have the upstream MDM API present). Instead they are calls to a service that require the calling app to either be signed by the platform certificate or on the system image. Doh.&lt;/p&gt;

&lt;p&gt;So now, time to root. I adapted the SEAdmin app from upstream SE for Android to use the Samsung APIs instead and put it on the system image. After some kajiggering I got the app to set enforcing (yay!). Fun fact: you have to set the logging level all the way up for it to work... hrm...&lt;/p&gt;

&lt;p&gt;So, now let's set it back to permissive. Oh, there isn't an API for that; can't use JNI either, since the app isn't running as system. Well, I guess that is more secure anyway. Too bad it makes development very difficult.&lt;/p&gt;

&lt;p&gt;Speaking of making development very difficult, fun fact #2 is that the audit logs for SELinux are turned off in the kernel so you can't get denials if you plan on doing policy development. Guess I'll have to rebuild the kernel when I get to that stage.&lt;/p&gt;

&lt;p&gt;Time for a demo:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;shell@android:/ $ getenforce
getenforce
Permissive
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here's where I hit the button to go into enforcing&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;shell@android:/ $ getenforce
getenforce
Could not get enforcing status:  Permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So far, so good; to get out of enforcing just reboot. Fun fact #3, there is no way to keep enforcing persistent across reboots. I guess I'll have to write a service or something that runs at boot.&lt;/p&gt;

&lt;h2&gt;So, what can we do?&lt;/h2&gt;

&lt;p&gt;Okay, I found an interface that lets me load a new policy... at least I thought I did.&lt;/p&gt;

&lt;p&gt;I updated the admin app and tried pushing policy, &quot;success&quot; it says... how do I test though? Pushing a random policy and going into enforcing is likely to cause all manners of breakage so I spent a couple hours writing a &lt;a href=&quot;https://bitbucket.org/joshua_brindle/sepolicy-inject/&quot;&gt;rule injector&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Run that baby:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;joshua@QuarkZilla:~/sepolicy-inject$ sesearch -A -s shell -t selinuxfs -c file sepolicy                                    
Found 1 semantic av rules:
   allow appdomain fs_type : file getattr ; 

joshua@QuarkZilla:~/sepolicy-inject$ ./sepolicy-inject -s shell -t selinuxfs -c file -p open -P sepolicy -o sepolicy2      
joshua@QuarkZilla:~/sepolicy-inject$ ./sepolicy-inject -s shell -t selinuxfs -c file -p read -P sepolicy2 -o sepolicy

joshua@QuarkZilla:~/sepolicy-inject$ sesearch -A -s shell -t selinuxfs -c file sepolicy                              
Found 2 semantic av rules:
   allow shell selinuxfs : file { read open } ; 
   allow appdomain fs_type : file getattr ;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;woohoo!&lt;/p&gt;

&lt;p&gt;Let's test this out. Push the policy with the interface and test it out. Fail. Hrm...&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;shell@android:/ $ getenforce
getenforce
Could not get enforcing status:  Permission denied
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Well, we don't have denials so this is tricky. Let's manually load the policy. The policy &lt;em&gt;was&lt;/em&gt; put in /data/security by the interface, it just wasn't loaded:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@android:/ # setprop selinux.reload_policy 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;How about now?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;shell@android:/ $ getenforce
getenforce
Enforcing
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Success. Well, at least I know my tool works :)&lt;/p&gt;

&lt;p&gt;There are other interfaces to push down other policy files, such as seapp_contexts (fun fact #4: that interface actually misnames the target file as &quot;seapps_context&quot; ... sigh) but since they aren't reloaded there isn't much value there. Libselinux will read a properly named seapp_contexts from /data/security at boot time so you can put one there manually. &lt;del&gt;mac_permissions.xml &lt;em&gt;does not&lt;/em&gt; get read from /data/security, so adding signatures won't work there. Luckily that file is on /system which we are already committed to modifying.&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;Correction: mac_permissions.xml does get read from /data/security at boot time. MMAC is not in enforcing by default but can be put into enforcing mode:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;adb shell su -c &quot;setprop persist.mmac.enforce 1&quot;
adb reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;Here's the bottom line:&lt;/p&gt;

&lt;p&gt;The Good:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SE for Android is present&lt;/li&gt;
&lt;li&gt;SE for Android can be turned to enforcing and the phone doesn't catch on fire&lt;/li&gt;
&lt;li&gt;There are APIs for updating policies and setting enforcing&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The Bad:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enforcing not on by default&lt;/li&gt;
&lt;li&gt;APIs don't actually work&lt;/li&gt;
&lt;li&gt;Setting enforcing does not persist across reboots&lt;/li&gt;
&lt;li&gt;No denials&lt;/li&gt;
&lt;li&gt;No way to set back to permissive programatically&lt;/li&gt;
&lt;li&gt;Strange side effects like requiring max log level&lt;/li&gt;
&lt;li&gt;Root required to do anything with SE for Android&lt;/li&gt;
&lt;li&gt;No way to get or set SELinux booleans&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The Ugly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;These APIs are actually not public, meaning they can go away or change at any point&lt;/li&gt;
&lt;li&gt;Without vulnerabilities available users won't be able to secure their devices...&lt;/li&gt;
&lt;li&gt;Real SE for Android development on the GS4 means rerolling the kernel and boot image&lt;/li&gt;
&lt;li&gt;If the management APIs are any indication the SE for Android support is still half-baked on the GS4&lt;/li&gt;
&lt;li&gt;SE for Android isn't actually a supported feature on standard GS4's, technically it is a Knox feature, and we don't have Knox yet&lt;/li&gt;
&lt;/ol&gt;</description>
	<pubDate>Thu, 27 Jun 2013 05:00:00 +0000</pubDate>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 19 Part 5: gssproxy</title>
	<guid>http://danwalsh.livejournal.com/65467.html</guid>
	<link>http://danwalsh.livejournal.com/65467.html</link>
	<description>&lt;p&gt;On Friday, I was asked to quickly write policy for the new gssproxy daemon which was added to Fedora 19.&amp;nbsp; Investigating it, I found I had a new security feature blog, I had to write.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/gss-proxy&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Fedora 19 is adding the gssproxy daemon.&amp;nbsp; gssproxy will be replacing rpc.svcgssd&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;gssproxy is a a proxy daemon for the GSS-API, which is a higher level API used mainly in Kerberized applications.&lt;br /&gt;&lt;br /&gt;File systems services like CIFS, (samba), NFS and AFS make lots of kerberos encryption calls within the kernel, using keying material handed into the kernel.&amp;nbsp; But the initialization and creation, renewing and cleaning up of credential caches, really should be handled in user space.&amp;nbsp; gssproxy is the daemon to handle this. &lt;br /&gt;&lt;br /&gt;A useful feature of gssproxy will eliminate the need to daemons that use kerberos keytabs from needing to read them directly.&amp;nbsp; Currently if you set up an Apache server with kerberos, it needs full read access to the keytab file, allowing it to see the keying material.&amp;nbsp; If Apache gets hacked, the hacker would get full access to the secrets.&amp;nbsp; With gssproxy developers could setup Apache to talk to gssproxy and allow it to handle the keytab file, eliminating this need.&amp;nbsp; This will allow my team to alter the SELinux policy and prevent the Apache daemon from being able to read keying information directly and force it to talk to the daemon.&lt;br /&gt;&lt;br /&gt;Another cool feature, explained to me by Simo Sorce,&amp;nbsp; is to take an application that needs kerberos access to a nfs share, but does not know anything about kerberos or the gssapi.&amp;nbsp; Currently the way you handle this is to wrap an init scripts with things like k5start so the application has a keytab and a credential cache regularly refreshed.&amp;nbsp; Then rpc.gssd would have to look in /tmp for a ccache to use for the application user and allow the application authenticated access to the secure nfs share.&lt;br /&gt;&lt;br /&gt;With gssproxy you will not longer need to do this.&amp;nbsp; All you need to do is drop a keytab in &lt;i&gt;&lt;span&gt;/v&lt;/span&gt;ar/lib/gssproxy/clients&lt;span&gt;/&lt;/span&gt;&lt;/i&gt;&amp;lt;id&amp;gt;.keytab and the gssproxy will automatically initiate a connection when nfs client needs it. Advantages of this method:&lt;br /&gt;1. No more wrapping of init scripts&lt;br /&gt;2. Privilege separation, the app has no access to the keytab&lt;br /&gt;3. Initiate on request, if the app never needs nfs we never initiate or renew tickets unnecessarily&lt;/p&gt;&lt;p&gt;gssproxy can be setup to renew Kerberos Tickets from keytabs for long running jobs, eliminating a lot of previous hacks.&lt;/p&gt;</description>
	<pubDate>Mon, 03 Jun 2013 13:53:28 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 19 Part 4: openssh 6.2 better support for multi-factor authentication</title>
	<guid>http://danwalsh.livejournal.com/65054.html</guid>
	<link>http://danwalsh.livejournal.com/65054.html</link>
	<description>&lt;div&gt;&lt;span&gt;We are beginning to see the end of passwords as the only means of authenticating yourself to a system, hopefully.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;Fedora 19 will be our first release of Openssh 6.2, which has introduced the AuthenticationMethods setting. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;This feature allows you to require multiple different types of authorization to get into a system.&amp;nbsp; For example it is very easy to require&amp;nbsp; both an ssh public key and a password to login.&amp;nbsp;&amp;nbsp; &lt;/span&gt;If you don't have the public key, you will never get to the password prompt.&lt;br /&gt;&lt;br /&gt;In previous Fedora releases,&lt;span&gt; there were some tricky&amp;nbsp; ways to do multi-factor using pam but this allows for more&amp;nbsp; combinations, and easier setup.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;I found this blog that does a great job of describing the feature.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;a href=&quot;https://blog.flameeyes.eu/2013/03/openssh-6-2-adds-support-for-two-factor-authentication&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;https://blog.flameeyes.eu/2013/03/openssh-6-2-adds-support-for-two-factor-authentication&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Bottom line if you have a critical server, you want a user to prove multiple ways that he is worthy to get on the system.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>
	<pubDate>Sat, 01 Jun 2013 09:51:10 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: How do I tell what would be allowed by a boolean?</title>
	<guid>http://danwalsh.livejournal.com/64779.html</guid>
	<link>http://danwalsh.livejournal.com/64779.html</link>
	<description>&lt;p&gt;I received and Email today that asked the following question:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I still fail to understand the difference between&amp;nbsp; httpd_can_network_connect_db and httpd_can_network_connect. Some people say the former allows connections to known database ports. My question are:&lt;br /&gt;&lt;br /&gt;What are these ports? Where are the corresponding policy defined? I found many&amp;nbsp; .pp files deeply under /etc/selinux, and I feel sorry that they are binary which are almost impossible to interpret, so where can I find the the source files for the compiled policy, and what is the language to define policies?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You could use the semanage command for how the booleans are described.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; semanage boolean -l | grep httpd_can_network_connect&lt;br /&gt;httpd_can_network_connect_db&amp;nbsp;&amp;nbsp; (off&amp;nbsp; ,&amp;nbsp; off)&amp;nbsp; Allow HTTPD scripts and modules to connect to databases over the network.&lt;br /&gt;httpd_can_network_connect&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (off&amp;nbsp; ,&amp;nbsp; off)&amp;nbsp; Allow HTTPD scripts and modules to connect to the network using TCP.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The best answer to this is to look at the sesearch and seinfo tools and on newer (Fedora/RHEL7) systems sepolicy command.&amp;nbsp; Also look at the man pages that have been generated. &lt;br /&gt;&lt;br /&gt;&lt;span&gt;man httpd_selinux&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sesearch and seinfo are available in the setools-cmdline package.&amp;nbsp; sepolicy is in policycoreutils-python package.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;httpd_can_network_connect_db&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt; sesearch -A -s httpd_t -b httpd_can_network_connect_db -p name_connect&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t postgresql_port_t : tcp_socket { recv_msg send_msg name_connect } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t mssql_port_t : tcp_socket name_connect ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t oracle_port_t : tcp_socket name_connect ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t mysqld_port_t : tcp_socket { recv_msg send_msg name_connect } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t gds_db_port_t : tcp_socket name_connect ; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The command above reads in the policy and prints out what happens when you enable the &lt;b&gt;&lt;span&gt;httpd_can_network_connect_db&lt;/span&gt;&lt;/b&gt; boolean.&amp;nbsp; We further restrict the search to see how it affects the &lt;b&gt;httpd_t&lt;/b&gt;, apache, process type with the &lt;b&gt;name_connect&lt;/b&gt; access.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sesearch tells us that turning on httpd_can_network_connect_db would allow the httpd_t domain to connect to tcp ports labeled postgresql_port_t, mssql_port_t, oracle_port_t, mysqld_port_t, gds_db_port_t.&amp;nbsp; You can use seinfo to turn these port types into port definitions. &lt;u&gt; semanage port -l&lt;/u&gt; would also work.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; seinfo&amp;nbsp; --port | grep -e postgresql_port_t -e mysqld_port_t -e oracle_port_t -e gds_db_port_t | grep tcp&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 3050 system_u:object_r:gds_db_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 1186 system_u:object_r:mysqld_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 3306 system_u:object_r:mysqld_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 63132-63164 system_u:object_r:mysqld_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 1521 system_u:object_r:oracle_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 2483 system_u:object_r:oracle_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 2484 system_u:object_r:oracle_port_t:s0&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;portcon tcp 5432 system_u:object_r:postgresql_port_t:s0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; sepolicy network -t postgresql_port_t&lt;br /&gt;postgresql_port_t: tcp: 5432&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;httpd_can_network_connect &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; sesearch -A -s httpd_t -b httpd_can_network_connect -p name_connect&lt;br /&gt;Found 1 semantic av rules:&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow httpd_t port_type : tcp_socket name_connect ; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The above command shows that httpd_can_network_connect allows httpd_t to connect to all tcp socket types that have the port_type attribute.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; seinfo -aport_type -x | wc -l&lt;br /&gt;245&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Using seinfo above would show you that port_type is the attribute of all port types, meaning that turning on the httpd_can_network_connect boolean, allows the httpd_t domain to connect to ALL tcp network ports.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Bottom Line&lt;/b&gt;  httpd_can_network_connect_db allows httpd_t to connect to an additional 10 ports while httpd_can_network_connect adds thousands.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description>
	<pubDate>Tue, 28 May 2013 15:50:39 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: sandbox -X in Fedora 19 is resizeable, finally!</title>
	<guid>http://danwalsh.livejournal.com/64558.html</guid>
	<link>http://danwalsh.livejournal.com/64558.html</link>
	<description>Thomas Liu worked as an intern for me a few years ago and wrote a patch for Xephyr to allow a Xepher window to be resizeable. &lt;br /&gt;&lt;br /&gt;We shipped this patch in RHEL6 and waited for it to get upstream so we could pull it in Fedora.&amp;nbsp; Well as of today a Xephr&lt;br /&gt;&lt;pre&gt;
 xorg-x11-server-1.14.1-2.fc19 has been pushed into Fedora 19, and we have support for resizing sandbox in Fedora.

Now rumors have it Labelled NFS may finally reach upstream, that would truly be remarkable...
&lt;/pre&gt;</description>
	<pubDate>Sun, 26 May 2013 11:18:55 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 19 Part 3: Hard Link/Soft Link Protection</title>
	<guid>http://danwalsh.livejournal.com/64493.html</guid>
	<link>http://danwalsh.livejournal.com/64493.html</link>
	<description>It is surprising to most people who understand Linux and Unix that you are allowed to Hard Link to any file on the OS as long as it is on the same file system.&lt;br /&gt;Hard linking means that you can put the same Inode number into two different directories.&amp;nbsp; Prior to Fedora 19, a normal user would be allowed to do something like:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; ln /etc/shadow ~/shadow&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Even though the /etc/shadow is owned by root.&amp;nbsp; Then if the user tricked an administrator into doing something like&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# chown -R&amp;nbsp; dwalsh:dwalsh ~&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This would cause the /etc/shadow file to be owned by dwalsh.&lt;br /&gt;&lt;br /&gt;Similarly in the past hackers have tricked privileged applications to follow hard and soft links, created in a user account to compromise the system.&lt;br /&gt;&lt;br /&gt;Kees Cook wrote some patches for the linux kernel that allows distributions to disable this behaviour.&lt;br /&gt;&lt;br /&gt;Here is Kees Description of the benefits of the patch:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
&lt;span&gt;This patch adds symlink and hardlink restrictions to the Linux VFS.

Symlinks:

A long-standing class of security issues is the symlink-based time-of-check-time-of-use race, most commonly seen in world-writable
directories like /tmp. The common method of exploitation of this flaw is to cross privilege boundaries when following a given symlink (i.e. a
root process follows a symlink belonging to another user). For a likely incomplete list of hundreds of examples across the years, please see:
http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=/tmp

The solution is to permit symlinks to only be followed when outside a sticky world-writable directory, or when the uid of the symlink and
follower match, or when the directory owner matches the symlink's owner.

&amp;lt;snip&amp;gt;

Hardlinks:

On systems that have user-writable directories on the same partition as system files, a long-standing class of security issues is the
hardlink-based time-of-check-time-of-use race, most commonly seen in world-writable directories like /tmp. The common method of exploitation
of this flaw is to cross privilege boundaries when following a given hardlink (i.e. a root process follows a hardlink created by another
user). Additionally, an issue exists where users can &amp;quot;pin&amp;quot; a potentially vulnerable setuid/setgid file so that an administrator will not actually
upgrade a system fully.

The solution is to permit hardlinks to only be created when the user is already the existing file's owner, or if they already have read/write
access to the existing file.

Many Linux users are surprised when they learn they can link to files they have no access to, so this change appears to follow the doctrine
of &amp;quot;least surprise&amp;quot;. Additionally, this change does not violate POSIX, which states &amp;quot;the implementation may require that the calling process
has permission to access the existing file&amp;quot;[1].

This change is known to break some implementations of the &amp;quot;at&amp;quot; daemon, though the version used by Fedora and Ubuntu has been fixed[2] for
a while. Otherwise, the change has been undisruptive while in use in Ubuntu for the last 1.5 years.

&amp;lt;snip&amp;gt;&lt;/span&gt;

This feature is turned on by default in /usr/lib/sysctl.d/50-default.conf in F19.

grep fs /usr/lib/sysctl.d/50-default.conf 
fs.protected_hardlinks = 1
fs.protected_symlinks = 1

There was some concern that this could cause problems in applications that expect this behaviour, so it can be disabled.
But overall, I think it is a positive feature for Fedora.

&lt;/pre&gt;</description>
	<pubDate>Wed, 22 May 2013 17:42:52 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: SELinux is a labeling system. First thought should be &quot;Is there a label that would make this work?&quot;</title>
	<guid>http://danwalsh.livejournal.com/64142.html</guid>
	<link>http://danwalsh.livejournal.com/64142.html</link>
	<description>On the SELinux mail list today, someone asked:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span&gt;I want to store the logs from openswan into a different file ( /var/log/ipsec ) than the default. For this purpose I added &lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span&gt;plutostderrlog=/var/log/ipsec&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span&gt;to ipsec.conf.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; As long as I keep the server in permissive mode, openswan starts OK. If, however, I switch to enforcing, the daemon refuses to start with the following error message displayed in the console:&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span&gt;ipsec_setup: Starting Openswan IPsec U2.6.32/K3.0.78-1.el6.elrepo.x86_64...&lt;br /&gt;ipsec_setup: Cannot write to &amp;quot;/var/log/ipsec&amp;quot;.&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span&gt; &amp;nbsp;&amp;nbsp; The audit log does not record anything useful so I tried to switch dontaudit to off and see if anything useful comes out. After running audit2allow and a bit of trial and error I came out with the following custom policy :&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;span&gt;module myipsec 1.0;&lt;br /&gt;require {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type ipsec_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type var_log_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class file { write ioctl getattr append };&lt;br /&gt;}&lt;br /&gt;#============= ipsec_mgmt_t ==============&lt;br /&gt;allow ipsec_mgmt_t var_log_t:file write;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;span&gt; &amp;nbsp;&amp;nbsp; The above policy worked for me but I am wondering if it is OK &lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The problem is the administrator decided to add policy that allows ipsec_mgmt_t to write any file labeled var_log_t.&amp;nbsp; A hacked ipsec_mgmt could now overwrite any log file on the system labeled var_log_t, including /var/log/messages.&amp;nbsp; var_log_t is the default label for ANY file in /var/log directory that does not&amp;nbsp; have SELinux policy controlling it.&amp;nbsp; Also remember &amp;quot;write&amp;quot; access is always more dangerous then &amp;quot;append&amp;quot; access, since &amp;quot;write&amp;quot; allows you to truncate a file, destroying evidence, versus append to the end of a file.&lt;br /&gt;&lt;br /&gt;In the paper I wrote a few years ago,&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;a href=&quot;http://people.fedoraproject.org/%7Edwalsh/SELinux/Presentations/selinux_four_things.pdf&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;span&gt;&lt;strong&gt;What is SELinux trying to tell me?&lt;br /&gt;The 4 key causes of SELinux errors.&lt;/strong&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I explain that adding policy should be your third option, not your first.&amp;nbsp; In this case Dominic Grift pointed out the admin, that changing the label of the target would fix the problem and not involve adding custom policy.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;semanage fcontext -a -t ipsec_log_t &amp;quot;/var/log/ipsec.*&amp;quot;&lt;br /&gt;restorecon -v /var/log/ipsec &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By telling SELinux that the content in the /var/log/ipsec log file was ipsec_log_t, you solve your problem and end up with the same security you had before the change.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Think Labels First...&lt;/b&gt;</description>
	<pubDate>Mon, 20 May 2013 13:03:01 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>James Morris: Slides from my Security Subsystem Overview at LinuxCon Japan 2012</title>
	<guid>http://blog.namei.org/?p=563</guid>
	<link>http://blog.namei.org/2013/05/13/slides-from-my-security-subsystem-overview-at-linuxcon-japan-2012/</link>
	<description>&lt;p&gt;Whoops.  Looks like I forgot to post my slides from last year&amp;#8217;s &lt;a href=&quot;http://events.linuxfoundation.org/archive/2012/linuxcon-japan&quot;&gt;LinuxCon Japan&lt;/a&gt; talk on the Linux kernel security subsystem.&lt;/p&gt;
&lt;p&gt;Here they are:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://namei.org/presentations/kernel-security-state-linuxconjp-2012b.pdf&quot;&gt;http://namei.org/presentations/kernel-security-state-linuxconjp-2012b.pdf&lt;br /&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ll be giving an &lt;a href=&quot;http://linuxconcloudopenjapan2013.sched.org/event/296bcc789f3fe132dacafb624466c999?iframe=no&amp;#038;w=900&amp;#038;sidebar=yes&amp;#038;bg=no#.UZDKy4KaSxA&quot;&gt;update&lt;/a&gt; at the upcoming &lt;a href=&quot;http://events.linuxfoundation.org/events/linuxcon-japan&quot;&gt;LinuxCon Japan&lt;/a&gt; in Tokyo in a couple of weeks.&lt;/p&gt;</description>
	<pubDate>Mon, 13 May 2013 11:14:29 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>James Morris: Linux Security Summit 2013 (New Orleans) – Call for Participation</title>
	<guid>http://blog.namei.org/?p=561</guid>
	<link>http://blog.namei.org/2013/05/06/linux-security-summit-2013-new-orleans-call-for-participation/</link>
	<description>&lt;p&gt;The CFP for the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2013&quot;&gt;2013 Linux Security Summit&lt;/a&gt; has been &lt;a href=&quot;http://marc.info/?l=linux-security-module&amp;#038;m=136783173311478&amp;#038;w=2&quot;&gt;announced&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The summit will be held across the 19th and 20th of September in New Orleans, co-located again with &lt;a href=&quot;https://events.linuxfoundation.org/events/linuxcon&quot;&gt;LinuxCon&lt;/a&gt; and &lt;a href=&quot;http://www.linuxplumbersconf.org/2013/&quot;&gt;Linux Plumbers&lt;/a&gt;.   Note that presenters and attendees at LSS must be registered as LinuxCon attendees.&lt;/p&gt;
&lt;p&gt;We&amp;#8217;ll be following a similar format to &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2012&quot;&gt;last year&lt;/a&gt;, with a day of refereed presentations, followed by subsystem updates and break-out sessions on the second day.  We&amp;#8217;ll probably finish up around lunchtime on the Friday for people needing to head home that day, but check the final schedule for details once it&amp;#8217;s published.&lt;/p&gt;
&lt;p&gt;The CFP is open until &lt;strong&gt;14th June&lt;/strong&gt;, with speaker notifications to be posted by 21st June.&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;ve been doing cool and interesting work in Linux security, be sure to submit a proposal!&lt;/p&gt;</description>
	<pubDate>Mon, 06 May 2013 09:59:59 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Joshua Brindle: SE Android and the motochopper exploit</title>
	<guid>http://securityblog.org/2013/04/30/se-android-and-the-motochopper-exploit</guid>
	<link>http://securityblog.org/2013/04/30/SE-Android-and-the-motochopper-exploit</link>
	<description>&lt;h3&gt;SE Android prevents first exploit against commercial phone&lt;/h3&gt;

&lt;p&gt;That should have been the title of this post, but alas it is not.&lt;/p&gt;

&lt;p&gt;By now you may know that the Samsung Galaxy S4 is the first commercial device shipped with SE Android included.&lt;/p&gt;

&lt;p&gt;Included, but not enforcing. If you are familiar with SELinux you know that there is a developer mode (also called permissive) that audits access that would have been denied, but does not actually deny them. This is very useful for developing your policies without having to interate through accesses one at a time (this takes a very very long time with complex software).&lt;/p&gt;

&lt;p&gt;The standard way of writing policy is to use permissive mode to run an application, then look at the logs and figure out what the access patterns are, what should be labeled what, write the policy, then try again. Eventually you go into enforcing mode when you are ready to send your product to production.&lt;/p&gt;

&lt;p&gt;That is the theory, anyway.&lt;/p&gt;

&lt;h3&gt;History lesson&lt;/h3&gt;

&lt;p&gt;Back in the Fedora 2 days (that is 2004) SELinux shipped in enforcing, with a strict policy. It was a catastrophy. Linux users who were accustumed to cat'ing /dev/cdrom, for whatever reason, became angry that they couldn't do it all of a sudden. The targeted policy was then created which would resrtict only high-threat applications, like apache and ssh. Most recently Dan Walsh, over at Red Hat, introduces new application policies to the masses in permissive mode (note, SELinux supports permissive mode per-type, not just system wide) and collects denials from users for a few months, to figure out how people use the applications, since he can't be an expert at every single one. He then switches the policy to enforcing when the policy has been fleshed out.&lt;/p&gt;

&lt;h3&gt;Lost Opportunity&lt;/h3&gt;

&lt;p&gt;This is the first commercial phone with SE Android; there is a huge amount of risk to going into the wild in enforcing. I don't know if they were nervous that something like Fedora 2 would happen or it was carrier certification delays or perhaps they just don't think SE Android should be on unless explicitely requested. No matter what the reason, a huge opportunity to show the world the power of SE Android was lost. No worries, though, there will be another opportunity.&lt;/p&gt;

&lt;h3&gt;The Exploit&lt;/h3&gt;

&lt;p&gt;Ok, lets look at this exploit and see what would have happened. I don't happen to have a Galaxy S4 in front of me, but the stock recovery image has everything I need to look at this.&lt;/p&gt;

&lt;p&gt;First, the &lt;a href=&quot;http://forum.xda-developers.com/showthread.php?t=2252248&quot;&gt;exploit&lt;/a&gt; is motochopper and was originally written for a Motorola. The reason it works on the S4 is that the phones have similar chipsets. The chipset vendors provide kernel patches, drivers, userspace components, etc to the OEM's. The OEM's then integrate that into their version of Android, normally what Google gives them + their extras. In this case the vulnerability was in the code provided by the chipset, it had a world writable fb0 device node, that allowed an mmap() of kernel memory.&lt;/p&gt;

&lt;p&gt;Without a phone in front of me, how on earth could I know that the exploit wouldn't have worked, you ask?&lt;/p&gt;

&lt;p&gt;Edit: The above isn't quiet accurate. The vulnerability &lt;a href=&quot;http://forum.xda-developers.com/showthread.php?p=40873964&quot;&gt;was a bug in the mainline framebuffer&lt;/a&gt; rather than in a specific chipset, which means it may affect even more devices.&lt;/p&gt;

&lt;h3&gt;The Policy&lt;/h3&gt;

&lt;p&gt;On the recovery ROM are 2 files that I can use to mount this investigation. I know the exploit mmap()'s /dev/graphics/fb0 so first I want to know what that would be labeled:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ grep /dev/graphics file_contexts 
/dev/graphics(/.*)?     u:object_r:graphics_device:s0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, /dev/graphics/fb0 (and indeed everything under the graphics directory) would be labeled graphics_device.&lt;/p&gt;

&lt;p&gt;On SE Android the type you get when you use adb shell is shell. So, next I need to look for accesses between shell and graphics_device:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sesearch --all -s shell -t graphics_device sepolicy       
Found 7 semantic av rules:
   allow appdomain dev_type : file getattr ; 
   allow appdomain dev_type : dir { ioctl read getattr search open } ; 
   allow appdomain dev_type : lnk_file { read getattr } ; 
   allow appdomain dev_type : chr_file getattr ; 
   allow appdomain dev_type : blk_file getattr ; 
   allow appdomain dev_type : sock_file getattr ; 
   allow appdomain dev_type : fifo_file getattr ; 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Indeed there is no write permission so the mmap attempt to write to kernel memory would fail. This only covers the adb shell case though, and that is typically done by the owner of the device. Granted that this makes problems for BYOD but the more interesting question is, could malicious apps exploit this?&lt;/p&gt;

&lt;p&gt;In the seapp_contexts file it shows that third party apps will be labeled untrusted_app, so lets look at that:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sesearch --all -s untrusted_app -t graphics_device sepolicy      
Found 7 semantic av rules:
   allow appdomain dev_type : file getattr ; 
   allow appdomain dev_type : dir { ioctl read getattr search open } ; 
   allow appdomain dev_type : lnk_file { read getattr } ; 
   allow appdomain dev_type : chr_file getattr ; 
   allow appdomain dev_type : blk_file getattr ; 
   allow appdomain dev_type : sock_file getattr ; 
   allow appdomain dev_type : fifo_file getattr ; 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Again, no dice. Apps can stat() the file but not read or write it. The same goes for the browser (browser_app) and even platform_app, which includes all of the apps included on the device from Samsung and Google.&lt;/p&gt;

&lt;p&gt;But which types &lt;em&gt;can&lt;/em&gt; write to the file? Good question, SE Android may be blocking all of this access but we know the vulnerability is there, we should find out what on the system is able to exploit it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sesearch -t graphics_device --allow -c chr_file -p write sepolicy 
Found 7 semantic av rules:
   allow system graphics_device : chr_file { ioctl read write getattr lock append open } ; 
   allow system_app graphics_device : chr_file { ioctl read write getattr lock append open } ; 
   allow mediaserver graphics_device : chr_file { ioctl read write getattr lock append open } ; 
   allow unconfineddomain dev_type : chr_file { ioctl read write create getattr setattr lock relabelfrom relabelto append unlink link rename execute swapon quotaon mounton execute_no_trans entrypoint execmod open audit_access } ; 
   allow mm-pp-daemon graphics_device : chr_file { ioctl read write getattr lock append open } ; 
   allow surfaceflinger graphics_device : chr_file { ioctl read write getattr lock append open } ; 
   allow bintvoutservice graphics_device : chr_file { ioctl read write getattr lock append open } ; 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Well, system and system_app, which are pretty powerful either way, granted it is an escalation if you can compromise them. unconfineddomain (hrm.. whats that?), the seapp_contexts file doesn't have any entries for it, so presumably it is there for MDM/MAM vendors to run unconfined apps if they choose to. surfaceflinger obviously needs to be able to write to the graphics device, and possibly mediaserver. bintvoutservice probably does too, and I don't know what mm-pp-domain is, probably a Qualcomm specific thing.&lt;/p&gt;

&lt;p&gt;So, there are definitely vectors to get at this, but they involve compromising protected apps (in a real security analysis we'd keep backtracking to see what vectors there are to attack system and system_app, for example) but this exploit wouldn't have been pulled off nearly as easily as it was, if SE Android were enforcing.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Exploits like this are scary, not because of owners that want to root their phones but because, if an owner can do it, it is highly likely that an adversary can. These mobile devices are our lives, they have business data on them, they have private data, and they can be used to steal your money in various ways (such as premium SMS's). There will not be a shortage of vulnerabilities until OEM's and users alike start thinking from a security mindset. The tools are there, no OEM has an excuse not to use them.&lt;/p&gt;

&lt;p&gt;It may not be a bad idea to set SE Android into enforcing once you've rooted your phone, so that malicious apps don't take advantage of the same vulnerability, if I get my hands on a GS4 I'll blog about doing that.&lt;/p&gt;</description>
	<pubDate>Tue, 30 Apr 2013 05:00:00 +0000</pubDate>
</item>
<item>
	<title>Dan Walsh: SELinux &amp;amp; PaaS: Deep Dive on Multi-tenancy, Containers &amp;amp; Security with Dan Walsh, Red Hat</title>
	<guid>http://danwalsh.livejournal.com/63915.html</guid>
	<link>http://danwalsh.livejournal.com/63915.html</link>
	<description>&lt;h3&gt;&lt;a dir=&quot;ltr&quot; href=&quot;https://www.youtube.com/watch?v=VaxkrSpBr6M&quot; src=&quot;en&quot; title=&quot;SELinux &amp;amp; PaaS: Deep Dive on Multi-tenancy, Containers &amp;amp; Security with Dan Walsh, Red Hat&quot; rel=&quot;nofollow&quot;&gt;SELinux &amp;amp; PaaS: Deep Dive on Multi-tenancy, Containers &amp;amp; Security with Dan Walsh, Red Hat&lt;/a&gt;&lt;/h3&gt;Last week I went to Portland, OR for the &lt;a href=&quot;https://www.openshift.com/community&quot; rel=&quot;nofollow&quot;&gt;OpenShift Origin&lt;/a&gt; Day.&lt;br /&gt;I gave a talk about SELinux and &lt;a href=&quot;http://www.openshift.com&quot; rel=&quot;nofollow&quot;&gt;OpenShift&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The talk covered&amp;nbsp; the importance of MAC and container/namespaces when using a multi-tenant environment like OpenShift. &lt;br /&gt;&lt;br /&gt;The talk also covers enhancements I want to make to OpenShift gears (containers) and additional features that we will be adding.&lt;br /&gt;&lt;br /&gt;The &lt;a href=&quot;http:// https://www.youtube.com/watch?v=VaxkrSpBr6M&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;video&lt;/a&gt; has been posted to youtube.&lt;br /&gt;&lt;br /&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://danwalsh.livejournal.com/data/rss&quot; title=&quot;&quot; /&gt;</description>
	<pubDate>Tue, 23 Apr 2013 20:52:39 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: What is the differences between user_home_dir_t  and user_home_t</title>
	<guid>http://danwalsh.livejournal.com/63586.html</guid>
	<link>http://danwalsh.livejournal.com/63586.html</link>
	<description>I just saw this email on the SELinux Fedora Mailing list and figured I would try to answer it here.&lt;br /&gt;&lt;br /&gt;Lets look at the labels of content in my&amp;nbsp; home directory.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; ls -lZd / /home /home/dwalsh /home/dwalsh/.ssh /home/dwalsh/.emacs /home/dwalsh/public_html&lt;br /&gt;dr-xr-xr-x. root&amp;nbsp;&amp;nbsp; root&amp;nbsp;&amp;nbsp; system_u:object_r:root_t:s0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /&lt;br /&gt;drwxr-xr-x. root&amp;nbsp;&amp;nbsp; root&amp;nbsp;&amp;nbsp; system_u:object_r:home_root_t:s0 /home&lt;br /&gt;drwx------. dwalsh dwalsh unconfined_u:object_r:user_home_dir_t:s0 /home/dwalsh&lt;br /&gt;-rw-r--r--. dwalsh dwalsh unconfined_u:object_r:user_home_t:s0 /home/dwalsh/.emacs&lt;br /&gt;drwxr-xr-x. dwalsh dwalsh unconfined_u:object_r:httpd_user_content_t:s0 /home/dwalsh/public_html&lt;br /&gt;drwx------. dwalsh dwalsh unconfined_u:object_r:ssh_home_t:s0 /home/dwalsh/.ssh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As we go through the different files and directories that make up my home directory we see multiple SELinux labels.&amp;nbsp; Notice the files that are owned by me have an SELinux user of staff_u.&amp;nbsp; On most systems these would be labeled unconfined_u.&amp;nbsp; In SELinux every file that is created by a process running as unconfined_u will get the unconfined_u SELinux user placed on the file label.&amp;nbsp; Similarly staff_u will get staff_u, ...&lt;br /&gt;&lt;br /&gt;This component is ignored on most SELinux systems, system_u on /home here is the default label set by restorecon or at install time.&lt;br /&gt;&lt;br /&gt;object_r is just a place holder.&amp;nbsp; For all SELinux systems other then some experimental systems, every object on the file system gets labeled object_r.&lt;br /&gt;&lt;br /&gt;The last field is all s0.&amp;nbsp; This is the MCS or MLS label depending on your policy.&amp;nbsp; On most systems this will be s0 (SystemLow)&lt;br /&gt;&lt;br /&gt;SELinux is a type enforcement system, and the interesting parts is the types.&amp;nbsp; Lets look at each directory/file above and the types associated with them.&lt;ul&gt;&lt;br /&gt;&lt;li&gt;/ is labeled with the root_t type.&amp;nbsp; This should be the only object on the system with the root_t type, if you have other objects on the computer with this label, then you were probably running in permissive mode and a confined process created it, you need to fix the labels.&amp;nbsp; The main purpose of root_t is for policy writers to define transitions. for system applications that are going to create content in /.&amp;nbsp; For example boot flags will get created with etc_runtime_t.&amp;nbsp; Random directories created in / will get labeled default_t.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;span&gt;#&amp;nbsp; touch /.autorelabel; ls -lZ /.autorelabel&lt;br /&gt;-rw-r--r--. root root unconfined_u:object_r:etc_runtime_t:s0 /.autorelabel&lt;br /&gt;# mkdir /foobar; ls -ldZ /foobar&lt;br /&gt;drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /foobar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; One thing to note about default_t is that NO confined apps are allowed to read content labeled default_t, because we have no idea what kind of content would be in this directory.&amp;nbsp; Invariably when some one creates a new directory in / without setting the labels, SELinux will have issues.&amp;nbsp; If foobar above contained apache content you would need to execute the following in order to allow apache to read the content.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage fcontext -a -t httpd_sys_content_t '/foobar(/.*)?'&lt;br /&gt;# restorecon -R -v /foobar&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;/home is labeled with the&lt;b&gt; home_root_t &lt;/b&gt;type.&amp;nbsp; home_root_t is basically used for the toplevel or root directory for homedirs. &amp;nbsp; It's main purpose is to be used by policy for applications that need to create home directories or file system quota files.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;span&gt;# sesearch -T -t home_root_t&lt;br /&gt;Found 10 semantic te rules:&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition quota_t home_root_t : file quota_db_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition sysadm_t home_root_t : dir user_home_dir_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition firstboot_t home_root_t : dir user_home_dir_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition useradd_t home_root_t : dir user_home_dir_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition lsassd_t home_root_t : dir user_home_dir_t;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition oddjob_mkhomedir_t home_root_t : dir user_home_dir_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition smbd_t home_root_t : dir user_home_dir_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; type_transition automount_t home_root_t : dir automount_tmp_t; &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; /home/dwalsh is labeled with the user_home_dir_t type.&amp;nbsp; &amp;nbsp; Policy writers use this type to write transition rules to get content labeled correctly within the homedir.&amp;nbsp; Confined applications that create content in a users home directory need transition rules to create the content with the proper label. For example if you use ssh-copy-id on the remote machine, this triggers sshd to create the /home/dwalsh/.ssh directory, which we want labeled ssh_home_t, to protect the content.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;span&gt;# sesearch -T -s sshd_t -t user_home_dir_t | grep &amp;quot;\.ssh&amp;quot;&lt;br /&gt;type_transition sshd_t user_home_dir_t : dir ssh_home_t &amp;quot;.ssh&amp;quot;; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch -T -s staff_t -t user_home_dir_t |wc -l&lt;br /&gt;118&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note there are over 118 transition rules for a confined user creating content in his home directory.&amp;nbsp; With the advent of file name transition rules, we have exploded the number of these transitions in order to get proper labeling in the users home dir.&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;/home/dwalsh/.emacs is labeled user_home_t, which is the default label for all content in a users home directory.&amp;nbsp; This is the label that users are allowed to read/write and manage.&amp;nbsp; We try to prevent confined applications from being able to read and write this content, since this is where users store private content like credit card data, passwords shared secrets etc.&amp;nbsp; When we have a confined application that needs to access this content we usually wrap it in a boolean like ftp_home_dir.&amp;nbsp; Or we create a new type for this content, like mozilla_home_t or ssh_home_t. &lt;/li&gt;&lt;br /&gt;&lt;li&gt;/home/dwalsh/.ssh is labeled ssh_home_t, and contains content that only user types and sshd is allowed to read. Most other confined domains are not allowed to view content in this directory since it contains content like your secret keys.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;/home/dwalsh/public_html is labeled httpd_user_content_t , which by default is the only place apache process is allowed to read in the home directory.&amp;nbsp; Allowing apache to read .ssh or say your .mozilla directory is just asking for trouble.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;Note:&amp;nbsp; In order for apache or sshd to read their content they need to be allowed to search and getattr on every directory in the path.&amp;nbsp; The httpd would need to search root_t, home_root_t, user_home_dir_t, httpd_user_content_t.&amp;nbsp; It is not allowed to do this by default and needs the httpd_enable_homedirs boolean turned on.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# sesearch -A -b httpd_enable_homedirs -c dir -C | grep -v nfs | grep -v samba&lt;br /&gt;Found 20 semantic av rules:&lt;br /&gt;DT allow httpd_sys_script_t home_root_t : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_sys_script_t user_home_dir_t : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_user_script_t user_home_type : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_t user_home_type : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_user_script_t home_root_t : dir { ioctl read getattr lock search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_t home_root_t : dir { ioctl read getattr lock search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_user_script_t user_home_dir_t : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_t user_home_dir_t : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_suexec_t user_home_type : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_suexec_t home_root_t : dir { ioctl read getattr lock search open } ; [ httpd_enable_homedirs ]&lt;br /&gt;DT allow httpd_suexec_t user_home_dir_t : dir { getattr search open } ; [ httpd_enable_homedirs ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Getting back to the question that drove me to create this blog.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What is the differences between user_home_dir_t&amp;nbsp; and user_home_t?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;user_home_dir_t should only be the label of the users home directory but not of any content in the users home directory.&lt;br /&gt;user_home_t is the label for generic content in a users homedir.&lt;br /&gt;&lt;br /&gt;If you want to see all the labels that effect the users homedir, you can look at /etc/selinux/targeted/contexts/files/file_contexts.homedirs.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;grep /home /etc/selinux/targeted/contexts/files/file_contexts.homedirs |wc -l&lt;br /&gt;300&lt;/span&gt;</description>
	<pubDate>Tue, 23 Apr 2013 14:56:21 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Understanding MCS Separation.</title>
	<guid>http://danwalsh.livejournal.com/63472.html</guid>
	<link>http://danwalsh.livejournal.com/63472.html</link>
	<description>We designed a new way of using MCS, Multi Category Security, when we developed sVirt (Secure Virtualization) a few years ago.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To understand MCS it is helpful to understand something about MLS.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When Red Hat Enterprise Linux 5 came out, we had a done a lot of work adding MLS, Multi Level Security.&amp;nbsp; MLS requires the Belle &amp;amp; La Padula model of security.&amp;nbsp; This model takes into account the &amp;quot;Level and Category&amp;quot; of the data, and adds rules like a higher level process (TopSecret) is not allowed to write down (Secret) and a lower level (Secret) process is not allowed to read a higher level data (TopSecret).&amp;nbsp; The simple description of categories would be in order to read or write your process must have all the categories of the target.&amp;nbsp;&amp;nbsp;&amp;nbsp; Levels can go from s0 (SystemLow) to s15 (SystemHigh).&amp;nbsp; Then you can have any combination of 1024 categories.&lt;br /&gt;&lt;br /&gt;In MCS we stole the idea of categories and dropped the concept of levels.&lt;br /&gt;&lt;br /&gt;As I mentioned above the process category most include ALL of the categories of the target, otherwise MCS separation would block the access.&amp;nbsp;&amp;nbsp; It is best to see an example of this.&lt;br /&gt;&lt;br /&gt;Say I have a process labeled system_u:system_r:svirt_t:s0:c1,c2 from MCS Separation point of view.&amp;nbsp; This process would be allowed to access any file with any of these 4 MCS labels.&lt;ul&gt;&lt;br /&gt;&lt;li&gt;s0&lt;/li&gt;&lt;br /&gt;&lt;li&gt;s0:c1&lt;/li&gt;&lt;br /&gt;&lt;li&gt;s0:c2&lt;/li&gt;&lt;br /&gt;&lt;li&gt;s0:c1,c2&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;Since most files on a targeted system have the MCS label s0.&amp;nbsp; MCS Labeling does not block much mcs constrained applications.&lt;br /&gt;&lt;br /&gt;By convention MCS confinement always uses two categories, and the categories can not be the same.&amp;nbsp; s0:c1,c1 == s0:c1.&amp;nbsp; Secondarily tools that launch MCS separate apps like libvirt and sandbox, make sure they never launch two processes with the same MCS label.&amp;nbsp; Which means we guarantee that two svirt_t always have two MCS labels that no other svirt_t or svirt_image_t would have.&amp;nbsp; Therefore a process running svirt_t:s0:c1,c2 would not be prevented by&amp;nbsp; MCS from access to any file with a MCS label of s0 or s0:c1,c2.&amp;nbsp; It would be denied from reading any file labeled s0:c1,c3 or s0:c2,c4 or s0:c4,c6.&lt;br /&gt;&lt;br /&gt;But looking at MCS separation as the only control, misses out on type enforcement controls.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;svirt_t access&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We define our virtual machines as svirt_t type, and then we define rules about which types an svirt_t type is allowed access to.&amp;nbsp; If I wanted to see which types svirt_t is allowed to write, I could execute the following command.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# sesearch -A -s svirt_t -c file -p write -C | grep open | grep -v ^D&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain svirt_tmp_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow svirt_t xen_image_t : file { ioctl read write getattr lock append open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain svirt_image_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain svirt_tmpfs_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain virt_cache_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain qemu_var_run_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain anon_inodefs_t : file { ioctl read write getattr lock append open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow virt_domain svirt_home_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow svirt_t svirt_t : file { ioctl read write getattr lock append open } ;&lt;br /&gt;ET allow virt_domain dosfs_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; [ virt_use_usb ]&lt;br /&gt;ET allow virt_domain usbfs_t : file { ioctl read write getattr lock append open } ; [ virt_use_usb ]&lt;br /&gt;&lt;br /&gt;This means a confined virtual machine running as svirt_t:s0:c1,c2 would ONLY allowed to write to the following file types IFF they are MCS labeled s0 or s0:c1,c2&lt;br /&gt;&lt;br /&gt;svirt_tmp_t, svirt_image_t, svirt_tmpfs_t, virt_cache_t, qemu_var_run_t, svirt_home_t,&lt;br /&gt;&lt;br /&gt;dosfs_t and usbfs_t iff the virt_use_usb boolean is turned on, perhaps we should turn this off by default.&lt;br /&gt;&lt;br /&gt;anon_inodefs_t and svirt_t are not file types, svirt_t is a process types which would be in /proc.&lt;br /&gt;&lt;br /&gt;libvirt and the kernel need to ensure that non of these files get labeled with s0.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Openshift domains are allowed to write/open &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Kernel file systems anon_inodefs_t, openshift_t,hugetlbfs_t,&amp;nbsp; security_t&lt;br /&gt;&lt;br /&gt;openshift_tmp_t, openshift_rw_file_t, openshift_tmpfs_t&lt;br /&gt;&lt;br /&gt;&lt;b&gt;MCS Constrained Types&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Thee following types are MCS Constrained.&lt;br /&gt;&lt;br /&gt;seinfo&amp;nbsp; -amcs_constrained_type -x&lt;br /&gt;&amp;nbsp;&amp;nbsp; mcs_constrained_type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svirt_lxc_net_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_app_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_min_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_net_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_min_app_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_net_app_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svirt_tcg_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; netlabel_peer_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sandbox_x_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svirt_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sandbox_min_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sandbox_net_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sandbox_web_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sandbox_t</description>
	<pubDate>Wed, 17 Apr 2013 15:40:16 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Audit2allow should be your third option not the first.</title>
	<guid>http://danwalsh.livejournal.com/63137.html</guid>
	<link>http://danwalsh.livejournal.com/63137.html</link>
	<description>Whenever I talk about SELinux lately, I make everyone stand up and say.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span&gt;SELinux is a labeling system&lt;/span&gt;.&lt;/b&gt;&lt;br /&gt;&lt;span&gt;Every process has a label every object on the system has a label.&amp;nbsp; Files, Directories, network ports ...&lt;br /&gt;The SELinux policy controls how process labels interact with other labels on the system.&lt;br /&gt;The kernel enforces the policy rules.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The follow up to this is, if you get a denial the &lt;b&gt;First &lt;/b&gt;thing you should think is, perhaps one of the labels is &lt;b&gt;WRONG.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I wrote a paper&amp;nbsp; a while ago called the &lt;a href=&quot;http://danwalsh.livejournal.com/30837.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;SELinux Four Things.&lt;/a&gt;  In which I point out the four causes of SELinux denials.&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;You have a labeling problem.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You have changed a process configuration, and you forgot to tell SELinux about it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You have a bug in either an application or SELinux policy.&amp;nbsp; Either SELinux policy did not know an application could do something, or the application is broken.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;You have been hacked.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;The solution to #3 is to report a bug and use audit2allow to generate a local policy module and install it until either the application is fixed or SELinux policy adds rules to allow it.&lt;br /&gt;&lt;br /&gt;The problem i see is that administrators seem to go to this option when ever they see a denial.&amp;nbsp;&amp;nbsp; Lets look at a recent example from email.&lt;br /&gt;&lt;br /&gt;In a recent email on selinux@lists.fedoraproject.org, Richard reported:&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;span&gt;I have a CGI application named &amp;quot;mapserv&amp;quot; that needs to write to a specific location: &amp;quot;/rwg/mapserver/tmp&amp;quot;&lt;/span&gt;&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;He figured out that Apache content was usually labeled httpd_sys_content_t, which was a step in the right direction, so I guess he labeled this rectory tree as&lt;br /&gt;httpd_sys_content_t.&lt;br /&gt;&lt;br /&gt;Then he asked about writing policy that looked like.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;module test 1.0;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;require {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type httpd_sys_content_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type httpd_sys_script_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class dir add_name;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class file { write create };&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#============= httpd_sys_script_t ==============&lt;br /&gt;allow httpd_sys_script_t httpd_sys_content_t:dir add_name;&lt;br /&gt;allow httpd_sys_script_t httpd_sys_content_t:file { write create };&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This policy obviously came from audit2allow, and would work, except for a couple of problems, the biggest being that all CGI Scripts would be able to read write all Apache content.&amp;nbsp; The policy is also fragile since you might get an AVC like httpd_sys_script_t is not allowed to append to httpd_sys_content_t.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;manage_files_pattern(httpd_sys_script_t, httpd_sys_content_t, httpd_sys_content_t) &lt;/span&gt; Would have been better.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Is there a better label I could have used?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;But the main point of this blog would be that Richard should not have used a audit2allow module.&amp;nbsp; He could have used httpd_sys_rw_content_t for the tmp directory.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semanage fcontext -a -t httpd_sys_rw_content_t &amp;quot;/rwg/mapserver/tmp(/.*?)&amp;quot;&lt;br /&gt;# restorecon -R -v /rwg/mapserver/tmp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This would have been choice &amp;quot;1&amp;quot; above, one of the labels is wrong.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Could I change the process label?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Dominic Grift pointed out, in a mail reply, another solution. &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;
&lt;span&gt;cat &amp;gt; mywebapp.te &amp;lt;&amp;lt; EOF
policy_module(mywebappp, 1.0.0)
apache_content_template(mywebapp)
EOF

make -f /usr/share/selinux/devel/Makefile mywebapp.pp
sudo semodule -i mywebapp&lt;/span&gt;

&lt;span&gt;Now you can use the following new types:

httpd_mywebapp_script_t (mywebapp process type)
httpd_mywebapp_script_exec_t (mywebapp cgi executable file type)
httpd_mywebapp_content_t (mywebapp readonly file type)
httpd_mywebapp_content_rw_t (mywebapp read/write file type)
httpd_mywebapp_content_ra_t (mywebapp read/append file type)
httpd_mywebapp_htaccess_t (mywebapp htaccess file types)

Basically you can just label the cgi script with the mywebapp script executable file type and then the mywebapp process will run with the mywebapp process type creating files with the mywebapp content file types.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;This solution satisfies &amp;quot;1&amp;quot;, changing both the process label and the target label.&amp;nbsp; This is probably the best solution, since if Richard used other CGI scripts on his machine, only the mapserver cgi script would be able to write the mapserver cgi content, and he would have better separation.&lt;br /&gt;&lt;br /&gt;Note:&amp;nbsp; I would have used &lt;span&gt;sepolicy generate --cgi PATHTO/mapserver.cgi&lt;/span&gt; to generate the policy.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Could I modify the SELinux configuration to allow this access?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A third option would be to turn on the httpd_unified boolean.&amp;nbsp; (This would an option of type &amp;quot;2&amp;quot;).&amp;nbsp; Although not the best solution for the problem.&lt;br /&gt;&lt;br /&gt;httpd_unified is described as &amp;quot;Unify HTTPD handling of all content files.&amp;quot; &lt;/p&gt;&lt;p&gt;&lt;span&gt;# setsebool -P httpd_unified 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This means it will allow the apache process and default apache scripts to read/write/execute all default labeled apache content. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Bottom line, when you see an SELinux AVC, the way your decision tree should go something like the following.&lt;/b&gt;&lt;/p&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Is the process that is being denied running with the correct label?&amp;nbsp; Could I make it run with a better label? &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Does the target object have the correct label or could I assign it a label that would allow the access from the process label?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Is their an SELinux Boolean that would allow the access?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If this is a network port being denied, did I modify the default settings and could I modify the labels on network packets using semanage port.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Do I believe this is a bug in an application?&amp;nbsp; If yes, I need to report a bug?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Is this a bug in SELinux policy and the access should be allowed by default?&amp;nbsp; I should install a local modification and report this as a bug.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Am I being hacked?&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;setroubleshoot attempts to help you walk through this process, and newer versions of audit2allow show you booleans and potential labels you can use.</description>
	<pubDate>Wed, 17 Apr 2013 13:11:55 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Joshua Brindle: And here it is... mRAT's found that bypass MAM</title>
	<guid>http://securityblog.org/2013/04/12/and-here-it-is-mrats-found-that-bypass-mdm</guid>
	<link>http://securityblog.org/2013/04/12/mrats-bypass-mam</link>
	<description>&lt;p&gt;As a follow-up to my &lt;a href=&quot;http://securityblog.org/2013/04/11/security-anti-pattern-mobile-castles-on-sand/&quot;&gt;last blog post&lt;/a&gt;, I just came across this article: &lt;a href=&quot;http://www.infosecurity-magazine.com/view/31801/mobile-malware-gets-serious-rats-can-bypass-sandboxes-and-encryption/&quot;&gt;Mobile malware gets serious – RATs can bypass sandboxes and encryption&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1 in 1000 devices, the tools are in the wild. There is no reason to believe this number will go down. Further, these mRAT's apparently know how to bypass MDM and MAM sandboxes and encryption.&lt;/p&gt;

&lt;p&gt;of course, &lt;a href=&quot;http://blogs.computerworld.com/19803/mobile_rat_attack_makes_android_the_ultimate_spy_tool&quot;&gt;mRAT's&lt;/a&gt; &lt;a href=&quot;http://365.rsaconference.com/community/connect/blog/2012/02/21/rsac2012-podcast-hot-203-hacking-exposed-mobile-rat-edition&quot;&gt;aren't&lt;/a&gt; &lt;a href=&quot;http://www.talkandroid.com/52495-malware-strain-nickispy-c-is-exploiting-the-rise-of-google/&quot;&gt;anything new&lt;/a&gt;, but this is the first I've heard about ones that specifically target/bypass MDM/MAM.&lt;/p&gt;

&lt;p&gt;Worse, the tools aren't just being used by experts; hackforums.net has tutorials on using them with commands like 'Hit Start then run, type &quot;CMD&quot; without quotations, hit OK, type &quot;IPCONFIG&quot; without quotations, etc'.&lt;/p&gt;

&lt;p&gt;The solution is integrating SE Android into your devices; but SE Android, like SELinux is no silver bullet. You need good policies. Mobile device manufacturers are notoriously bad at securing their devices. The fact that a device node directly exposing kernel memory was world readable/writeable on many Samsung devices is direct evidence of this. The same people writing that software could not possibly be trusted to write secure SELinux policies. Separate teams that do security analysis and testing must ensure the policies are reasonable, etc.&lt;/p&gt;

&lt;p&gt;This isn't rocket science, but it isn't standard operating procedure either. We've been doing independent verification and validation (IV&amp;amp;V) in government spaces forever. This needs to happen in mobile and there need to be security mechanisms that don't rely on discretionary access controls in place, which, of course, means mandatory access controls, which SE Android offers.&lt;/p&gt;</description>
	<pubDate>Fri, 12 Apr 2013 05:00:00 +0000</pubDate>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 19 Part 2: Shared System Certificates</title>
	<guid>http://danwalsh.livejournal.com/62737.html</guid>
	<link>http://danwalsh.livejournal.com/62737.html</link>
	<description>One of the cool things about writing this series of blogs for each Fedora Release is finding out about the changes is different parts of the OS outside of SELinux.&amp;nbsp; I love getting suggestions of security topics to blog on.&amp;nbsp; If you know of security topics I should cover send them to me at dwalsh@redhat.com or tweet &lt;a href=&quot;https://twitter.com/rhatdan&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;@rhatdan&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;Shared System Certificates&lt;/h2&gt;&lt;p&gt;Currently Tools like NSS (Mozilla products like Firefox/Thunderbird), GnuTLS, OpenSSL and Java on a Fedora box ship their own public key certificates and their own trust relationships. This means if an administrator wants to add/modify/delete trust to certain Certificates, he might have to modify several different stores in order to get the correct security.&lt;br /&gt; &lt;br /&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/SharedSystemCertificates&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;A new feature in Fedora 19 is a system wide trust store of static data to be used by crypto toolkits as input for certificate trust decisions.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This feature the tools listed above a default source for retrieving system certificate anchors and black list information.&amp;nbsp; Fedora 19 will be the first step toward development of a comprehensive solution.&lt;br /&gt;&lt;br /&gt;Look at the feature for more information on the changes, but the following two sections explain the key benefits to this feature and how users will use it.&lt;/p&gt;&lt;h2&gt;&lt;span&gt;Benefit to Fedora &lt;/span&gt;&lt;/h2&gt;&lt;p&gt;The goal is to empower administrators to configure additional trusted CAs, or to override the trust settings of CAs, on a system wide level, as required by local system environments or corporate deployments. Although this is theoretically possible today, it's extremely hard to get right.&lt;/p&gt;&lt;p&gt;Fedora will immediately gain a unified approach to system anchor certificates and black lists. This is then built on in the future to be a comprehensive solution.&lt;/p&gt;&lt;h2&gt;&lt;span&gt;User Experience &lt;/span&gt;&lt;/h2&gt;&lt;p&gt;Administrators will be able to use a tool to add a certificate authority file to the system trust store and have it recognized by all relevant applications.&lt;/p&gt;&lt;p&gt;Users will stop being surprised by incoherent and unpredictable trust decisions when using different applications with websites/services which require custom trust policy.&lt;/p&gt;</description>
	<pubDate>Thu, 11 Apr 2013 14:17:49 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Joshua Brindle: Security Anti-Pattern - Mobile Castles on Sand (or why app wrapping is not a security model)</title>
	<guid>http://securityblog.org/2013/04/11/security-anti-pattern-castles-on-sand</guid>
	<link>http://securityblog.org/2013/04/11/security-anti-pattern-mobile-castles-on-sand</link>
	<description>&lt;h1&gt;Mobile Application Management (MAM)&lt;/h1&gt;

&lt;p&gt;Mobile Device Management (MDM) was all the hotness just a few years ago. It gave IT departments the ability to manage both corporate owned devices and devices owned by employees (BYOD) but it was dissatisfying. As BYOD became more prevalent and corporate owned devices less it made users feel like they were giving up all control of their device to their employer, mainly because they were. Most users at this point probably know the feeling of adding their corporate credentials into their phone and seeing the dreaded 'you are giving administrators the ability to wipe your phone, install apps, remove apps, and locate your phone' screen.&lt;/p&gt;

&lt;p&gt;Then there was the issue of having multiple administrators that wanted to do different things with your device.&lt;/p&gt;

&lt;p&gt;Even for the administrators, the solution was incomplete. It did not give them the ability to manage app configuration, app storage, app authentication, etc.&lt;/p&gt;

&lt;p&gt;That is where MAM comes in. For the administrators it means they can package apps with configuration, version it, push it out and wipe only corporate app data when an employee leaves. The nicer systems add single sign-on so that a user can authenticate once and get access to all corporate apps. They also store corporate data encrypted and can report usage statistics back to corporate IT. For users it means that they don't have to give up full control of their device.&lt;/p&gt;

&lt;p&gt;Sounds great, right?&lt;/p&gt;

&lt;h2&gt;How does it work?&lt;/h2&gt;

&lt;p&gt;Well, mobile devices don't typically have this kind of granular control built in. Further, off-the-shelf applications generally don't come configured or support single sign-on. The solution that MDM vendors started peddling is called app wrapping. Basically it means that the IT department takes the apps they want to manage (whether they are internally developed or 3rd party) and runs a tool from the MAM vendor that packages the app within another app, the wrapper (or the castle).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://securityblog.org/images/castle.png&quot; title=&quot;Icons from http://wwalczyszyn.deviantart.com/&quot; alt=&quot;Apps in a castle&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The outside package interacts with the real device, including storing data to disk encrypted, verifying credentials with corporate authentication servers, etc. The fancier ones even prevent apps from running outside of specific physical locations (geofencing), and will attempt to detect a rooted device (though that is impossible in practice).&lt;/p&gt;

&lt;p&gt;So, this still sounds great. From a functionality point of view this is a superior experience for both the user and IT, so what is the problem?&lt;/p&gt;

&lt;h2&gt;Userspace containerization (or building castles)&lt;/h2&gt;

&lt;p&gt;Lets start with the obvious one first. The inside (wrapped) app is modified to not be able to interact with the real device, but to interact with the wrapper instead. Two standard ways this is done is by providing an SDK that corporate apps can be written with and the other is called app wrapping. It should be noted that while using the SDK is the safer option, it will likely lock you in to a single MAM vendor.&lt;/p&gt;

&lt;p&gt;App wrapping on Android involves modifying the Dalvik bytecode ahead of time to add all of the functional additions as well as changing functions that would normally interact directly with the system (think filesystem operations, intents, binder calls, etc) to use analogous calls in the wrapper instead. The effect here is that the wrapper can 1) ensure filesystem writes only go to allowed locations and are encrypted and 2) to prevent IPC with apps outside of the &quot;container&quot;.&lt;/p&gt;

&lt;p&gt;Well, that is the thought, anyway.&lt;/p&gt;

&lt;p&gt;No one in their right mind would believe that they can write a libc wrapper that intercepts open() calls to make security decisions and think that it buys them anything, but that is fundamentally what is happening here. App wrappers cannot contain numerous, supported features on Android such as jni to native libraries and java reflection. A particularly crafty app might even have a scripting language interpreter or its own java class loader that would be nearly impossible for the wrapper to understand and secure.&lt;/p&gt;

&lt;p&gt;There is no chance that an MAM implementation could keep an app that wanted to exfiltrate corporate data from doing so. That is an easy problem to solve though, you only wrap trusted apps, because they are either corporate or known 3rd party apps, right? Well, hopefully, for your sake, those apps don't have vulnerabilities that a spear phisher can take advantage of to gain access to corporate data (spoiler: they do).&lt;/p&gt;

&lt;p&gt;In the scheme of things this is a relatively low threat, though, so lets move onto the real issue.&lt;/p&gt;

&lt;h2&gt;The insecure platform (or the sand)&lt;/h2&gt;

&lt;p&gt;People have tried building secure on top of insecure as long as personal computers have been around. The appeal is that there is always an insecure platform, be it Windows, Linux, iOS, or Android and there is always a need to access secure data is always there.&lt;/p&gt;

&lt;p&gt;I'll take this opportunity to suggest that, if you haven't already, you should read:
&lt;a href=&quot;http://csrc.nist.gov/nissc/1998/proceedings/paperF1.pdf&quot;&gt;The Inevitability of Failure: The Flawed Assumption of Security in Modern Computing Environments&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fact is that if the system below your application isn't secure no amount of anything will make your application (or wrapper) secure. Detecting rooted devices is not enough. Most detection is heuristic, such as checking for the existence of /system/xbin/su. Suppose the device is not rooted by the user such that su exists but by an adversary? Root access gained for the intention of stealing corporate data would not likely be detected by an MAM solution and therefore malicious applications running on the device would be able to affect the corporate apps in various ways, from communicating with them, bypassing the wrapper, all the way to scanning their memory and extracting corporate data.&lt;/p&gt;

&lt;p&gt;Most snake oil vendors will claim encryption solves this problem. Encryption may be a suitable solution to data-at-rest, data not currently being accessed that is sitting on disk, but when your corporate email app is running the emails are in memory, not encrypted. Even if an industrious app writer did extra work to keep them encrypted in memory the decryption key must also be in memory, and is vulnerable.&lt;/p&gt;

&lt;p&gt;So, this is the real threat. If your app has data I want and it runs on a standard Android or iOS phone, I'll be able to get it, no matter what your MAM vendor is telling you.&lt;/p&gt;

&lt;p&gt;As a non-security related aside, you probably don't have permission to download 3rd party apps from the app store and wrap them, which would constitute unlicensed distribution, you'd have to get permission from the app owner. An interesting ramification of this is that GPL apps can't be legally wrapped since the GPL license of the app would have to apply to the wrapper as well.&lt;/p&gt;

&lt;h1&gt;The solution&lt;/h1&gt;

&lt;p&gt;Just like in standard computing the solution isn't hard, but is rarely used.&lt;/p&gt;

&lt;p&gt;You must have a secure host platform if you want your applications to be secure. Unfortunately not many options exist for this but fortunately there are options that are freely available. The one that I favor is, of course, SELinux. I've been involved in building SELinux systems to secure even the most important data for nearly a decade now and it has proven true.&lt;/p&gt;

&lt;p&gt;Anecdotally, I have security researcher friends who work on the offensive side of the fence that have told me when they encounter an SELinux machine they bail and look for an easier target. It is important to note that we aren't talking about out-of-the-box Fedora installs, though, but systems intentionally and knowingly hardened against this type of adversary.&lt;/p&gt;

&lt;p&gt;Which brings us back to Android. The Security Enhanced Android (SE Android) project has been picking up more and more steam. Much of it is already merged into AOSP which allows all Android vendors to use it and recently Samsung has announced a device that will have it included by default. This is definitely a step in the right direction but a far cry from what it will take to feel confident allowing important corporate data to be accessed on non-corporate owned devices.&lt;/p&gt;

&lt;p&gt;With a secure platform you can enjoy the functionality benefits of an MAM solution and be confident that security provided by the platform will keep their castles secure, both from the inside and the outside.&lt;/p&gt;

&lt;p&gt;Unfortunately, none of this is a solution you can use today. Technology must, as usual, catch up to market demands. The demand must be there, though. Demand secure platforms. There is no excuse for Android vendors to not include SE Android in future offerings, all the hard work has already been done by early adopters.&lt;/p&gt;

&lt;p&gt;Update:
My &lt;a href=&quot;http://securityblog.org/2013/04/12/mrats-bypass-mam/&quot;&gt;next entry&lt;/a&gt; has validation for this post, seen in the wild.&lt;/p&gt;</description>
	<pubDate>Thu, 11 Apr 2013 05:00:00 +0000</pubDate>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 19 Part 1: New Confined/Permissive Process Domains</title>
	<guid>http://danwalsh.livejournal.com/62711.html</guid>
	<link>http://danwalsh.livejournal.com/62711.html</link>
	<description>Each Fedora we release a bunch of new domains that will run in permissive mode for the release.&amp;nbsp; When the next release is released, the permissive domains are made enforcing.&lt;br /&gt;&lt;br /&gt;In my blog,&lt;a href=&quot;http://danwalsh.livejournal.com/42394.html&quot; rel=&quot;nofollow&quot;&gt;10 things you probably did not know about SELinux.. #4&lt;/a&gt;, I describe how you can interact with permissive domains.&lt;br /&gt;&lt;br /&gt;In &lt;a href=&quot;http://danwalsh.livejournal.com/58178.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Fedora 18&lt;/a&gt;, we added 8 new permissive domains, all of&amp;nbsp; which are now enforcing in Fedora 19. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 18 Permissive Domains/ Now Confined in Fedora 19&lt;/b&gt;&lt;br /&gt;&lt;span&gt; &amp;nbsp; pkcsslotd_t (daemon manages PKCS#11 objects between PKCS#11-enabled applications)&lt;br /&gt;&amp;nbsp;&amp;nbsp; slpd_t&amp;nbsp; (Server Location Protocol Daemon)&lt;br /&gt;&amp;nbsp;&amp;nbsp; sensord_t (Sensor information logging daemon)&lt;br /&gt;&amp;nbsp;&amp;nbsp; mandb_t&amp;nbsp; (Cron job used to create /var/cache/man content)&lt;br /&gt;&amp;nbsp;&amp;nbsp; glusterd_t (policy for glusterd service)&lt;br /&gt;&amp;nbsp;&amp;nbsp; stapserver_t (Instrumentation System Server) Note: This was back ported to Fedora 17.&lt;br /&gt;&amp;nbsp;&amp;nbsp; realmd_t (dbus system service which manages discovery and enrollment in realms and domains like Active Directory or IPA)&lt;br /&gt;&amp;nbsp;&amp;nbsp; phpfpm_t (FastCGI Process Manager) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 19 Permissive Domains&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; systemd_localed_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; systemd-localed is a system service that may be used as mechanism to&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; change the system locale settings, as well as the console key mapping&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and default X11 key mapping.&amp;nbsp; systemd-localed is automatically&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activated on request and terminates itself when it is unused.&lt;br /&gt;&lt;br /&gt;&amp;nbsp; systemd_hostnamed_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; systemd-hostnamed is a system service that may be used as mechanism to&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; change the system hostname.&amp;nbsp; systemd-hostnamed is automatically&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activated on request and terminates itself when it is unused.&lt;br /&gt;&lt;br /&gt;&amp;nbsp; systemd_sysctl_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; systemd-sysctl.service is an early-boot service that configures&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sysctl(8) kernel parameters.&lt;br /&gt;&lt;br /&gt;&amp;nbsp; httpd_mythtv_script_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mythtv cgi scripts used for managing mythtv scheduling and content.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; openshift_cron_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OpenShift System Cron jobs run as openshift_cron_t, not gear cron jobs.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; swift_t&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OpenStack Object Storage (swift) aggregates commodity servers to work together&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; in clusters for reliable, redundant, and large-scale storage of static objects.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 19 Modules Removed&lt;/b&gt;&lt;br /&gt;shutdown.pp (Command no longer supported, functions suplanted by systemd)&lt;br /&gt;consoletype.pp(Command should no longer be used, suplanted by systemd-logind)&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 19 Modules Renamed or Consolodated&lt;/b&gt;&lt;br /&gt;amavis.pp clamav.pp - These have been consolodated into a unified view of antivirus.pp, All aliased o antivirus_t.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; typealias antivirus_t alias { amavis_t clamd_t clamscan_t freshclam_t } ;&lt;br /&gt;&lt;br /&gt;ctdbd.pp changed name upstream to ctdb.pp&lt;br /&gt;isnsd.pp changed name upstream to isnd.pp&lt;br /&gt;pacemaker.pp and corosync.pp rgmanager.pp aisexec.pp - These have been consolodated into a unified view of rhcs.pp, all aliased to the new type cluster_t.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; typealias cluster_t alias { aisexec_t corosync_t pacemaker_t rgmanager_t }</description>
	<pubDate>Wed, 10 Apr 2013 13:04:24 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Security Vs Usability</title>
	<guid>http://danwalsh.livejournal.com/62262.html</guid>
	<link>http://danwalsh.livejournal.com/62262.html</link>
	<description>One of the interesting things about working in the security field, is walking the balance between security and usability.&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;On one of the many mailing lists I read, an admin as complaining about his Apache server being hacked.&amp;nbsp; Some application had been hacked in a way that it got apache to write to a particular directory and then executed the code it has written.&lt;br /&gt;&lt;br /&gt;I decided to look at how SELinux Policy controlled httpd_t.&amp;nbsp; I wanted to know what file types was httpd_t allowed to write and execute.&lt;br /&gt;&lt;br /&gt;In Fedora 19, I executed the following command.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; sesearch -A -C -s httpd_t -p execute -c file | grep write&lt;br /&gt;DT allow httpd_t httpdcontent : file { ioctl read write create getattr setattr lock append unlink link rename execute open } ; [ httpd_enable_cgi httpd_unified &amp;amp;&amp;amp; httpd_builtin_scripting &amp;amp;&amp;amp; ]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This indicates that the apache deamon (httpd_t) is allowed to write and execute files that have a label that has the attribute httpdcontent.&amp;nbsp; But they would have to have the httpd_enable_cgi, httpd_unified, and httpd_builtin_scripting booleans turned on.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;#semanage boolean -l | grep httpd_enable_cgi&lt;br /&gt;httpd_enable_cgi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (on&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; on)&amp;nbsp; Allow httpd cgi support&lt;br /&gt;# semanage boolean -l | grep httpd_unified&lt;br /&gt;httpd_unified&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (off&amp;nbsp; ,&amp;nbsp; off)&amp;nbsp; Unify HTTPD handling of all content files.&lt;br /&gt;# semanage boolean -l | grep httpd_builtin_scripting&lt;br /&gt;httpd_builtin_scripting&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (on&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp; on)&amp;nbsp; Allow httpd to use built in scripting (usually php)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Out of the box we enable httpd_enable_cgi, so cgi scripts will run with your apache server.&amp;nbsp; We also enable httpd_builtin_scripting, which allows you to run php scripts within the same processes as apache, this also enabled other builtin scripting tools like mod_python and mod_perl.&lt;br /&gt;&lt;br /&gt;We disable httpd_unified, which basically says httpd_t has full access to all httpdcontent files.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# seinfo -ahttpdcontent -x&lt;br /&gt;&amp;nbsp;&amp;nbsp; httpdcontent&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_sys_content_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_user_ra_content_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_user_rw_content_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_sys_ra_content_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_sys_rw_content_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_user_content_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So rather then treating each type differently we combine all access.&amp;nbsp; We used to have this turned on by default for people who did not understand SELinux, probably still is in RHEL5 and maybe RHEL6.&amp;nbsp; But in latest Fedora and RHEL7 we will turn it off by default.&lt;br /&gt;&lt;br /&gt;If you are running a web site that does not do any scripting, it would probably be advisable to turn off the other two booleans.</description>
	<pubDate>Fri, 15 Mar 2013 14:59:02 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: SELinux Reveals Bugs in Code</title>
	<guid>http://danwalsh.livejournal.com/62070.html</guid>
	<link>http://danwalsh.livejournal.com/62070.html</link>
	<description>I have noticed over the years random confined process that get avc denials for the SYS_RESOURCE and SYS_ADMIN capabilities.&amp;nbsp; Most of the time, these are not easily repeated.&amp;nbsp; The combination of these two usually indicate a confined processes is attempting to use a system resources beyond the limits for the owner UID.&amp;nbsp; For example in RHEL6 a user, dwalsh, is only allowed to run 1025 processes, and an individual process running as dwalsh, is only allowed to open 1024 files.&lt;br /&gt;&lt;br /&gt;/usr/include/linux/capability.h documents SYS_RESOURCE as the following&lt;br /&gt;&lt;br /&gt;&lt;span&gt;/* Override resource limits. Set resource limits. */&lt;br /&gt;/* Override quota limits. */&lt;br /&gt;/* Override reserved space on ext2 filesystem */&lt;br /&gt;/* Modify data journaling mode on ext3 filesystem (uses journaling&lt;br /&gt;&amp;nbsp;&amp;nbsp; resources) */&lt;br /&gt;/* NOTE: ext2 honors fsuid when checking for resource overrides, so&lt;br /&gt;&amp;nbsp;&amp;nbsp; you can override using fsuid too */&lt;br /&gt;/* Override size restrictions on IPC message queues */&lt;br /&gt;/* Allow more than 64hz interrupts from the real-time clock */&lt;br /&gt;/* Override max number of consoles on console allocation */&lt;br /&gt;/* Override max number of keymaps */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The goal of these limits is to prevent an individual user from doing a fork bomb or opening so many files the system gets a Denial of Service.&lt;br /&gt;&lt;br /&gt;Even root processes are governed by these limits,&amp;nbsp; however root processes almost always have SYS_ADMIN and SYS_RESOURCE capabilities, unless they have dropped them using something like libcap/libcap-ng or you are using an Mandatory Access System like SELinux.&lt;br /&gt;&lt;br /&gt;Lon Hohberger, who is working on the OpenStack team at Red Hat and currently working on making SELinux work well with OpenStack, discovered some problems in RHEL6, that could and probably are triggering these AVC's.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Bug #1 &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Prior to RHEL6.4 ANY login to the system, including root,&amp;nbsp; would get a process limit of 1024.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# ulimit -u&lt;br /&gt;1024&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Meaning if you started any processes on a system that already had 1025 processes running, the kernel would be checking SYS_RESOURCE.&amp;nbsp; If you executed a command like&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# service httpd restart&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then httpd would fall under the same limits, since httpd_t is not allowed these Capabilities, httpd_t would generate the AVC's and probably fail to start.&lt;br /&gt;&lt;br /&gt;Worse then this, if you executed:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# yum -y update&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is a decent chance that during the update some packages post install would do a&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# service foobar restar&lt;/span&gt;t&lt;br /&gt;&lt;br /&gt;If foobar was confined by SELinux, then the AVC could be generated.&lt;br /&gt;&lt;br /&gt;Luckily we have had a fix for this in RHEL6.4,&amp;nbsp; although this fix has not gone into Fedora yet...&lt;br /&gt;&lt;br /&gt;The following line as added to&lt;span&gt; /etc/security/limits.d/90-nproc.conf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;root soft nproc unlimited&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;BUG #2&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;First if you login as root to a RHEL6.4 system, and check the max processes limit, you will get something like:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# ulimit -u&lt;br /&gt;29924&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you login as a normal user you would get:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; ulimit -u&lt;br /&gt;1024&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you run su from your normal user account and check the ulimit you get:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# ulimit -u&lt;br /&gt;29924&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But if you run sudo as a normal user and run ulimit you get:&lt;br /&gt;&lt;span&gt;# ulimit -u&lt;br /&gt;1024&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;su and sudo should work the same way.&lt;br /&gt;&lt;br /&gt;This is probably a bug in sudo or in the sudo pam stack.&amp;nbsp; Have not determined which yet.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;BUG #3&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This one might be controversial, since these limits are supposed to count the resources used by a particular UID, we should be looking at ALL of the processes kicked off by the user, not only those running under his UID.&amp;nbsp;&amp;nbsp;&amp;nbsp; Since sudo in the above example was not modifying the maximum running processes when user dwalsh became root, the process started counted against the total number of root processes rather then the total number of processes started by dwalsh.&amp;nbsp; I believe this is wrong.&amp;nbsp; The kernel should be counting the number of processes started by user dwalsh and should look at the LoginUID rather then the actual UID.&amp;nbsp; Now if dwalsh logged onto a system and was able to get some processes running as root, they could continue to count against dwalshs resource constraints and not against the systems.&amp;nbsp;&amp;nbsp;&amp;nbsp; I realize this might be difficult since you would probably want processes that have the SYS_RESOURCE capability to not count against the total.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;systemd to the rescue&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;systemd has helped fix a lot of these issues.&lt;br /&gt;&lt;br /&gt;In RHEL6 if an admin starts/restarts a system daemon, that daemon ends up being a subprocess of the user, meaning inherits any of the constraints on the user processes.&amp;nbsp; In the latest Fedora's, systemd starts most system daemons.&amp;nbsp; The user process sends a message to systemd and systemd starts/restarts the service, which means the service gets the system constraints not the user constraints.</description>
	<pubDate>Thu, 14 Mar 2013 18:35:27 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: OpenCLでCPU/GPUを使い分ける？</title>
	<guid>hatenablog://entry/6435988827676747615</guid>
	<link>http://kaigai.hatenablog.com/entry/2013/04/03/033106</link>
	<description>&lt;p&gt;最近、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PG&quot;&gt;PG&lt;/a&gt;-Stromに興味があるという方からちょくちょく、個別に質問メールを頂く事がある。&lt;/p&gt;
&lt;p&gt;その中で頂いたコメントに興味深い洞察が。&lt;/p&gt;
&lt;blockquote&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;による&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%A2%A5%AF%A5%BB%A5%E9%A5%EC%A1%BC%A5%B7%A5%E7%A5%F3&quot;&gt;アクセラレーション&lt;/a&gt;は確かに興味深い機能だけれども、PG-Stromの本質は突き詰めていえばパイプライン処理のお化けだよね？だから、計算処理をCPUでやるようにしても良いんじゃない？&lt;/blockquote&gt;
&lt;p&gt;確かに。&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;による並列処理はハマると物凄い費用対効果をもらたすけれども、例えば&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%C0%B5%B5%AC%C9%BD%B8%BD&quot;&gt;正規表現&lt;/a&gt;マッチみたく、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;向きじゃない処理もある。&lt;/p&gt;
&lt;p&gt;PG-Stromの場合、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SQL&quot;&gt;SQL&lt;/a&gt;のWHERE句に与えられた条件から行を評価する&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%B4%D8%BF%F4&quot;&gt;関数&lt;/a&gt;を自動的に生成、それを&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/JIT&quot;&gt;JIT&lt;/a&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%B3%A5%F3%A5%D1%A5%A4%A5%EB&quot;&gt;コンパイル&lt;/a&gt;して実行する。たぶん、プランナの時点でCPU実行用、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;実行用の２種類の関数を自動的に生成して、計算&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%B5%A1%BC%A5%D0&quot;&gt;サーバ&lt;/a&gt;に渡すという処理は実現可能だろう。&lt;/p&gt;
&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NVidia&quot;&gt;NVidia&lt;/a&gt;の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;を前提とするCUDAと異なり、OpenCLは&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/AMD&quot;&gt;AMD&lt;/a&gt;の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;や&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Xeon&quot;&gt;Xeon&lt;/a&gt; Phiもサポートする。それどころか、OpenCL Cで書かれたコードをCPU用にコンパイルする事も可能。&lt;/p&gt;
&lt;p&gt;その辺の事情もあり、今、PG-StromをOpenCLで再実装し直している。(works in progress)&lt;/p&gt;
&lt;p&gt;だが、CPUと&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;用にそれぞれ計算サーバ書くのか、実装が複雑になってやだなぁ～と思っていたところ、実は勘違いである事が判明。&lt;/p&gt;
&lt;p&gt;以下のgpuinfoコマンドの出力は、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NVidia&quot;&gt;NVidia&lt;/a&gt;のCUDA 4.2と、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;のOpenCL &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SDK&quot;&gt;SDK&lt;/a&gt;を&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB&quot;&gt;インストール&lt;/a&gt;した環境でのもの。&lt;/p&gt;
&lt;p&gt;なんと、Platform-1で&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;が、Platform-2でCPUが認識されている。&lt;/p&gt;
&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NVidia&quot;&gt;NVidia&lt;/a&gt;のOpenCL&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%E9%A5%A4%A5%D6%A5%E9%A5%EA&quot;&gt;ライブラリ&lt;/a&gt;でも、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;のOpenCLライブラリでも同様。&lt;/p&gt;
&lt;p&gt;という事はですよ、要求された計算の特性に応じて、1個の計算サーバでCPU/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;を使い分けるという芸当もできるという事になるじゃありませんか。&lt;/p&gt;
&lt;p&gt;いやー、面白い。実装意欲を掻き立てられる。&lt;/p&gt;
&lt;p&gt;なお、以下のコマンド gpuinfo の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/URL&quot;&gt;URL&lt;/a&gt;は↓です。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/kaigai/gpuinfo&quot; target=&quot;_blank&quot;&gt;https://github.com/kaigai/gpuinfo&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;[kaigai@iwashi gpuinfo]$ ./gpuinfo
platform-index:      1
platform-vendor:     &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NVIDIA&quot;&gt;NVIDIA&lt;/a&gt; Corporation
platform-name:       &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NVIDIA&quot;&gt;NVIDIA&lt;/a&gt; CUDA
platform-version:    OpenCL 1.1 CUDA 4.2.1
platform-profile:    FULL_PROFILE
platform-extensions: cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing
 cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll
  Device-01
  Device type:                     &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GPU&quot;&gt;GPU&lt;/a&gt;
  Vendor:                          &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/NVIDIA&quot;&gt;NVIDIA&lt;/a&gt; Corporation (id: 000010de)
  Name:                            &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GeForce&quot;&gt;GeForce&lt;/a&gt; GT 640
  Version:                         OpenCL 1.1 CUDA
  Driver version:                  310.32
  OpenCL C version:                OpenCL C 1.1
  Profile:                         FULL_PROFILE
  Device available:                yes
  Address bits:                    32
  Compiler available:              yes
  Double FP config:                Denorm, INF/NaN, R/nearest, R/zero, R/INF, FMA
  Endian:                          little
  Error correction support:        no
  Execution capability:            kernel, native kernel
  Extensions:                      cl_khr_byte_addressable_store cl_khr_icd \
   cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query \
   cl_nv_pragma_unroll  cl_khr_global_int32_base_atomics \
   cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics \
   cl_khr_local_int32_extended_atomics cl_khr_fp64
  Global memory cache size:        32 KB
  Global memory cache type:        read-write
  Global memory cacheline size:    128
  Global memory size:              2047 MB
  Host unified memory:             no
  Image support:                   yes
  Image 2D max size:               32768 x 32768
  Image 3D max size:               4096 x 4096 x 4096
  Local memory size:               49152
  Local memory type:               &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SRAM&quot;&gt;SRAM&lt;/a&gt;
  Max clock frequency:             901
  Max compute units:               2
  Max constant args:               9
  Max constant buffer size:        65536
  Max memory allocation size:      511 MB
  Max parameter size:              4352
  Max read image args:             256
  Max samplers:                    32
  Max work-group size:             1024
  Max work-item sizes:             {1024,1024,64}
  Max write image args:            16
  Memory base address align:       4096
  Min data type align size:        128
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - char:      1
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - short:     1
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - int:       1
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - long:      1
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - float:     1
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - double:    1
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - char:   1
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - short:  1
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - int:    1
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - long:   1
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - float:  1
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - double: 1
  Profiling timer resolution:      1000
  Queue properties:                out-of-order execution, profiling
  Sindle FP config:                Denorm, INF/NaN, R/nearest, R/zero, R/INF, FMA

platform-index:      2
platform-vendor:     &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;(R) Corporation
platform-name:       &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;(R) OpenCL
platform-version:    OpenCL 1.2 &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/LINUX&quot;&gt;LINUX&lt;/a&gt;
platform-profile:    FULL_PROFILE
platform-extensions: cl_khr_fp64 cl_khr_icd cl_khr_global_int32_base_atomics \
  cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics \
  cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store \
  cl_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/intel&quot;&gt;intel&lt;/a&gt;_printf cl_ext_device_fission cl_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/intel&quot;&gt;intel&lt;/a&gt;_exec_by_local_thread
  Device-01
  Device type:                     CPU
  Vendor:                          &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;(R) Corporation (id: 00008086)
  Name:                                   &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Intel&quot;&gt;Intel&lt;/a&gt;(R) &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Xeon&quot;&gt;Xeon&lt;/a&gt;(R) CPU E5-2670 0 @ 2.60GHz
  Version:                         OpenCL 1.2 (Build 56860)
  Driver version:                  1.2
  OpenCL C version:                OpenCL C 1.2
  Profile:                         FULL_PROFILE
  Device available:                yes
  Address bits:                    64
  Compiler available:              yes
  Double FP config:                Denorm, INF/NaN, R/nearest, R/zero, R/INF, FMA
  Endian:                          little
  Error correction support:        no
  Execution capability:            kernel, native kernel
  Extensions:                      cl_khr_fp64 cl_khr_icd \
    cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics \
    cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics \
    cl_khr_byte_addressable_store cl_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/intel&quot;&gt;intel&lt;/a&gt;_printf cl_ext_device_fission \
    cl_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/intel&quot;&gt;intel&lt;/a&gt;_exec_by_local_thread
  Global memory cache size:        256 KB
  Global memory cache type:        read-write
  Global memory cacheline size:    64
  Global memory size:              386942 MB
  Host unified memory:             yes
  Image support:                   yes
  Image 2D max size:               16384 x 16384
  Image 3D max size:               2048 x 2048 x 2048
  Local memory size:               32768
  Local memory type:               &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/DRAM&quot;&gt;DRAM&lt;/a&gt;
  Max clock frequency:             2600
  Max compute units:               32
  Max constant args:               480
  Max constant buffer size:        131072
  Max memory allocation size:      96735 MB
  Max parameter size:              3840
  Max read image args:             480
  Max samplers:                    480
  Max work-group size:             1024
  Max work-item sizes:             {1024,1024,1024}
  Max write image args:            480
  Memory base address align:       1024
  Min data type align size:        128
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - char:      16
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - short:     8
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - int:       4
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - long:      2
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - float:     4
  Native &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - double:    2
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - char:   16
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - short:  8
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - int:    4
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - long:   2
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - float:  4
  Preferred &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/vector&quot;&gt;vector&lt;/a&gt; width - double: 2
  Profiling timer resolution:      1
  Queue properties:                out-of-order execution, profiling
  Sindle FP config:                Denorm, INF/NaN, R/nearest
&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;</description>
	<pubDate>Thu, 07 Mar 2013 23:00:00 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>Joshua Brindle: Security Anti-Pattern - Mobile Hypervisors (for user facing VM's)</title>
	<guid>http://securityblog.org/2013/02/11/security-anti-pattern-mobile-hypervisors</guid>
	<link>http://securityblog.org/2013/02/11/security-anti-pattern-mobile-hypervisors</link>
	<description>&lt;p&gt;One of the things I was working on for most of 2012 was mobile security, specifically SE Android.&lt;/p&gt;

&lt;p&gt;My exposure to mobile was limited to using smart phones and making minor customizations to third party ROM's before 2012.&lt;/p&gt;

&lt;p&gt;That would all change. A group of us started looking at a specific RFP that many believed would be the major mobile entréinto the federal government and military. It wasn't. It turned into a fiasco.&lt;/p&gt;

&lt;p&gt;What it did do, however, was solidify many people's belief that hypervisors on mobile platforms was the way to achieve multi-level cross domain access. It convinced me that they couldn't be more wrong.&lt;/p&gt;

&lt;p&gt;Since then, my colleagues and myself were on a mission to convince the world that virtualization on mobile for security is the wrong answer. Now that I am out on my own I want to take this opportunity to share some of my own beliefs on the matter.&lt;/p&gt;

&lt;p&gt;First a CYA part: Although these beliefs were formed while I was working elsewhere I have no reason to believe they are proprietary and I don't, in any way, represent anyone except myself.&lt;/p&gt;

&lt;h2&gt;The Fiasco&lt;/h2&gt;

&lt;p&gt;At the beginning I, like everyone else, had no reason to doubt all the vendors out there selling mobile virtualization solutions. After all, they had demos, they had huge numbers like deployed on 1.5 billion devices. Many proposal writers would have been satisfied with this and gone to the next issue. However, because of the insane schedule requirements of this particular RFP I wanted to make sure there was software available &lt;em&gt;today&lt;/em&gt; (which was March, 2012) that could be used immediately, on hardware that was already available.&lt;/p&gt;

&lt;p&gt;Boy, that is an interesting rabbit hole. Anyone working in mobile knows that information in general is hard to come by. Anecdotally, people working at major mobile device manufacturers sometimes have trouble getting spec sheets for their own phones. Mobile hypervisors are no exception, and possibly worse.&lt;/p&gt;

&lt;p&gt;Unlike Intel, which makes its own chips, ARM does not. Instead they license the chip designs to chip makers. Those makers, in general, are free to pick and choose various capabilities, extended instruction sets, add proprietary instruction sets, etc. They can even choose the endieness. This does not make a friendly environment for people who need to work very closely to the hardware, like a hypervisor developer.&lt;/p&gt;

&lt;p&gt;Like Intel, ARM has virtualization extensions. For quite a while, in fact. ARM also has TrustZone, which is made for DRM, but provides a secure-world split from the rest of the system, and can be used for a hypervisor. The challenge at the time was that &lt;em&gt;there were no mobile phones on the market that implemented either of these completely, correctly, or enabled&lt;/em&gt;. Further, TrustZone configuration is available only to the chip maker. This means that hypervisors that run on these technologies quite possibly work, on a development board, but not on any phones. Finally, a hardware vendor admitted that they never enable things like TrustZone because they didn't want to get into the key management business. Yay.&lt;/p&gt;

&lt;p&gt;Well, there is still paravirtualization, right? Paravirtualization is great, really. Except that it requires modifying the OS, more specifically it means modifying the drivers. So, onto lesson #2 for the mobile noobs. No one gets driver source code except the chip manufacturers. That includes the people packaging them up into boards, the people building phones, the people building the OS for the phones, etc. Some chip manufacturers won't even let Google release &lt;em&gt;binary&lt;/em&gt; blobs of their drivers on the website for Nexus devices, despite the fact that Nexus owners can unlock their phones and pull them all off.&lt;/p&gt;

&lt;p&gt;One conclusion was that, while someone with deep connections to the chip makers might be able to eventually produce a phone that can run a hypervisor for multiple guest operating systems, it wasn't happening with phones on the market at the time, it wasn't happening within the schedule of this particular RFP, and it certainly wasn't going to be us doing it.&lt;/p&gt;

&lt;h2&gt;Reset&lt;/h2&gt;

&lt;p&gt;So, now the belief I went into this with has been broken down. Why did we have that belief at all? Why did we start thinking it was the right answer? We fell into the same trap that everyone else did. The Cross Domain Solution community has forgotten its heritage. Virtualization has become the magic bullet for cross domain access solutions, but why?&lt;/p&gt;

&lt;p&gt;Once upon a time there were many trusted operating systems. They were mostly based on their non-trusted siblings. The names were straightforward; you had Trusted Solaris, Trusted IRIX, Trusted Xenix, etc. These were evaluated. You could run applications at multiple levels on them just fine. And people did, just not very many people.&lt;/p&gt;

&lt;p&gt;By the end of the UNIX wars, most of these systems were Trusted Solaris, but they still weren't in huge use. Most people had settled on Windows for their standard tasks. Windows applications didn't run on Trusted Solaris. In fact, modern Solaris applications didn't run on Trusted Solaris, which was typically a couple major releases behind.&lt;/p&gt;

&lt;p&gt;What to do? Well, SELinux was being developed. Virtualization was becoming possible on x86. The NSA tied the 2 together and released NetTop. You could now run Windows apps at multiple levels right next to each other on the same system, albeit very slowly. Then there were the various HAP (High Assurance Platform) projects, and other variations. Long story short, people started defaulting to 'virtualize for cross domain access', without even thinking.&lt;/p&gt;

&lt;p&gt;For mobile this trap can be avoided entirely. You have a platform, and people are using apps written for that platform, not for another platform. You don't need to virtualize to run the apps you want.&lt;/p&gt;

&lt;h2&gt;Security Anti-pattern&lt;/h2&gt;

&lt;p&gt;Up until now I've been focusing on why hypervisors aren't there for mobile, and why that was the default thought anyway, but not much about the security anti-pattern part. So lets get started on that.&lt;/p&gt;

&lt;p&gt;Mobile security is an interesting beast. It has all the issues of regular computing and a whole host of its own.&lt;/p&gt;

&lt;h3&gt;Power Management&lt;/h3&gt;

&lt;p&gt;Take power management, for example. On mobile systems you want the main application processor powered down as often as possible. How do you do that while maintaining a nice user experience? You don't want an app sitting in the background constantly polling for email, killing your battery, but you also don't want everything to fire up and go download data the instant the user unlocks the device, since that will make it unusable for some amount of time. Google implemented wakelocks for this purpose. They allow apps to notify the kernel that they are doing something, and that the kernel shouldn't put the device to sleep. You also want apps to be able to simultaneously use wakelocks, and let the system sleep sooner.&lt;/p&gt;

&lt;p&gt;Now, instead of just getting to the kernel above the apps, those wakelocks would need to make it all the way to the hypervisor. Further, without sharing wakelocks between VM's you'll have the same power draining serial usage of processor awake time.&lt;/p&gt;

&lt;p&gt;See what I did there? Automatic info-flow between VM's, regardless of whether you do it or not. If VM1 is doing something it'll keep the processor awake, VM2 will know. If you share wakelocks and VM1 is doing something VM2 will know.&lt;/p&gt;

&lt;p&gt;The old trusty high assurance MILS way of fixing this? Fixed time-slice scheduling. Give each VM X amount of time, move on to the next when time is up. In this world, how will the hypervisor know when to sleep? How do you manage talking on the phone, a somewhat real-time activity, if you are cycling through VM's? Finally, what is someone going to do with a phone that has a 1 hour battery life because VM's can't cooperate?&lt;/p&gt;

&lt;p&gt;So, choose between punching a hole in the hypervisor or getting miserable power performance.&lt;/p&gt;

&lt;h3&gt;Holes, holes everywhere&lt;/h3&gt;

&lt;p&gt;I already mentioned the issue with drivers. The current solution for hypervisors is to pass device access straight through to one (or more) of the VM's.&lt;/p&gt;

&lt;p&gt;This is pretty standard for all virtualization based cross domain solutions, actually. Hypervisors are suppose to be small, they can't have a graphics subsystem. By using an IOMMU they assign a single VM to manage graphics (and nothing else) and then assign the DMA memory range of the device to that VM. No other VM can access that memory, so then you build one-way pipelines from all the VM's to the graphics VM and let it do compositing, etc.&lt;/p&gt;

&lt;p&gt;As a sidenote, none of the solutions I know of actually have shared 3d acceleration, if you need 3d acceleration you have to lock a single VM to a video card.&lt;/p&gt;

&lt;p&gt;So, back to mobile. You &lt;em&gt;might&lt;/em&gt; be able to find an SoC with a working IOMMU, but I wouldn't count on it. I could find nothing of the sort back then.&lt;/p&gt;

&lt;p&gt;This same method is used for all kinds of devices, such as networking. With networking, however, you now have 2-way communication. High assurance systems will need separate network cards that can each be assigned to a single VM. How do you do this on a mobile device, where there is generally one cellular radio? Typically the idea is that you have separate encryption VM's for each user facing VM.&lt;/p&gt;

&lt;p&gt;How many device VM's are you willing to have? How many paths through the hypervisor do you open? How much security do you end up having when every device is shared between all VM's? What is the performance and power penalty if a simple action like downloading some data from a website, storing it to the filesystem and displaying a message to the screen involves no fewer than 4 VM's?&lt;/p&gt;

&lt;p&gt;In the end you have VM's that are trusted to do the separation between user-facing VM's instead of having the hypervisor solely doing that. This means that all those assurance arguments and the fact that your hypervisor only has 10k lines of code is irrelevant. You've just added a bunch of Linux kernels to your trusted base.&lt;/p&gt;

&lt;p&gt;In desktop virtualization based solutions these device managing VM's were typically SELinux systems. SE Android could be similarly used to lock down these systems, and at the time it was just being released. I figured that since it had to be done anyway, in order for the hypervisor use case to ever work, I might we well focus on it. At least then there would be a secure platform that could be used until the whole hypervisor thing got resolved. At this point my opinion is that even if they are available and working they aren't worth it, but I know many who disagree.&lt;/p&gt;

&lt;h3&gt;Functionality&lt;/h3&gt;

&lt;p&gt;Security is always at odds with functionality, by definition. Mobile users have fairly high expectations of their devices. One example is the ability to receive phone calls. Personally I have bad experiences with my smart phones receiving phone calls without extra security so this is a serious uphill battle.&lt;/p&gt;

&lt;p&gt;So, if a user is using a secret level VM, and his child's school calls on the unclass VM to tell him that his child has been hurt and is going to the hospital, should he be able to be receive that call? I don't think many people would want to use these devices if the answer is no, but what does saying yes entail? More holes punched through the hypervisor? Probably, but you've already made plenty of those.&lt;/p&gt;

&lt;p&gt;How about the baseband processor? Oh, right, I haven't mentioned that yet. Pretty much every smart phone has a whole 'nother processor, operating system and software stack connected to the radio. Sometimes this processor is actually primary (it bootstraps and starts the application processor).&lt;/p&gt;

&lt;p&gt;So, on some smart phones the baseband processor is connected directly to the microphone. Obviously while in the secret VM access to the microphone must be restricted. What does this mean? There must be a VM managing communication with the baseband processor, so it is going to have to make the hard decision as to allow the microphone to be used while a secret VM is active. This, obviously, opens all sorts of serious issues.&lt;/p&gt;

&lt;p&gt;There are many other examples of this. Switching between 5 VM's to check email isn't going to make anyone happy. Not getting text messages from the wife while at work may not make your home life better.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;You'll notice that the title of this entry specifically mentions user facing VM's on mobile devices. I do not object to using a hypervisor in conjunction with a specialized integrity measurement and monitoring system for attestation purposes. The device access necessary to such a VM would be minimal, and it would only need to do something when an attestation request was made, so it has no reason to wake up the phone. It also doesn't add many VM's that need to constantly be scheduled.&lt;/p&gt;

&lt;p&gt;I &lt;em&gt;do&lt;/em&gt; object to the sentiment that a hypervisor is &lt;em&gt;required&lt;/em&gt; for multi-level cross domain access on a mobile device. I believe the sentiment is guided by where the desktop multi-level market landed, without the requirements that got it there. Additionally, I believe, by the time you have a functional implementation you won't have any more assurance than running an SE Android system that implements multi-level access controls. On top of that, the system will be significantly less usable, battery life and performance will suffer, and you'll never get away from having to modify the underlying OS anyway.&lt;/p&gt;

&lt;p&gt;SE Android is being developed at a rapid pace and new features are added often. I can't wait to see where it goes, but I hope the hypervisor evangelists aren't able to take the steam out of it before it gets there.&lt;/p&gt;</description>
	<pubDate>Mon, 11 Feb 2013 06:00:00 +0000</pubDate>
</item>
<item>
	<title>Joshua Brindle: Big changes</title>
	<guid>http://securityblog.org/2013/02/06/big-changes</guid>
	<link>http://securityblog.org/2013/02/06/big-changes</link>
	<description>&lt;p&gt;New blogging system... Also I left Tresys.&lt;/p&gt;

&lt;p&gt;After almost 9 years there I have resigned, which was a hard thing to do.&lt;/p&gt;

&lt;p&gt;Spencer Shimko, Brandon Whalen and I left Tresys a couple weeks ago to start our own company, &lt;a href=&quot;http://quarksecurity.com/&quot;&gt;Quark Security&lt;/a&gt;. That decision wasn't easy but it is a good time in our careers and we all believe that we are prepared to succeed running our own company. We were joined by an ex-Tresys employee, Ed Sealing.&lt;/p&gt;

&lt;p&gt;So, after a very crazy 2012, almost entirely focusing on mobile security for me, we are going forward, trying to figure out how to make our mark on the world. We are learning about the nitty gritty details about government contracting that we were never exposed to before. It is all very fascinating and definitely unlike what I've done before.&lt;/p&gt;

&lt;p&gt;Strangely enough, my workload is much lighter at the moment, than it was before I left, so I hope to be able to spend some time writing up my thoughts on various things, including mobile security, before I get ramped back up to pre-leaving workloads.&lt;/p&gt;</description>
	<pubDate>Wed, 06 Feb 2013 06:00:00 +0000</pubDate>
</item>
<item>
	<title>James Morris: Save the Date: 2013 Linux Security Summit</title>
	<guid>http://blog.namei.org/?p=559</guid>
	<link>http://blog.namei.org/2013/02/04/save-the-date-2013-linux-security-summit/</link>
	<description>&lt;p&gt;This year&amp;#8217;s &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2013&quot;&gt;Linux Security Summit&lt;/a&gt; will be co-located with &lt;a href=&quot;http://events.linuxfoundation.org/events/linuxcon&quot;&gt;LinuxCon&lt;/a&gt; (along with &lt;a href=&quot;http://www.linuxplumbersconf.org/2013/&quot;&gt;Linux Plumbers&lt;/a&gt;) in New Orleans, USA, on the 19th and 20th of September.&lt;/p&gt;
&lt;p&gt;The format is expected to be similar to the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2012/Schedule&quot;&gt;2012&lt;/a&gt; summit.&lt;/p&gt;
&lt;p&gt;A CfP will be issued soon.&lt;/p&gt;</description>
	<pubDate>Mon, 04 Feb 2013 04:38:37 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Russell Coker (security): SE Linux Things To Do</title>
	<guid>http://etbe.coker.com.au/?p=3654</guid>
	<link>http://etbe.coker.com.au/2013/01/31/selinux-todo/</link>
	<description>&lt;p&gt;At the end of &lt;a href=&quot;http://etbe.coker.com.au/2013/01/28/selinux-status-lca2013/&quot;&gt;my talk on Monday about the status of SE Linux [1]&lt;/a&gt; I described some of the things that I want to do with SE Linux in Debian (and general SE Linux stuff). Here is a brief summary of some of them:&lt;/p&gt;
&lt;p&gt;One thing I&amp;#8217;ve wanted to do for years is to get X Access Controls working in Debian. This means that two X applications could have windows on the same desktop but be unable to communicate with each other by any of the X methods (this includes screen capture and clipboard). It seems that the Fedora people are moving to sandbox processes with Xephyr for X access (&lt;a href=&quot;http://danwalsh.livejournal.com/31146.html&quot;&gt;see Dan Walsh&amp;#8217;s blog post about sandbox -X [2]&lt;/a&gt;). But XAce will take a lot of work and time is always an issue.&lt;/p&gt;
&lt;p&gt;An ongoing problem with SE Linux (and most security systems) is the difficulty in running applications with minimum privilege. One example of this is utility programs which can be run by multiple programs, if a utility is usually run by a process that is privileged then we probably won&amp;#8217;t notice that it requires excess privileges until it&amp;#8217;s run in a different context. This is a particular problem when trying to restrict programs that may be run as part of a user session. A common example is programs that open files read-write when they only need to read them, if the program then aborts when it can&amp;#8217;t open the file in question then we will have a problem when it&amp;#8217;s run from a context that doesn&amp;#8217;t grant it write access. To deal with such latent problems I am considering ways of analysing the operation of systems to try and determine which programs request more access than they really need.&lt;/p&gt;
&lt;p&gt;During my talk I discussed the possibility of using a shared object to log file open/read/write to find such latent problems. A member of the audience suggested static code analysis which seems useful for some languages but doesn&amp;#8217;t seem likely to cover all necessary languages. Of course the benefit of static code analysis is that it will catch operations that the program doesn&amp;#8217;t perform in a test environment &amp;#8211; error handling is one particularly important corner case in this regard.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://etbe.coker.com.au/2013/01/28/selinux-status-lca2013/&quot;&gt; http://etbe.coker.com.au/2013/01/28/selinux-status-lca2013/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[2]&lt;a href=&quot;http://danwalsh.livejournal.com/31146.html&quot;&gt; http://danwalsh.livejournal.com/31146.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2009/11/17/debian-ssh-se-linux/&quot; rel=&quot;bookmark&quot; title=&quot;Debian SSH and SE Linux&quot;&gt;Debian SSH and SE Linux &lt;/a&gt; &lt;small&gt;I have just filed Debian bug report #556644 against the...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2011/07/22/run-se-linux-policy/&quot; rel=&quot;bookmark&quot; title=&quot;/run and SE Linux Policy&quot;&gt;/run and SE Linux Policy &lt;/a&gt; &lt;small&gt;Currently Debian/Unstable is going through a transition to using /run...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2012/06/22/se-linux-policy-wheezy/&quot; rel=&quot;bookmark&quot; title=&quot;New SE Linux Policy for Wheezy&quot;&gt;New SE Linux Policy for Wheezy &lt;/a&gt; &lt;small&gt;I&amp;#8217;ve just uploaded a new SE Linux policy for Debian/Wheezy....&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Wed, 30 Jan 2013 21:16:33 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Russell Coker (security): My SE Linux Status Report – LCA 2013</title>
	<guid>http://etbe.coker.com.au/?p=3650</guid>
	<link>http://etbe.coker.com.au/2013/01/28/selinux-status-lca2013/</link>
	<description>&lt;p&gt;This morning I gave a status report on SE Linux. The talk initially didn&amp;#8217;t go too well, I wasn&amp;#8217;t in the right mental state for it and I moved through the material too fast. Fortunately Casey Schaufler asked some really good questions which helped me to get back on track. The end result seemed reasonably good. Here&amp;#8217;s a summary of the things I discussed:&lt;/p&gt;
&lt;p&gt;Transaction hooks for RPM to support SE Linux operations. This supports signing packages to indicate their security status and preventing packages from overwriting other packages or executing scripts in the wrong context. There is also work to incorporate some of the features of that into &amp;#8220;dpkg&amp;#8221; for Debian.&lt;/p&gt;
&lt;p&gt;Some changes to libraries to allow faster booting. Systems with sysvinit and a HDD won&amp;#8217;t be affected but with systemd and SSD it makes a real difference. Mostly Red Hat&amp;#8217;s work.&lt;/p&gt;
&lt;p&gt;Filename transition rules to allow the initial context to be assigned based on file name were created in 2011 but are not starting to get used.&lt;/p&gt;
&lt;p&gt;When systemd is used for starting/stopping daemons some hacks such as run_init can be avoided. Fedora is making the best progress in this regard due to only supporting systemd while the support for other init systems will limit what we can do for Debian. This improves security by stopping terminal buffer insertion attacks while also improving reliability by giving the daemon the same inherited settings each time it&amp;#8217;s executed.&lt;/p&gt;
&lt;p&gt;Labelled NFS has been accepted as part of the NFSv4.2 specification. This is a big deal as labelled NFS work has been going for many years without hitting such a milestone in the past.&lt;/p&gt;
&lt;p&gt;ZFS and BTRFS support but we still need to consider management issues for such snapshot based filesystems. Filesystem snapshots have the potential to interact badly with relabelling if we don&amp;#8217;t develop code and sysadmin practices to deal with it properly.&lt;/p&gt;
&lt;p&gt;The most significant upstream focus of SE Linux development over the last year is SE Android. I hope that will result in more work on the X Access Controls for use on the desktop.&lt;/p&gt;
&lt;p&gt;During question time I also gave a 3 minute &amp;#8220;lightning talk&amp;#8221; description of SE Linux.&lt;/p&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2012/01/25/se-linux-status-2012-01/&quot; rel=&quot;bookmark&quot; title=&quot;SE Linux Status in Debian 2012-01&quot;&gt;SE Linux Status in Debian 2012-01 &lt;/a&gt; &lt;small&gt;Since my last SE Linux in Debian status report [1]...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2012/06/17/debian-selinux-june-2012/&quot; rel=&quot;bookmark&quot; title=&quot;Debian SE Linux Status June 2012&quot;&gt;Debian SE Linux Status June 2012 &lt;/a&gt; &lt;small&gt;It&amp;#8217;s almost the Wheezy freeze time and I&amp;#8217;ve been working...&lt;/small&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2009/01/20/status-se-linux-debian-lca2009/&quot; rel=&quot;bookmark&quot; title=&quot;Status of SE Linux in Debian LCA 2009&quot;&gt;Status of SE Linux in Debian LCA 2009 &lt;/a&gt; &lt;small&gt;This morning I gave a talk at the Security mini-conf...&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Mon, 28 Jan 2013 02:56:30 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>Dan Walsh: Where did audit2allow go in Fedora 18?</title>
	<guid>http://danwalsh.livejournal.com/61710.html</guid>
	<link>http://danwalsh.livejournal.com/61710.html</link>
	<description>One of the goals of Fedora 18 is to shrink the size of the Minimal install as much as possible.&amp;nbsp;&amp;nbsp; We are concentrating on keeping this minimal.&lt;br /&gt;&lt;br /&gt;Since a minimal install machine does not need to do SELinux policy development, it was decided to remove the selinux-policy-devel package from the minimal install, which is fairly large.&amp;nbsp; But audit2allow was in policycoreutils-python, and required the selinux-policy-devel package.&amp;nbsp; audit2allow needs the interface files in selinux-policy-devel package in order for&amp;nbsp; &lt;span&gt;audit2allow -R to work.&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I decided to move the audit2allow script to policycoreutils-devel package, since its main job is to help develop selinux-policy.&lt;br /&gt;If you do not find audit2allow you your system, just&lt;br /&gt;&lt;br /&gt;&lt;span&gt;yum install policycoreutils-devel&lt;/span&gt;&lt;br /&gt;or&lt;br /&gt;&lt;span&gt;yum install /usr/bin/audit2allow &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: The latest setroubleshoot-server package requires policycoreutils-devel, so if you have this installed you will get audit2allow for free...</description>
	<pubDate>Fri, 18 Jan 2013 14:37:20 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: rsync and SELinux</title>
	<guid>http://danwalsh.livejournal.com/61646.html</guid>
	<link>http://danwalsh.livejournal.com/61646.html</link>
	<description>I have been pinged by a couple of users having problems with SELinux and rsync.&amp;nbsp; We began confining the rsync service back in RHEL5.&lt;br /&gt;&lt;br /&gt;The biggest problem SELinux has with rsync is there is no way to distinguish between the client and the server from an SELinux point of view.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;rsync as a daemon&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If someone sets up an rsync service to listen for connections they use the /usr/bin/rsync executable.&amp;nbsp; In order to confine this application we label /usr/bin/rsync as rsync_exec_t.&amp;nbsp; The init daemons (init_t, initrc_t) will transition to rsync_t when they execute /usr/bin/rsync. SELinux policy allows share parts of the host, mainly readonly, and allows admins to setup directories labeled rsync_data_t where content could be uploaded to the rsync domain.&lt;br /&gt;&lt;br /&gt;There are lots of booleans defined for rsync_t to share data.&amp;nbsp; On Fedora 18, I see.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;getsebool -a | grep rsync&lt;br /&gt;postgresql_can_rsync --&amp;gt; off&lt;br /&gt;rsync_anon_write --&amp;gt; off&lt;br /&gt;rsync_client --&amp;gt; off&lt;br /&gt;rsync_export_all_ro --&amp;gt; off&lt;br /&gt;rsync_use_cifs --&amp;gt; off&lt;br /&gt;rsync_use_nfs --&amp;gt; of&lt;br /&gt;&lt;br /&gt;man rsync_selinux &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;to see more info.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;rsync as a client.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If you execute rsync as a client from a user script, everything works fine, since we do not transition from unconfined_t or other user domains to rsync_t, rsync runs within the user domain and is able to read/write anything the user process label is allowed to read/write.&lt;br /&gt;&lt;br /&gt;If a service that SELinux does not have policy runs runs within the init system and attempts to use rsync as a client it can have problems.&amp;nbsp; You see the service running within the init system that has no policy will run as either init_t or initrc_t.&amp;nbsp; When a process running as init_t or initrc_t executes /usr/bin/rsync (rsync_exec_t), the rsync process will transition to rsync_t and SELinux will treat it as the rsync daemon not as a client.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;There are many possible solutions for this problem.&amp;nbsp;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Best would be to write policy for the init service that is currently running without confinement.&amp;nbsp;&amp;nbsp; I realize&amp;nbsp; that most users will not do this, but you could contact us for help.&lt;/li&gt;&lt;li&gt;In RHEL5 you could turn on the rsync_disable_trans boolean.&amp;nbsp; Which will stop the transition from initrc_t to rsync_t, and rsync_t would just tun in&amp;nbsp; initrc_t domain, which by default is an unconfined domain.&lt;/li&gt;&lt;li&gt;You could use audit2allow to add all of the rules to rsync_t to allow it to run as a client.&lt;/li&gt;&lt;li&gt;You could change the label of /usr/bin/rsync to bin_t using semanage fcontext -m -t bin_t /usr/bin/rsync which would also stop the transition.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/47066.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;You could make rsync_t an unconfined domain.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;There are many ways of fixing this problem.&amp;nbsp; And perhaps I need to talk to the rsync packagers to see if we could figure a better way of handling this in the future.&amp;nbsp;</description>
	<pubDate>Mon, 07 Jan 2013 16:28:59 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Russell Coker (security): Finding an ATM Skimmer</title>
	<guid>http://etbe.coker.com.au/?p=3575</guid>
	<link>http://etbe.coker.com.au/2012/12/23/finding-an-atm-skimmer/</link>
	<description>&lt;p&gt;A member of &lt;a href=&quot;http://www.sage-au.org.au/&quot;&gt;SAGE-AU [1]&lt;/a&gt; found two &lt;a href=&quot;http://en.wikipedia.org/wiki/Skimming_(credit_card_fraud)#Skimming&quot;&gt;ATM skimmers [2]&lt;/a&gt; and gave me permission to publish his description and analysis of the situation. I&amp;#8217;ve lightly edited this from a mailing list post to a blog format with permission from the author. &lt;a href=&quot;http://www.couriermail.com.au/news/queensland/european-atm-skimming-machine-your-credit-cards-new-worst-enemy-in-australian-crime-first/story-e6freoof-1226521141277&quot;&gt;This Courier-Mail article refers to the skimmers in question [3]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;People were wondering what gave the skimmers away so here goes, NB this is only about the 2 I discovered.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The actual atms in question were the free standing type (but even this doesn&amp;#8217;t matter in the scheme of things because they can be on those in a bank of the things).&lt;/li&gt;
&lt;li&gt;I&amp;#8217;d actually conducted transaction and was waiting for my card to come out of the machine &amp;#8211; these things looked that good. The colours matched &amp;#8211; especially in the 3/4 or less light that you typically have on the fascia&amp;#8217;s of such machine. The backing plate grey matched atm fascia as did the green &amp;#8220;bubble&amp;#8221; where the card goes.&lt;/li&gt;
&lt;li&gt;WHAT REALLY CAUSED SUSPICION &amp;#8211; my card was having difficulty coming out of the atm at end of transaction i.e. card coming out extra slow &amp;#8211; then only the end couple of mm, I had to physically grab my card with fingertips to get it out and there was barely perceptible movement of skimmer due to my fingers using the green &amp;#8220;bubble&amp;#8221; as purchase point, THAT was what made me suspect. I then really had close look and found that I could move the &amp;#8220;bubble&amp;#8221; with its backing plate &amp;#8211; I pulled it off the machine and then looked at the atm next to it and found it to look exactly the same. These things are held on by double sided tape.&lt;/li&gt;
&lt;li&gt;Grabbed the cleaning lady wandering past showed her the device and asked her to get security. Security and centre operations manager subsequently showed up, while waiting for them I had to stop people from using either machine (everyone amazed at how good these things looked). Centre ops guy went and checked other machines in the centre, I left my details and they called the cops&amp;#8230; I went straight to my credit union and reported what had happened and they cancelled my card and ordered a new one on the spot for me.&lt;/li&gt;
&lt;li&gt;Coincidently (or not) the centre ops and security lady told me that the machines had been serviced (refilled) not too much earlier that day &amp;#8211; i.e. I wondered if the bad guys did the &amp;#8220;service&amp;#8221; or were tracking armaguard servicing types.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Quick side notes: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;3 more skimmers have been found since then.&lt;/li&gt;
&lt;li&gt;Subsequently, I found out these were the type that needed to be picked up for the bad guys to retrieve the data i.e. these weren&amp;#8217;t the type that transmitted to some-one sitting near by via Bluetooth/wireless i.e. in this instance I need not have cancelled my card and gotten a new one from my credit union.&lt;br /&gt;HOWEVER, it is best practice if you discover one and you&amp;#8217;ve used that machine to immediately have your financial institution cancel your card and issue you a new one &amp;#8211; though getting the new one can take up to a week.&lt;/li&gt;
&lt;li&gt;As I understand it, These 2 devices (i.e. others could be different) have 2 usb ports one for the reader and the other to a pinhole camera (commercially available type removed from it&amp;#8217;s original housing). The magnetic stripe data is held on the audio track associated with the video and there was an 8GB storage card to hold it all i.e. it makes things easier for the bad guys to match PINs to card details.&lt;/li&gt;
&lt;li&gt;If you do find a skimmer DO NOT touch the insides (non public facing parts) of it &amp;#8211; this is where the cops can really try lift dna and prints from; gathering prints from externally is far more fraught as everyone and their dog has probably touched the exterior of the skimmer.&lt;/li&gt;
&lt;li&gt;In the lead up to Xmas these things or similar are highly likely to become more prevalent as we all go about parting with dosh  while gift shopping &amp;#8211; SO BE AWARE AND CAREFUL.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;[1]&lt;a href=&quot;http://www.sage-au.org.au/&quot;&gt; http://www.sage-au.org.au/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[2]&lt;a href=&quot;http://en.wikipedia.org/wiki/Skimming_(credit_card_fraud)#Skimming&quot;&gt; http://en.wikipedia.org/wiki/Skimming_(credit_card_fraud)#Skimming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;[3]&lt;a href=&quot;http://www.couriermail.com.au/news/queensland/european-atm-skimming-machine-your-credit-cards-new-worst-enemy-in-australian-crime-first/story-e6freoof-1226521141277&quot;&gt; http://tinyurl.com/aqu9yb6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;yarpp-related-rss&quot;&gt;
&lt;p&gt;Related posts:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://etbe.coker.com.au/2009/06/14/finding-thread-unsafe-code/&quot; rel=&quot;bookmark&quot; title=&quot;Finding Thread-unsafe Code&quot;&gt;Finding Thread-unsafe Code&lt;/a&gt; &lt;small&gt;One problem that I have had on a number of...&lt;/small&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description>
	<pubDate>Sun, 23 Dec 2012 01:08:49 +0000</pubDate>
	<dc:creator>etbe</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: SE-PostgreSQLでリモートプロセスのセキュリティラベルを使用する</title>
	<guid>hatenablog://entry/12704830469096319076</guid>
	<link>http://kaigai.hatenablog.com/entry/20121206/1354771579</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://atnd.org/events/34176&quot;&gt;PostgreSQL Advent Calendar 2012&lt;/a&gt;に参加しています。&lt;/p&gt;

&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;何を設定する必要があるのか？&lt;/h4&gt;
    &lt;p&gt;何か世のため人のためになりそうなネタは・・・という事で、SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;でリモートプロセスのセキュリティラベルを使用する方法をまとめてみました。&lt;/p&gt;&lt;p&gt;v9.1からサポートされたSE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;は、OSの機能である&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;と連携して、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SQL&quot;&gt;SQL&lt;/a&gt;を介したDBオブジェクトへのアクセスに対して強制アクセス制御を行う機能です。&lt;br /&gt;
かいつまんで言えば、○○のテーブルは機密度の高い情報を持っている、□□は機密度が低いと言った形で、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;標準のDBアクセス制御機能に加えて、OSの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%BB%A5%AD%A5%E5%A5%EA%A5%C6%A5%A3%A5%DD%A5%EA%A5%B7%A1%BC&quot;&gt;セキュリティポリシー&lt;/a&gt;に従ってアクセス制御を行います。そのため、同じ”情報”であるにも関わらず、保存先がファイルかデータベースかといった”格納手段”によって異なるポリシーでアクセス制御が行われる事を避ける事ができます。&lt;br /&gt;
SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;が追加のアクセス制御を行う際には、『誰が（subject）』『何に（object）』『何をする（action）』のかをひとまとめにして、OSの一部である&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;に伺いを立てるのですが、この時に『誰が』『何に』を識別するために、セキュリティコンテキストと呼ばれる特別な識別子が使用されます。&lt;br /&gt;
セキュリティコンテキストというのはこんな感じです。ファイルのセキュリティコンテキストを確認するには ls -Z を、プロセスの場合は ps -Z や id -Z を実行して確認できます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[kaigai@iwashi ~]$ ls -Z
drwxr-xr-x. kaigai users unconfined_u:object_r:user_home_t:s0 patch/
drwxr-xr-x. kaigai users unconfined_u:object_r:user_home_t:s0 repo/
drwxr-xr-x. kaigai users unconfined_u:object_r:user_home_t:s0 rpmbuild/
drwxr-xr-x. kaigai users unconfined_u:object_r:user_home_t:s0 source/
drwxr-xr-x. kaigai users unconfined_u:object_r:user_home_t:s0 tmp/
[kaigai@iwashi ~]$ ps -Z
LABEL                             PID TTY          TIME CMD
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 28791 pts/4 00:00:00 bash
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 29093 pts/4 00:00:00 ps&lt;/pre&gt;&lt;p&gt;DBオブジェクトの場合はSECURITY LABEL構文を用いて設定できるほか、システムビューのpg_seclabelsを用いて参照する事ができます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;postgres=# SELECT provider,label FROM pg_seclabels
              WHERE objtype = 'table' AND objname = 't1';
 provider |                  label
----------+------------------------------------------
 selinux  | unconfined_u:object_r:sepgsql_table_t:s0
(1 row)&lt;/pre&gt;&lt;p&gt;そしてDB利用者の場合。やっと今回の記事の主題にたどり着けたワケですが、SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;は『接続元プロセスのセキュリティコンテキスト』をDB利用者のセキュリティコンテキスト（= DB利用者の権限）として扱います。&lt;/p&gt;&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;は&lt;tt&gt;getpeercon(3)&lt;/tt&gt;という&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/API&quot;&gt;API&lt;/a&gt;を持っており、この人はソケットのファイル&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%B9%A5%AF%A5%EA%A5%D7%A5%BF&quot;&gt;ディスクリプタ&lt;/a&gt;を引数として与えると、接続相手のセキュリティコンテキストを返します。SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;はこの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/API&quot;&gt;API&lt;/a&gt;を使用して『接続元プロセスのセキュリティコンテキスト』を取得しています。&lt;br /&gt;
で、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/UNIX&quot;&gt;UNIX&lt;/a&gt;ドメインソケットによるローカル接続の場合は特別な設定は何も必要ないのですが、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/TCP/IP&quot;&gt;TCP/IP&lt;/a&gt;によるリモート接続の場合、OSは相手側プロセスの情報を持っていないため、ネットワーク接続の確立に先立って双方のセキュリティコンテキストを交換する Labeled Network の設定を行う必要があります。&lt;br /&gt;
この機能、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Linux&quot;&gt;Linux&lt;/a&gt; kernel 2.6.16 からサポートされた機能で、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;の鍵交換デーモンである racoon と連携してネットワーク接続先とセキュリティコンテキストを交換します。つまり、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;で通信経路が保護されている（少なくとも、改ざん検知できる）事が前提です。&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;が前提ですよ。大切な事なので２回書きました。&lt;/p&gt;&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Linux&quot;&gt;Linux&lt;/a&gt; kernelのバージョンからも分かるようにそれほど新しい機能ではないのですが、意外と設定手順がドキュメント化されていませんので、少しまとめてみました。&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;テスト環境の構成&lt;/h4&gt;
    &lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;の設定を極める事が目的ではありませんので、今回は、最も単純なHost-to-HostのPSK(Pre-Shared Key)の構成で&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;通信経路を作成します。その上で、Labeled Networkの設定を追加する事にします。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206044548&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206044548.png&quot; alt=&quot;f:id:kaigai:20121206044548p:image&quot; title=&quot;f:id:kaigai:20121206044548p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
今回のテスト環境では、2台のホストをそれぞれサーバとクライアントに見立てて設定を行いました。kg1(192.168.1.42)がクライアント、kg2(192.168.1.43)がサーバであると想定し、この2台の間に&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;の接続を設定します。&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%B9%A5%C8%A5%EA%A5%D3%A5%E5%A1%BC%A5%B7%A5%E7%A5%F3&quot;&gt;ディストリビューション&lt;/a&gt;は &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Fedora&quot;&gt;Fedora&lt;/a&gt; 17 を使用し、Development Workstation構成で&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%AF%A5%EA%A1%BC%A5%F3%A5%A4%A5%F3%A5%B9%A5%C8%A1%BC%A5%EB&quot;&gt;クリーンインストール&lt;/a&gt;しました。&lt;/p&gt;&lt;p&gt;なお、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;接続の設定に関しては&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Fedora%20Project&quot;&gt;Fedora Project&lt;/a&gt;のドキュメントを参考にしています。&lt;br /&gt;
詳しくは&lt;a href=&quot;http://docs.fedoraproject.org/en-US/Fedora/14/html/Security_Guide/sect-Security_Guide-Virtual_Private_Networks_VPNs-IPsec_Host_to_Host_Configuration.html&quot;&gt;IPsec Host-to-Host Configuration&lt;/a&gt;を参照してください。&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;事前の設定&lt;/h4&gt;
    
&lt;div class=&quot;section&quot;&gt;
    &lt;h5&gt;パッケージの追加&lt;/h5&gt;
    &lt;p&gt;インストール直後の状態では &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/ipsec&quot;&gt;ipsec&lt;/a&gt;-tools と system-config-network パッケージが導入されていませんので、両ホストでこれらのパッケージをインストールします。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# yum install -y ipsec-tools system-config-network&lt;/pre&gt;&lt;p&gt;また、サーバ側には &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/postgresql&quot;&gt;postgresql&lt;/a&gt;-server と &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/postgresql&quot;&gt;postgresql&lt;/a&gt;-contrib パッケージが、クライアント側には &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/postgresql&quot;&gt;postgresql&lt;/a&gt; パッケージが必要です。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# yum install -y postgresql-server postgresql-contrib&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;# yum install -y postgresql&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h5&gt;ファイアウォールの設定&lt;/h5&gt;
    &lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;の鍵交換デーモンの通信と&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;サーバへの接続にはファイアウォールの設定変更が必要です。&lt;br /&gt;
system-config-firewallを実行して関連するポートを解放してください。&lt;br /&gt;
&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206050923&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206050923.png&quot; alt=&quot;f:id:kaigai:20121206050923p:image&quot; title=&quot;f:id:kaigai:20121206050923p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;の鍵交換デーモン用ポートは、サーバ側/クライアント側の双方で解放が必要です。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206050922&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206050922.png&quot; alt=&quot;f:id:kaigai:20121206050922p:image&quot; title=&quot;f:id:kaigai:20121206050922p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;サーバ用ポートは、サーバ側で解放が必要です。&lt;/p&gt;&lt;p&gt;これらの設定を保存し、有効化してください。&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h5&gt;NetworkManagerの無効化&lt;/h5&gt;
    &lt;p&gt;ちょっとダサいのですが、NetworkManager経由でうまくipsec0デバイスを自動起動させる事ができなかったので、レガシーなnetworkスクリプトによってネットワークデバイスをup/downさせる事にします。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# chkconfig NetworkManager off
# chkconfig network on&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;Host-to-Host &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt; デバイスの作成&lt;/h4&gt;
    &lt;p&gt;今回は、system-config-networkを使ってipsec0デバイスの定義ファイルや、racoonの設定ファイルを自動生成させる方法でHost-to-Hostの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;デバイスを作成します。&lt;br /&gt;
まず、system-config-networkを実行して設定&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/GUI&quot;&gt;GUI&lt;/a&gt;を起動します。&lt;br /&gt;
&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045148&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045148.png&quot; alt=&quot;f:id:kaigai:20121206045148p:image&quot; title=&quot;f:id:kaigai:20121206045148p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
起動画面です。『&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;』のタブを選択します。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045147&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045147.png&quot; alt=&quot;f:id:kaigai:20121206045147p:image&quot; title=&quot;f:id:kaigai:20121206045147p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
左上の『New』をクリックすると、ウィザード形式で&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;設定を追加することができます。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045145&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045145.png&quot; alt=&quot;f:id:kaigai:20121206045145p:image&quot; title=&quot;f:id:kaigai:20121206045145p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
デバイス名を入力します。ここでは『ipsec0』としました。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045144&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045144.png&quot; alt=&quot;f:id:kaigai:20121206045144p:image&quot; title=&quot;f:id:kaigai:20121206045144p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
今回は『Host-to-Host encryption』を選択します。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045143&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045143.png&quot; alt=&quot;f:id:kaigai:20121206045143p:image&quot; title=&quot;f:id:kaigai:20121206045143p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
『Automatic encryption mode selection via IKA (racoon)』を選択します。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045142&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045142.png&quot; alt=&quot;f:id:kaigai:20121206045142p:image&quot; title=&quot;f:id:kaigai:20121206045142p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
この設定での接続相手先の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IP%A5%A2%A5%C9%A5%EC%A5%B9&quot;&gt;IPアドレス&lt;/a&gt;を入力します。画面は192.168.1.42ホストのものなので、接続先は『192.168.1.43』となります。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045141&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045141.png&quot; alt=&quot;f:id:kaigai:20121206045141p:image&quot; title=&quot;f:id:kaigai:20121206045141p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
事前共有型の認証キーを入力します。ここでは『sepgsql920』としました。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045140&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045140.png&quot; alt=&quot;f:id:kaigai:20121206045140p:image&quot; title=&quot;f:id:kaigai:20121206045140p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
入力したパラメータを確認して『Apply』をクリックします。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045139&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045139.png&quot; alt=&quot;f:id:kaigai:20121206045139p:image&quot; title=&quot;f:id:kaigai:20121206045139p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
これで『ipsec0』デバイスが作成されているのが分かります。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20121206045235&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20121206/20121206045235.png&quot; alt=&quot;f:id:kaigai:20121206045235p:image&quot; title=&quot;f:id:kaigai:20121206045235p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
設定を保存すると、右上の『Activate』『Deactivate』を選択することができるようになりますので、『Activate』をクリックしてください。&lt;/p&gt;&lt;p&gt;もう一方のノードでも同様の設定を行います。&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;の動作確認&lt;/h4&gt;
    &lt;p&gt;ひとまず、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;関連の設定が絡まない範囲でHost-to-Host設定の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;がちゃんと動作しているかを確認します。双方のノードでネットワークを再起動します。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# service network restart&lt;/pre&gt;&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/tcpdump&quot;&gt;tcpdump&lt;/a&gt;でパケットを観察すると、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;のAH/ESPプロトコルが使われている事が分かります。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[root@kg2 ~]# tcpdump -n -i eth1 host 192.168.1.42
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
16:55:34.979277 IP 192.168.1.42 &amp;gt; 192.168.1.43: \
    AH(spi=0x03850f37,seq=0x10): ESP(spi=0x0f3c888b,seq=0x10), length 76
16:55:34.979505 IP 192.168.1.43 &amp;gt; 192.168.1.42: \
    AH(spi=0x0ebad42b,seq=0x6): ESP(spi=0x0183d073,seq=0x6), length 76
16:55:34.980000 IP 192.168.1.42 &amp;gt; 192.168.1.43: \
    AH(spi=0x03850f37,seq=0x11): ESP(spi=0x0f3c888b,seq=0x11), length 68
    :
    :&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;Labeled Network の設定&lt;/h4&gt;
    &lt;p&gt;ipsec0デバイスを起動する時に、どの相手との接続に&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;を使うのか、その際のアルゴリズムは何なのか…という事がOS側に伝えられます。これを行うのがsetkeyコマンドなのですが、通常、これはifcfg-ipsec0の記述に基づいて（ここにスクリプトファイル名）が自動的に実行されます。&lt;br /&gt;
実際には以下のような書式をsetkeyコマンドに与えるのですが、Labeled Networkを使用するにあたって重要なのは、2行目の-ctxから始まる行です。これを指定する事で、この&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;通信経路ではLabeled Networkを使用するという事を宣言できます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;spdadd 192.168.11.6 192.168.11.8 any
-ctx 1 1 &quot;system_u:object_r:ipsec_spd_t:s0&quot;
-P out ipsec esp/transport//require;&lt;/pre&gt;&lt;p&gt;が、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Fedora&quot;&gt;Fedora&lt;/a&gt;のInitスクリプトから実行される/etc/sysconfig/network-scripts/ifup-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/ipsec&quot;&gt;ipsec&lt;/a&gt;は、この辺の設定を行うための処理が入っていません。そこで、パッチを当てる事にしました（うげげ…）。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;--- ifup-ipsec.orig	2012-12-03 17:41:38.809689669 +0100
+++ ifup-ipsec	2012-12-04 17:52:43.356150231 +0100
@@ -123,6 +123,8 @@ if [ &quot;$ESP_PROTO&quot; = &quot;none&quot; ]; then
     unset SPI_ESP_IN SPI_ESP_OUT KEY_ESP_IN KEY_ESP_OUT SPD_ESP_IN SPD_ESP_OUT
 fi
 
+test -n &quot;$SELINUX_CONTEXT&quot; &amp;amp;&amp;amp; SELINUX_CONTEXT=&quot;\&quot;${SELINUX_CONTEXT}\&quot;&quot;
+
 /sbin/setkey -c &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;lt;&amp;lt; EOF
 ${SPI_AH_OUT:+delete $SRC $DST ah $SPI_AH_OUT;}
 ${SPI_AH_IN:+delete $DST $SRC ah $SPI_AH_IN;}
@@ -164,33 +166,45 @@ EOF
 # This looks weird but if you use both ESP and AH you need to configure them together, not seperately.
 if [ &quot;$ESP_PROTO&quot; != &quot;none&quot; ] &amp;amp;&amp;amp; [ &quot;$AH_PROTO&quot; != &quot;none&quot; ]; then
 /sbin/setkey -c &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;lt;&amp;lt; EOF
-spdadd $SPD_SRC $SPD_DST any -P out ipsec
+spdadd $SPD_SRC $SPD_DST any
+            ${SELINUX_CONTEXT:+-ctx 1 1 ${SELINUX_CONTEXT}}
+            -P out ipsec
             ${SPD_ESP_OUT:+esp/$MODE/${TUNNEL_MODE:+$SRC-$DST}/require}
             ${SPD_AH_OUT:+ah/$MODE/${TUNNEL_MODE:+$SRC-$DST}/require}
 	    ;
 
-spdadd $SPD_DST $SPD_SRC any -P in ipsec
+spdadd $SPD_DST $SPD_SRC any
+            ${SELINUX_CONTEXT:+-ctx 1 1 ${SELINUX_CONTEXT}}
+            -P in ipsec
 	    ${SPD_ESP_IN:+esp/$MODE/${TUNNEL_MODE:+$DST-$SRC}/require}
 	    ${SPD_AH_IN:+ah/$MODE/${TUNNEL_MODE:+$DST-$SRC}/require}
 	    ;
 EOF
 elif [ &quot;$AH_PROTO&quot; = &quot;none&quot; ]; then
 /sbin/setkey -c &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;lt;&amp;lt; EOF
-spdadd $SPD_SRC $SPD_DST any -P out ipsec
+spdadd $SPD_SRC $SPD_DST any
+            ${SELINUX_CONTEXT:+-ctx 1 1 ${SELINUX_CONTEXT}}
+            -P out ipsec
             ${SPD_ESP_OUT:+esp/$MODE/${TUNNEL_MODE:+$SRC-$DST}/require}
 	    ;
 
-spdadd $SPD_DST $SPD_SRC any -P in ipsec
+spdadd $SPD_DST $SPD_SRC any
+            ${SELINUX_CONTEXT:+-ctx 1 1 ${SELINUX_CONTEXT}}
+            -P in ipsec
 	    ${SPD_ESP_IN:+esp/$MODE/${TUNNEL_MODE:+$DST-$SRC}/require}
 	    ;
 EOF
 elif [ &quot;$ESP_PROTO&quot; = &quot;none&quot; ]; then
 /sbin/setkey -c &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 &amp;lt;&amp;lt; EOF
-spdadd $SPD_SRC $SPD_DST any -P out ipsec
+spdadd $SPD_SRC $SPD_DST any
+            ${SELINUX_CONTEXT:+-ctx 1 1 ${SELINUX_CONTEXT}}
+            -P out ipsec
             ${SPD_AH_OUT:+ah/$MODE/${TUNNEL_MODE:+$SRC-$DST}/require}
 	    ;
 
-spdadd $SPD_DST $SPD_SRC any -P in ipsec
+spdadd $SPD_DST $SPD_SRC any
+            ${SELINUX_CONTEXT:+-ctx 1 1 ${SELINUX_CONTEXT}}
+            -P in ipsec
 	    ${SPD_AH_IN:+ah/$MODE/${TUNNEL_MODE:+$DST-$SRC}/require}
 	    ;
 EOF&lt;/pre&gt;&lt;p&gt;この修正により、TYPE=&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPSEC&quot;&gt;IPSEC&lt;/a&gt; として定義されている /etc/sysconfig/network-scripts/ifcfg-* 設定ファイルに「&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELINUX&quot;&gt;SELINUX&lt;/a&gt;_CONTEXT=...」という行が存在すれば、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;通信経路を定義する際に、Labeled Networkの定義も同時に行われる事となります。&lt;br /&gt;
『&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/ipsec&quot;&gt;ipsec&lt;/a&gt;_spd_t』というのは、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/IPsec&quot;&gt;IPsec&lt;/a&gt;通信経路に対して定義されているタイプです。現時点ではこれ以外のタイプは定義されていませんので、”お約束”という事にしておきます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# cat /etc/sysconfig/network-scripts/ifcfg-ipsec0
DST=192.168.1.43
TYPE=IPSEC
ONBOOT=yes
IKE_METHOD=PSK
# KaiGai added them
SELINUX_CONTEXT=system_u:object_r:ipsec_spd_t:s0&lt;/pre&gt;&lt;p&gt;うまく設定できていれば、setkey -DPの出力結果の中に『security context: ...』がどーたらという行が出力されているハズです。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# setkey -DP
    :
192.168.1.42[any] 192.168.1.43[any] 255
        out prio def ipsec
        esp/transport//require
        ah/transport//require
        created: Dec  4 16:45:31 2012  lastused: Dec  5 21:26:24 2012
        lifetime: 0(s) validtime: 0(s)
        security context doi: 1
        security context algorithm: 1
        security context length: 33
        security context: system_u:object_r:ipsec_spd_t:s0
        spid=1 seq=0 pid=3500
        refcnt=2&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;のインストール&lt;/h4&gt;
    &lt;p&gt;続いて、SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;のインストールに移ります。&lt;br /&gt;
インストール手順は&lt;a href=&quot;http://www.postgresql.jp/document/9.2/html/sepgsql.html&quot;&gt;&amp;#x516C;&amp;#x5F0F;&amp;#x30C9;&amp;#x30AD;&amp;#x30E5;&amp;#x30E1;&amp;#x30F3;&amp;#x30C8;&lt;/a&gt;にも記載されていますので、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Fedora&quot;&gt;Fedora&lt;/a&gt;のパッケージを前提にざっくりと紹介します。&lt;/p&gt;&lt;p&gt;まず、initdbを実行します。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# postgresql-setup initdb
Initializing database ... OK&lt;/pre&gt;&lt;p&gt;次に、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/postgresql&quot;&gt;postgresql&lt;/a&gt;.conf を編集して shared_preload_libraries に '$libdir/sepgsql' を追加します。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# vi /var/lib/pgsql/data/postgresql.conf
    :
    :
#max_files_per_process = 1000           # min 25
                                        # (change requires restart)
shared_preload_libraries = '$libdir/sepgsql'

# - Cost-Based Vacuum Delay -&lt;/pre&gt;&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;をシングルユーザモードで起動し、各データベースに初期セキュリティラベルを割り当てます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# su - postgres
$ for dbname in template0 template1 postgres
  do
    /usr/bin/postgres --single $dbname &amp;lt; \
      /usr/share/pgsql/contrib/sepgsql.sql &amp;gt; /dev/null
  done&lt;/pre&gt;&lt;p&gt;これでSE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;の初期設定は完了です。&lt;/p&gt;&lt;p&gt;最後に、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/TCP/IP&quot;&gt;TCP/IP&lt;/a&gt;経由での接続を受け付けるための設定を行ってサーバを起動します。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# vi /var/lib/pgsql/data/pg_hba.conf
(以下の一行を追加; 設定簡略化のため、とりあえずtrust)
host    all    all    192.168.1.42/32    trust&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;vi /usr/lib/systemd/system/postgresql.service
(以下の一行を編集し、pg_ctlから-iオプションを渡すようにする)
ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o &quot;-p ${PGPORT}&quot; -w -t 300
  ↓
ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -o &quot;-i -p ${PGPORT}&quot; -w -t 300&lt;/pre&gt;&lt;p&gt;サーバを立ち上げます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;# service postgresql start&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;試してみる&lt;/h4&gt;
    &lt;p&gt;長かった・・・。&lt;/p&gt;&lt;p&gt;そして、クライアント側から&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/TCP/IP&quot;&gt;TCP/IP&lt;/a&gt;接続で&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;サーバに接続してみます。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[kaigai@kg1 ~]$ id -Z
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[kaigai@kg1 ~]$ psql -h 192.168.1.43 -U postgres postgres
psql (9.1.6)
Type &quot;help&quot; for help.

postgres=# SELECT sepgsql_getcon();
                    sepgsql_getcon
-------------------------------------------------------
 unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
(1 row)&lt;/pre&gt;&lt;p&gt;ふむふむ、ちゃんとセキュリティコンテキストが切り替わっているように見えます。&lt;/p&gt;&lt;p&gt;それでは、クライアント側で権限を切り替えてから&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;に接続してみましょう。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[kaigai@kg1 ~]$ runcon -l s0-s0:c0,c2 bash
[kaigai@kg1 ~]$ id -Z
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0,c2
[kaigai@kg1 ~]$ psql -h 192.168.1.43 -U postgres postgres
psql (9.1.6)
Type &quot;help&quot; for help.

postgres=# SELECT sepgsql_getcon();
                   sepgsql_getcon
----------------------------------------------------
 unconfined_u:unconfined_r:unconfined_t:s0-s0:c0,c2
(1 row)&lt;/pre&gt;&lt;p&gt;キタコレ！&lt;/p&gt;&lt;p&gt;クライアント側のOS上で変更したプロセスのセキュリティコンテキストが、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;側に透過的に伝えられている事が分かります。&lt;/p&gt;&lt;p&gt;なお、以下のようにgetpeercon(3)に失敗している場合は、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/TCP/IP&quot;&gt;TCP/IP&lt;/a&gt;レベルでの接続には成功したものの、Labeled Networkが機能していません。設定を見直してみてください。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ psql -h 192.168.0.43 -U postgres postgres
psql: FATAL:  SELinux: unable to get peer label: Protocol not available&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;まとめ&lt;/h4&gt;
    &lt;p&gt;今回紹介したLabeled Networkの機能を使う事で、SE-&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;が実現する”OSとDBのアクセス制御の統合”を複数ノードから成る環境にも拡大する事ができるようになりました。&lt;br /&gt;
ただ、これは不特定多数からの接続に対して、接続相手のセキュリティコンテキストを受け入れるという設定ではなく、あくまでも、信頼済みのホストが提示するセキュリティコンテキストを受け入れるという形になります。したがって、”誰か分からないけど世界中からアクセスが来る”という場合に使える方法ではなく、自サイトで管理下にあるWebサーバやAPサーバから&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;サーバに接続する際にセキュリティコンテキストを伝達するための手法という事になります。&lt;/p&gt;&lt;p&gt;現時点では、OS標準のスクリプトがLabeled Networkに対応しておらずスクリプトを修正する必要があったり、初回接続時に（racoonの鍵交換に時間がかかって？）タイムアウトになるといった現象が見られました。&lt;br /&gt;
この辺は改良の余地ありなので、引き続き調査してみようと思います。&lt;/p&gt;

&lt;/div&gt;</description>
	<pubDate>Thu, 06 Dec 2012 05:26:19 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>Dominick Grift: Anatomy of a SELinux policy module: Dropbox</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-1671553651625097256</guid>
	<link>http://selinux-mac.blogspot.com/2012/12/anatomy-of-selinux-policy-module-dropbox.html</link>
	<description>I was asked to write a SELinux policy module for Dropbox. For obvious reasons i do not use this user application myself but i was willing to make an exception for the sake of writing a SELinux policy configuration for Dropbox.&lt;br /&gt;&lt;br /&gt;The module was designed for and developed on a Fedora 18 (Beta) system.&lt;br /&gt;&lt;br /&gt;Before i start designing and writing a policy configuration for some application i usually do my home work first. That means reading up on the application as much as i can so that i have an idea what to expect.&lt;br /&gt;&lt;br /&gt;In this case i already had a rough idea about the applications functionality. I was interested in seeing what is installed where and when.&lt;br /&gt;&lt;br /&gt;And so i downloaded and extracted two packages from this location:&lt;br /&gt;&lt;br /&gt;https://www.dropbox.com/install&lt;br /&gt;&lt;br /&gt;I focussed on this package:&lt;br /&gt;&lt;br /&gt;https://dl-web.dropbox.com/u/17/dropbox-lnx.x86_64-1.6.2.tar.gz&lt;br /&gt;&lt;br /&gt;and also had a quick look at this:&lt;br /&gt;&lt;br /&gt;https://www.dropbox.com/download?dl=packages/fedora/nautilus-dropbox-1.4.0-1.fedora.x86_64.rpm&lt;br /&gt;&lt;br /&gt;Basically i downloaded both packages and extracted it to see what was in them.&lt;br /&gt;&lt;br /&gt;The dropbox-lnx.x86_64-1.6.2.tar.gz package is expected to be downloaded to &quot;~&quot;&amp;nbsp; and to be extracted there. It extracts a directory called &quot;.dropbox-dist&quot; with various files in it.&lt;br /&gt;&lt;br /&gt;The installation guide suggests that one runs the &quot;dropboxd&quot; file that is location in the extracted &quot;~/.dropbox-dist&quot;&amp;nbsp; location.&lt;br /&gt;&lt;br /&gt;And so i decided to just try it out.&lt;br /&gt;&lt;br /&gt;As it turns out the dropboxd programs runs another file in that location called &quot;dropbox&quot;. Another file in that directory called &quot;library.zip&quot; turned out to be a &quot;hard link&quot; to &quot; dropbox&quot;. I was also able to identify plenty library files by their &quot;.so&quot; extensions.&lt;br /&gt;&lt;br /&gt;Anyways; A graphical window popped up and presented me with a series of questions. I followed the directions and when i was done the window exited and the process installed two more directories in my home directories called &quot;~/.dropbox&quot; and &quot;~/Dropbox&quot;&amp;nbsp; respectively.&lt;br /&gt;&lt;br /&gt;The &quot; ~/.dropbox&quot;&amp;nbsp; directory has various files that seem to be configuration files of some sorts and the &quot;~/Dropbox&quot; directory is the location that gets synchronized.&lt;br /&gt;&lt;br /&gt;Now i' ve had a rough idea of the locations and the nature of the files that were installed.&lt;br /&gt;&lt;br /&gt;The next step was to think about design.&lt;br /&gt;&lt;br /&gt;Were using the common security models available to us: Role based access control and Type enforcement. The aim is to improve integrity of our processes and files.&lt;br /&gt;&lt;br /&gt;We must also do our best to support as much of the applications functionality as we possibly can.&lt;br /&gt;&lt;br /&gt;We need to maintain a sub-tile balance between usability and security.&lt;br /&gt;&lt;br /&gt;Designing policy configuration for applications that sit on top of a Desktop environment is more complicated than a text application that you can for example run from a console because they usually interact with components on the Desktop environment and operate on files maintained by the these components.&lt;br /&gt;&lt;br /&gt;In a stock Fedora SELinux policy configuration most of the Desktop enviroment is not targeted. The result of this design decision is that components of the Desktop enviroment run with the same attributes and permissions as the user running them.&lt;br /&gt;&lt;br /&gt;For us that means that we either target each Desktop environment component and each file they maintain that Dropbox interacts with, or we allow our targeted Dropbox application to interact with the components operating, and operate on files they maintain, with the attributes and permissions of the user.&lt;br /&gt;&lt;br /&gt;I decided to go with the latter for simplicity.&lt;br /&gt;&lt;br /&gt;With that in mind i set out some humble security goals to achieve:&lt;br /&gt;&lt;br /&gt;1. Protect user application configuration, data and cache files as much as possible.&lt;br /&gt;2. Protect and contain the Dropbox application and process as much as possible.&lt;br /&gt;&lt;br /&gt;What follows now is my current SELinux policy configuration for Dropbox. The nautilus plugin (nautilus-dropbox-1.4.0-1.fedora.x86_64.rpm) is NOT supported. At least not currently.&lt;br /&gt;&lt;br /&gt;This because i refuse to install it because it depends on libgnome which in turn depends on Orbit and Bonobo and i will do just about anything to not have that installed.&lt;br /&gt;&lt;br /&gt;Here is the configuration. Below the configuration i will touch on its properties in detail:&lt;br /&gt;&lt;br /&gt;1. The ~/mydopbox/mydropbox.te Type enforcement source policy file:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;policy_module(mydropbox, 1.0.0)&lt;br /&gt;&lt;br /&gt;attribute dropbox_domain;&lt;br /&gt;&lt;br /&gt;type dropbox_exec_t;&lt;br /&gt;&lt;br /&gt;type dropbox_home_t;&lt;br /&gt;userdom_user_home_content(dropbox_home_t)&lt;br /&gt;&lt;br /&gt;type dropbox_tmp_t;&lt;br /&gt;userdom_user_tmp_content(dropbox_tmp_t)&lt;br /&gt;&lt;br /&gt;type dropbox_tmpfs_t;&lt;br /&gt;userdom_user_tmpfs_content(dropbox_tmpfs_t)&lt;br /&gt;&lt;br /&gt;type dropbox_port_t;&lt;br /&gt;corenet_port(dropbox_port_t)&lt;br /&gt;&lt;br /&gt;allow dropbox_domain self:capability dac_override; # mount&lt;br /&gt;allow dropbox_domain self:netlink_route_socket r_netlink_socket_perms;&lt;br /&gt;allow dropbox_domain self:process { execmem signal };&lt;br /&gt;allow dropbox_domain self:shm create_shm_perms;&lt;br /&gt;allow dropbox_domain self:tcp_socket create_stream_socket_perms;&lt;br /&gt;allow dropbox_domain self:udp_socket create_socket_perms;&lt;br /&gt;&lt;br /&gt;allow dropbox_domain dropbox_home_t:dir manage_dir_perms;&lt;br /&gt;allow dropbox_domain dropbox_home_t:file manage_file_perms;&lt;br /&gt;allow dropbox_domain dropbox_home_t:sock_file manage_sock_file_perms;&lt;br /&gt;userdom_user_home_dir_filetrans(dropbox_domain, dropbox_home_t, dir, &quot;.dropbox&quot;)&lt;br /&gt;&lt;br /&gt;allow dropbox_domain dropbox_tmp_t:file { manage_file_perms mmap_file_perms };&lt;br /&gt;files_tmp_filetrans(dropbox_domain, dropbox_tmp_t, file)&lt;br /&gt;&lt;br /&gt;can_exec(dropbox_domain, dropbox_exec_t)&lt;br /&gt;&lt;br /&gt;kernel_getattr_core_if(dropbox_domain)&lt;br /&gt;&lt;br /&gt;corecmd_exec_shell(dropbox_domain)&lt;br /&gt;&lt;br /&gt;corenet_tcp_bind_generic_node(dropbox_domain)&lt;br /&gt;corenet_tcp_sendrecv_generic_if(dropbox_domain)&lt;br /&gt;corenet_tcp_sendrecv_generic_node(dropbox_domain)&lt;br /&gt;corenet_udp_bind_generic_node(dropbox_domain)&lt;br /&gt;corenet_udp_sendrecv_generic_if(dropbox_domain)&lt;br /&gt;corenet_udp_sendrecv_generic_node(dropbox_domain)&lt;br /&gt;&lt;br /&gt;corenet_sendrecv_http_client_packets(dropbox_domain)&lt;br /&gt;corenet_tcp_connect_http_port(dropbox_domain)&lt;br /&gt;corenet_tcp_sendrecv_http_port(dropbox_domain)&lt;br /&gt;&lt;br /&gt;allow dropbox_domain dropbox_port_t:{ tcp_socket udp_socket } name_bind; # temporary workaround: 17500&lt;br /&gt;&lt;br /&gt;dev_list_sysfs(dropbox_domain)&lt;br /&gt;dev_read_sysfs(dropbox_domain)&lt;br /&gt;dev_read_urand(dropbox_domain)&lt;br /&gt;&lt;br /&gt;dev_dontaudit_getattr_all_blk_files(dropbox_domain) # panic&lt;br /&gt;dev_dontaudit_getattr_all_chr_files(dropbox_domain) # panic&lt;br /&gt;&lt;br /&gt;fs_getattr_tmpfs(dropbox_domain)&lt;br /&gt;fs_getattr_xattr_fs(dropbox_domain)&lt;br /&gt;fs_rw_inherited_tmpfs_files(dropbox_domain) # this is that xserver shm thing&lt;br /&gt;&lt;br /&gt;auth_read_passwd(dropbox_domain)&lt;br /&gt;&lt;br /&gt;init_getattr_initctl(dropbox_domain)&lt;br /&gt;&lt;br /&gt;libs_exec_ldconfig(dropbox_domain)&lt;br /&gt;&lt;br /&gt;mount_exec(dropbox_domain)&lt;br /&gt;mount_manage_pid_files(dropbox_domain) # mount: read/write /run/mount/utab&lt;br /&gt;&lt;br /&gt;sysnet_exec_ifconfig(dropbox_domain)&lt;br /&gt;sysnet_read_config(dropbox_domain)&lt;br /&gt;&lt;br /&gt;userdom_manage_user_home_content_dirs(dropbox_domain)&lt;br /&gt;userdom_manage_user_home_content_files(dropbox_domain)&lt;br /&gt;userdom_mmap_user_home_content_files(dropbox_domain) # libraries in ~/.dropbox-dist&lt;br /&gt;userdom_user_home_dir_filetrans_user_home_content(dropbox_domain, dir) # cannot use named file transition due to random names&lt;br /&gt;userdom_use_user_terminals(dropbox_domain)&lt;br /&gt;&lt;br /&gt;optional_policy(`&lt;br /&gt; dbus_session_bus_client(dropbox_domain) # probably not actually optional&lt;br /&gt; dbus_connect_session_bus(dropbox_domain) # probably not actually optional&lt;br /&gt;')&lt;br /&gt;&lt;br /&gt;optional_policy(`&lt;br /&gt; gnome_read_generic_data_home_dirs(dropbox_domain) # searching ~/.local/share&lt;br /&gt; gnome_read_home_config(dropbox_domain) # ibus, might not be optional&lt;br /&gt;&lt;br /&gt; # hack&lt;br /&gt; gen_require(`&lt;br /&gt;  type config_home_t;&lt;br /&gt; ')&lt;br /&gt;&lt;br /&gt; allow dropbox_domain config_home_t:dir setattr_dir_perms;&lt;br /&gt;')&lt;/pre&gt;&lt;/blockquote&gt;&amp;nbsp;2. The ~/mydopbox/mydropbox.if Interface source policy file:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;Blogspot does not format this content properly: View&lt;span&gt;/Get&lt;/span&gt; it here instead:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;http://pastebin.com/zcfSK2n3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;## Dropbox is a free service that lets you bring all your photos, docs, and videos anywhere.&lt;br /&gt;&lt;br /&gt;#######################################&lt;br /&gt;## &lt;br /&gt;## The role template for the dropbox module.&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## This template creates a derived domains which are used&lt;br /&gt;## for dropbox applications.&lt;br /&gt;## &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## The prefix of the user domain (e.g., user&lt;br /&gt;## is the prefix for user_t).&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## The role associated with the user domain.&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## The type of the user domain.&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;#&lt;br /&gt;template(`dropbox_role_template',`&lt;br /&gt; gen_require(`&lt;br /&gt;  attribute dropbox_domain;&lt;br /&gt;  type dropbox_exec_t, dropbox_home_t, dropbox_tmpfs_t;&lt;br /&gt; ')&lt;br /&gt;&lt;br /&gt; ########################################&lt;br /&gt; #&lt;br /&gt; # Declarations&lt;br /&gt; #&lt;br /&gt;&lt;br /&gt; type $1_dropbox_t, dropbox_domain;&lt;br /&gt; userdom_user_application_domain($1_dropbox_t, dropbox_exec_t)&lt;br /&gt; role $2 types $1_dropbox_t;&lt;br /&gt;&lt;br /&gt; ########################################&lt;br /&gt; #&lt;br /&gt; # Policy&lt;br /&gt; #&lt;br /&gt;&lt;br /&gt; domtrans_pattern($3, dropbox_exec_t, $1_dropbox_t)&lt;br /&gt;&lt;br /&gt; ps_process_pattern($3, $1_dropbox_t)&lt;br /&gt; allow $3 $1_dropbox_t:process { ptrace signal_perms };&lt;br /&gt;&lt;br /&gt; allow $1_dropbox_t $3:process signull;&lt;br /&gt; allow $1_dropbox_t $3:unix_stream_socket connectto;&lt;br /&gt;&lt;br /&gt; allow $3 dropbox_exec_t:file { manage_file_perms relabel_file_perms };&lt;br /&gt; userdom_user_home_content_filetrans($3, dropbox_exec_t, file, &quot;dropbox&quot;)&lt;br /&gt; userdom_user_home_content_filetrans($3, dropbox_exec_t, file, &quot;dropboxd&quot;)&lt;br /&gt; userdom_user_home_content_filetrans($3, dropbox_exec_t, file, &quot;library.zip&quot;)&lt;br /&gt;&lt;br /&gt; allow $3 dropbox_home_t:dir { manage_dir_perms relabel_dir_perms };&lt;br /&gt; allow $3 dropbox_home_t:file { manage_file_perms relabel_file_perms };&lt;br /&gt; allow $3 dropbox_home_t:sock_file { manage_sock_file_perms relabel_sock_file_perms };&lt;br /&gt; userdom_user_home_dir_filetrans($3, dropbox_home_t, dir, &quot;.dropbox&quot;)&lt;br /&gt;&lt;br /&gt; kernel_read_system_state($1_dropbox_t)&lt;br /&gt;&lt;br /&gt; corecmd_bin_domtrans($1_dropbox_t, $3)&lt;br /&gt;&lt;br /&gt; corenet_all_recvfrom_unlabeled($1_dropbox_t)&lt;br /&gt; corenet_all_recvfrom_netlabel($1_dropbox_t)&lt;br /&gt;&lt;br /&gt; logging_send_syslog_msg($1_dropbox_t) # might want to make this conditional if possible&lt;br /&gt;&lt;br /&gt; optional_policy(`&lt;br /&gt;  dropbox_dbus_chat($1, $3) # probably not actually optional&lt;br /&gt; ')&lt;br /&gt;&lt;br /&gt; optional_policy(`&lt;br /&gt;  xserver_user_x_domain_template($1_dropbox, $1_dropbox_t, dropbox_tmpfs_t) # might not be optional&lt;br /&gt; ')&lt;br /&gt;')&lt;br /&gt;&lt;br /&gt;########################################&lt;br /&gt;## &lt;br /&gt;## Send and receive messages from&lt;br /&gt;## dropbox over dbus.&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## The prefix of the user domain (e.g., user&lt;br /&gt;## is the prefix for user_t).&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;## Domain allowed access.&lt;br /&gt;## &lt;br /&gt;## &lt;br /&gt;#&lt;br /&gt;interface(`dropbox_dbus_chat',`&lt;br /&gt; gen_require(`&lt;br /&gt;  type $1_dropbox_t;&lt;br /&gt;  class dbus send_msg;&lt;br /&gt; ')&lt;br /&gt;&lt;br /&gt; allow $2 $1_dropbox_t:dbus send_msg;&lt;br /&gt; allow $1_dropbox_t $2:dbus send_msg;&lt;br /&gt;')&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&amp;nbsp;3. The ~/mydopbox/mydropbox.fc File contexts source policy file:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;HOME_DIR/\.dropbox(/.*)? gen_context(system_u:object_r:dropbox_home_t,s0)&lt;br /&gt;HOME_DIR/\.dropbox-dist/dropbox(d)? -- gen_context(system_u:object_r:dropbox_exec_t,s0)&lt;br /&gt;HOME_DIR/\.dropbox-dist/library\.zip -- gen_context(system_u:object_r:dropbox_exec_t,s0)&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;Declaring types, classifying them and making sure that SELinux knows what to label what&lt;br /&gt;&lt;br /&gt;Note that the policy above is the current result. Many of the properties of Dropbox where discovered after studying the contents of the package by trial and error.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;type dropbox_exec_t;&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;This is the declaration of the type of the dropbox executable files. Since &quot;library.zip&quot; is a hard link of &quot;dropbox&quot;, we need to make sure that both are labeled identical. The file &quot;dropboxd&quot; is also a Dropbox user application executable file.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;HOME_DIR/\.dropbox-dist/dropbox(d)? -- gen_context(system_u:object_r:dropbox_exec_t,s0)&lt;br /&gt;HOME_DIR/\.dropbox-dist/library\.zip -- gen_context(system_u:object_r:dropbox_exec_t,s0)&lt;/pre&gt;&lt;/blockquote&gt;Above is how we instruct SELinux about where these Dropbox application executable files are located and how they should be labeled.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;type dropbox_home_t;&lt;br /&gt;userdom_user_home_content(dropbox_home_t)&lt;/pre&gt;&lt;/blockquote&gt;This is the declaration of the Dropbox user configuration content located in &quot;~/.dropbox&quot; as well as the interface call that classifies the type as &quot; user home content&quot;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;HOME_DIR/\.dropbox(/.*)? gen_context(system_u:object_r:dropbox_home_t,s0)&lt;/pre&gt;&lt;/blockquote&gt;Here we tell SELinux that the ~/.dropbox directory and everything in it should be labeled with type &quot;dropbox_home_t&quot; which is the Dropbox user home content type.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;type dropbox_tmp_t;&lt;br /&gt;userdom_user_tmp_content(dropbox_tmp_t)&lt;/pre&gt;&lt;/blockquote&gt;Dropbox maintains a file in &quot; $TMP&quot;. Here we declare a type &quot;dropbox_tmp_t&quot; for this file and we classify this file &quot;user tmp content&quot; by calling the &quot;userdom_user_tmp_content() interface with the &quot;dropbox_tmp_t&quot; file type parameter.&lt;br /&gt;&lt;br /&gt;SELinux does not have to be aware of the location of the file in &quot;$TMP&quot; since for reason that i will not touch on in this article it should not maintain any contexts in &quot;$TMP&quot;. Hence there is no entry for this in the &quot;~/mydropbox/mydropbox.fc&quot;&amp;nbsp; file.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;type dropbox_tmpfs_t;&lt;br /&gt;userdom_user_tmpfs_content(dropbox_tmpfs_t)&lt;/pre&gt;&lt;/blockquote&gt;Dropbox opens a GTK window when you first run it to guide you through the installation process. Dropbox also has i icon in the taskbar that opens a settings window if you select it. The result is that Dropbox interacts with X server and operates on content maintained by X server.&lt;br /&gt;&lt;br /&gt;For this we have to declare a type for Dropbox shared memory in &quot;/dev/shm&quot;. We classify this type &quot;user tmpfs content&quot;.&lt;br /&gt;&lt;br /&gt;There is no need to specificy a file context for this content as SELinux should not maintain file contexts in this locations for the same reasons as it should not maintain them in &quot;$TMP&quot;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;type dropbox_port_t;&lt;br /&gt;corenet_port(dropbox_port_t)&lt;/pre&gt;&lt;/blockquote&gt;Dropbox listens on the UDP and TCP network for connections on port 17500. We Declare a type for this port object and classify the type &quot;corenet_port&quot;. This will allow us to tell SELinux that Dropbox may only bind TCP and UDP sockets to ports that are classified &quot;dropbox_port_t&quot;.&lt;br /&gt;&lt;br /&gt;Ports are not files and thus their contexts should not be specified in the file context file (~/mydropbox/mydropbox.fc).&lt;br /&gt;&lt;br /&gt;Instead we need to , after we installed the policy module package, manually label the 17500 UDP and TCP ports type &quot;dropbox_port_t&quot;&lt;br /&gt;&lt;br /&gt;This is done by issuing the following command:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;semanage port -a -t dropbox_port_t -p tcp 17500&lt;br /&gt;semanage port -a -t dropbox_port_t -p udp 17500 &lt;/blockquote&gt;You may have noticed that we have not yet classified our &quot; dropbox_exec_t&quot; user application executable file type.&lt;br /&gt;&lt;br /&gt;You may also have notices that we have not yet declared and classified a type for the Dropbox process.&lt;br /&gt;&lt;br /&gt;This is because of the properties of this application and it is also related to my design decision.&lt;br /&gt;&lt;br /&gt;Dropbox runs Nautilus and Firefox on your behalf to open your &quot;~/Dropbox&quot;&amp;nbsp; location and to direct you to the &quot;www.dropbox.com&quot;&amp;nbsp; website respectively.&lt;br /&gt;&lt;br /&gt;These two applications are currently not targeted in Fedora and i have decided to not do that either.&lt;br /&gt;&lt;br /&gt;How can we tell SELinux that if Dropbox runs Nautilus or Firefox that it does that on behalf of the user and that SELinux thus should run these two applications with the attributes and permissions of the user rather than the attributes and permission of Dropbox?&lt;br /&gt;&lt;br /&gt;This requires that we create a template because not all SELinux users are created equal. We need to use the &quot;user role prefix&quot; to declare a derived Dropbox process type. This will allow use to create rules that specify with which attributes and permissions Dropbox should run Nautilus and Firefox.&lt;br /&gt;&lt;br /&gt;This is done in a template called &quot;dropbox_role_template&quot; that i have created in the &quot;~/mydropbox/mydropbox.if&quot;&amp;nbsp; interface file.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; type $1_dropbox_t, dropbox_domain;&lt;br /&gt; userdom_user_application_domain($1_dropbox_t, dropbox_exec_t)&lt;br /&gt; role $2 types $1_dropbox_t;&lt;/pre&gt;&lt;pre&gt; &lt;/pre&gt;&lt;/blockquote&gt;The above declares a derived dropbox process type &quot;$1_dropbox_t&quot; where &quot;$1&quot;&amp;nbsp; is the &quot;user role prefix&quot;. It then goes on to classify this process &quot;dropbox_domain&quot;&amp;nbsp; This is done by assigning it a &quot;type attribute&quot;&amp;nbsp; that we i declared in the &quot;~/mydropbox/mydropbox.te&quot;&amp;nbsp; type enforcement file. You can find it on top, right below the policy module declaration.&lt;br /&gt;&lt;br /&gt;Next we classify both the Dropbox process type as well as the Dropbox user application executable file type &quot;user application domain&quot;. This interface has all the permissions needed to classify our process type &quot;user application process&quot; and our application executable file &quot;user application executable file&quot;.&lt;br /&gt;&lt;br /&gt;The last rule is a &quot;Role based access control&quot;&amp;nbsp; rule that allows the &quot;calling&quot; role access to the prefixed Dropbox type.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;Policy.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;domtrans_pattern($3, dropbox_exec_t, $1_dropbox_t)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This rule is a domain transition rule, or if you like &quot;process type transition rule&quot;. It tells SELinux that the &quot;calling&quot; user process type should transition to the derived Dropbox process type when it runs the Dropbox user application executable file.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt; ps_process_pattern($3, $1_dropbox_t)&lt;br /&gt; allow $3 $1_dropbox_t:process { ptrace signal_perms };&lt;/pre&gt;&lt;br /&gt;The above rules allow the calling user process type to &quot;ps&quot; processes labeled with the derived Dropbox process type as well as ptrace it and send all signals to it.&lt;br /&gt;&lt;pre&gt;logging_send_syslog_msg($1_dropbox_t) &lt;/pre&gt;&lt;br /&gt;This will allow Dropbox to for example show up in &quot;top&quot;, &quot; ps x&quot;&amp;nbsp; and it allows you to &quot;strace&quot;, kill etc. the Dropbox process.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; allow $1_dropbox_t $3:process signull;&lt;br /&gt; allow $1_dropbox_t $3:unix_stream_socket connectto;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Here are some interesting rules. The first allows the derived Dropbox process type to send null signals to the calling user process type and the second one allows the derived Dropbox process type to connect to the calling user process type with a unix domain stream socket.&lt;br /&gt;&lt;br /&gt;The processes here labeled with the &quot;calling user process types&quot;&amp;nbsp; aren' t actually the calling user. These are for example Nautilus or Firefox. Since we decided not to target them they are labeled with the &quot; calling user process type&quot;.&lt;br /&gt;&lt;br /&gt;In this case Dropbox probably wants to see if Nautilus is already running, and Dropbox probably wants to communicate with Nautilus using a unix domain stream socket.&lt;br /&gt;&lt;br /&gt;These rules are problematic because they are coarse. You can't tell by just looking at these rules who &quot;$3&quot; or if you will the process labeled with the &quot;calling user process type&quot; really is. Is it Nautilus or is it Firefox? Maybe it another process that currently is not targeted.&lt;br /&gt;&lt;br /&gt;Basically it allows Dropbox to send null signals and talk using a unix domain stream socket to any application currently not targeted labeled with the &quot;calling user process type&quot;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; allow $3 dropbox_exec_t:file { manage_file_perms relabel_file_perms };&lt;br /&gt; userdom_user_home_content_filetrans($3, dropbox_exec_t, file, &quot;dropbox&quot;)&lt;br /&gt; userdom_user_home_content_filetrans($3, dropbox_exec_t, file, &quot;dropboxd&quot;)&lt;br /&gt; userdom_user_home_content_filetrans($3, dropbox_exec_t, file, &quot;library.zip&quot;)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;These rules allow processes labeled with the &quot; calling user process type&quot; to &quot;manage and relabel&quot;&amp;nbsp; files labeled with the dropbox use application executable type &quot; dropbox_exec_t&quot;.&lt;br /&gt;&lt;br /&gt;Users need to be able to manage and relabel content in their home directory as they own it.&lt;br /&gt;&lt;br /&gt;The other three rules are interesting as well. They use a pretty new feature called &quot;named file type transitions&quot;,&lt;br /&gt;&lt;br /&gt;These rules tell SELinux that if a process labeled with the &quot; calling user process type&quot; create files with named &quot;dropbox, dropboxd and library.zip&quot;&amp;nbsp; in directories that are labeled with the user home content type &quot;user_home_t&quot; that the files should be created with the dropbox user application executable file type &quot;dropbox_exec_t&quot;.&lt;br /&gt;&lt;br /&gt;This is a important rule because proper labelling of files is of vital importance to the integrity of SELinux policy enforcement.&lt;br /&gt;&lt;br /&gt;When you extract the&amp;nbsp; &quot;dropbox-lnx.x86_64-1.6.2.tar.gz&quot;&amp;nbsp; into you home directory, this rule ensure that the Dropbox executable files automatically get the right security context.&lt;br /&gt;&lt;br /&gt;The file context specification for these files that we added to &quot; ~/mydropbox/mydropbox.fc&quot;&amp;nbsp; ensure that if restorecon gets run on any and all of these files that they will stay labeled properly.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; allow $3 dropbox_home_t:dir { manage_dir_perms relabel_dir_perms };&lt;br /&gt; allow $3 dropbox_home_t:file { manage_file_perms relabel_file_perms };&lt;br /&gt; allow $3 dropbox_home_t:sock_file { manage_sock_file_perms relabel_sock_file_perms };&lt;br /&gt; userdom_user_home_dir_filetrans($3, dropbox_home_t, dir, &quot;.dropbox&quot;) &lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;The same applies to the above except that this applies to Dropbox user home content and it applies to files, directories and sock files.&lt;br /&gt;&lt;br /&gt;The named file transtion rule dictates that SELinux should make sure that processes with the calling user process type create directories with the name &quot;.dropbox&quot; in directories with type &quot;user_home_dir_t&quot; (~) with type &quot;dropbox_home_t&quot;.&lt;br /&gt;&lt;br /&gt;Note: I should probably allow allow processes with the calling process type to manage and relabel files with type dropbox_tmp_t as well dropbox_tmpfs_t. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; kernel_read_system_state($1_dropbox_t)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This rule allows the derived Dropbox process type to read generic system state files in &quot;/proc&quot;, like for example &quot;/proc/meminfo&quot;.&lt;br /&gt;&lt;br /&gt;We added this rule (and some other rules that would normally go into the type enforcement file) here because it uses type attributes and were also using our &quot;dropbox_domain&quot; type attribute in our type enforcement file to write rules.&lt;br /&gt;&lt;br /&gt;One can only assign type attribute to types. You cannot assign a type attribute to a type attribute and thus we decided to deal with this in this manner.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;corecmd_bin_domtrans($1_dropbox_t, $3)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This is the rule that caused me to implement the &quot;dropbox_role_template&quot; template.&lt;br /&gt;&lt;br /&gt;It is what enables us to tell SELinux that dropbox should run application that are not targeted with the &quot;calling user process type&quot;.&lt;br /&gt;&lt;br /&gt;Basically it dictates that when the derived Dropbox process type runs a file with the generic &quot;bin_t&quot;&amp;nbsp; &quot;core command executable type&quot; that the process type should transition from &quot;$1_dropbox_t&quot; (the derived Dropbox process type) to &quot;$3&quot; ( the calling user process type)&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; corenet_all_recvfrom_unlabeled($1_dropbox_t)&lt;br /&gt; corenet_all_recvfrom_netlabel($1_dropbox_t)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;These rules allow the derived Dropbox process type to recv from all unlabeled and netlabel network connections.&lt;br /&gt;&lt;br /&gt;It is basically a rule that effectivily disabled SELinux network controls enforcement.&lt;br /&gt;&lt;br /&gt;These rules are here because again they use type attributes and one cannot assign type attributes to type attributes. That means we cannot use our &quot;dropbox_domain&quot;&amp;nbsp; attribute to call these in our ~/mydropbox/mydropbox.te&quot; file.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;logging_send_syslog_msg($1_dropbox_t) &lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This rule allows the prefixed Dropbox process type to send messages to syslog. Same as above it uses type attributes and so i had to add it here instead of in the type enforcement file.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;br /&gt;&lt;pre&gt; optional_policy(`&lt;br /&gt;  dropbox_dbus_chat($1, $3) # probably not actually optional&lt;br /&gt; ')&lt;/pre&gt;&lt;/blockquote&gt;This allows the derived dropbox process type to communicate using DBUS with processes that are labeled with the &quot;calling user process type&quot;. Probably Nautilus or some Gnome Desktop environment compoment like GVFS.&lt;br /&gt;&lt;br /&gt;Since None of them are targeted we are forced to allow the prefixed dropbox process type to communicate using DBUS with any process as long as its labeled with the &quot;calling user process type&quot;.&lt;br /&gt;&lt;br /&gt;We could have used raw policy to write these rules here but since DBUS is a &quot;object manager&quot; and also since its good to have a &quot; dropbox_dbus_chat&quot; interface we decide to create one (you can find it below the &quot;dropbox_role_template&quot; template in &quot;~/mydropbox/mydropbox.if&quot; and to call it in our own module.&lt;br /&gt;&lt;br /&gt;The &quot;optional_policy&quot; block indicates that this module does not actually depend on the rule in the block. I was assuming that Dropbox does not depend on the presence of DBUS but i may well be mistaken.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt; optional_policy(`&lt;br /&gt;  xserver_user_x_domain_template($1_dropbox, $1_dropbox_t, dropbox_tmpfs_t) # might not be optional&lt;br /&gt; ')&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This rule allows the derived Dropbox process type to interact with X server and to operate on files maintained by X server. It also makes our &quot;dropbox_tmpfs_t&quot; &quot;user tmpfs content&quot; available for use with X server.&lt;br /&gt;&lt;br /&gt;I was under the impression that Dropbox does not depend on X server since on their website they claim that Dropbox works on &quot;any Linux server&quot; but again i may be mistaken.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;allow dropbox_domain self:capability dac_override; # mount&lt;br /&gt;allow dropbox_domain self:netlink_route_socket r_netlink_socket_perms;&lt;br /&gt;allow dropbox_domain self:process { execmem signal };&lt;br /&gt;allow dropbox_domain self:shm create_shm_perms;&lt;br /&gt;allow dropbox_domain self:tcp_socket create_stream_socket_perms;&lt;br /&gt;allow dropbox_domain self:udp_socket create_socket_perms;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;These are what i call &quot; self-rules&quot;. Basically rules where a source process labeled with a process type interacts with or operates on itself.&lt;br /&gt;&lt;br /&gt;The first rule allow any Dropbox process type the &quot;dac_override&quot;&amp;nbsp; capability. This capability is needed to override discretionary access controls.&lt;br /&gt;&lt;br /&gt;Dropbox runs the mount command with the derived Dropbox process type (rather than with a process type transition) which is a setuid command.&lt;br /&gt;&lt;br /&gt;When the command is run your shell sessions current &quot;pwd&quot; is probably &quot;~/.dropbox-dist&quot;&amp;nbsp; since thats where you run dropboxd from. The root Linux user does (or might not) have access to that location as &quot; $HOME&quot;&amp;nbsp; might have the &quot;0700&quot; attibutes. The &quot;dac_override&quot;&amp;nbsp; access vector permission allow the process type to access it anyway from a SELinux perspective.&lt;br /&gt;&lt;br /&gt;The second rule is probably to read the routing table. Dropbox is a network application and so i am not surprised that it needs these permissions.&lt;br /&gt;&lt;br /&gt;The third rule allows all Dropbox process types to &quot;execute anonymous memory&quot;, Basically memory that is world writable. It is usually a sign of bad programming practices but there are also legitimate use cases such as &quot;just in time compiling&quot;. This rule also allows Dropbox process types to send generic signals to itself.&lt;br /&gt;&lt;br /&gt;The fourth rule allows Dropbox processes to create shared memory. This is for X server interaction and is related to the &quot; dropbox_tmpfs_t&quot;&amp;nbsp; &quot;user_tmpfs_content&quot;&amp;nbsp; type.&lt;br /&gt;&lt;br /&gt;The fifth and the sixth rule allows dropbox and any other process labeled with any dropbox process type to create tcp stream sockets and udp sockets. This is needed because Dropbox is listening on the network for connections (port udp/tcp 17500 dropbox_port_t)&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;allow dropbox_domain dropbox_home_t:dir manage_dir_perms;&lt;br /&gt;allow dropbox_domain dropbox_home_t:file manage_file_perms;&lt;br /&gt;allow dropbox_domain dropbox_home_t:sock_file manage_sock_file_perms;&lt;br /&gt;userdom_user_home_dir_filetrans(dropbox_domain, dropbox_home_t, dir, &quot;.dropbox&quot;)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;These rules allow all Dropbox process types to &quot;manage&quot;&amp;nbsp; directories, files and sock files that are labeled with the &quot;dropbox_home_t&quot; &quot; user home content type&quot;. This is configuration content amongst other things. Stuff that could use protecting to ensure optimal integrity.&lt;br /&gt;&lt;br /&gt;The fourth rule is another named file type transition rule. It dictates that if any dropbox process type creates a directory with name &quot;.dropbox&quot;&amp;nbsp; in directories with type &quot; user_home_dir_t&quot;&amp;nbsp; which is &quot;~&quot;&amp;nbsp; that the directory be created with the &quot;dropbox_home_t&quot; type. Thus file transitioning from &quot;user_home_dir_t&quot; to &quot;dropbox_home_t&quot;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;allow dropbox_domain dropbox_tmp_t:file { manage_file_perms mmap_file_perms };&lt;br /&gt;files_tmp_filetrans(dropbox_domain, dropbox_tmp_t, file)&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Dropbox maintains a file in &quot;$TMP&quot; with a random name. It also &quot;mmaps&quot; that file. The second rule dictates that if any Dropbox process type creates a file in a directory with type &quot; tmp_t&quot; that the file is created with the &quot; dropbox_tmp_t&quot;&amp;nbsp; &quot; user_tmp_content&quot; type. Since this file has a random name i have to use a regular file type transition and i cannot use a named file type transition.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;can_exec(dropbox_domain, dropbox_exec_t)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;The dropboxd process executes the dropbox &quot;user application executable file&quot;&amp;nbsp; Both dropboxd as well as dropbox are labeled with the &quot; dropbox_exec_t&quot;&amp;nbsp; type. This rule allows all Dropbox process types to execute files with the dropbox_exec_t type without a process type transition.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;br /&gt;&lt;pre&gt;kernel_getattr_core_if(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;I am not sure why but Dropbox wants to get attribute of the core if file in &quot;/proc&quot;. Fine.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;corecmd_exec_shell(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This rule allows all Dropbox process types to run a shell without a process type transition.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;corenet_tcp_bind_generic_node(dropbox_domain)&lt;br /&gt;corenet_tcp_sendrecv_generic_if(dropbox_domain)&lt;br /&gt;corenet_tcp_sendrecv_generic_node(dropbox_domain)&lt;br /&gt;corenet_udp_bind_generic_node(dropbox_domain)&lt;br /&gt;corenet_udp_sendrecv_generic_if(dropbox_domain)&lt;br /&gt;corenet_udp_sendrecv_generic_node(dropbox_domain)&lt;br /&gt;&lt;br /&gt;corenet_sendrecv_http_client_packets(dropbox_domain)&lt;br /&gt;corenet_tcp_connect_http_port(dropbox_domain)&lt;br /&gt;corenet_tcp_sendrecv_http_port(dropbox_domain)&lt;br /&gt;&lt;br /&gt;allow dropbox_domain dropbox_port_t:{ tcp_socket udp_socket } name_bind; # temporary workaround: 17500&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Network related rules. The first block of rules are &quot;generic&quot; in the sense that it basically does not support the use of the SELinux network controls. Or it supports them in the most generic way.&lt;br /&gt;&lt;br /&gt;The second block allows all dropbox process types to connect to TCP ports that are labeled with the &quot;httpd_port_t&quot;&amp;nbsp; port type. Dropbox connects to &quot;tcp:443&quot; (their Dropbox web application). It allow Dropbox to send and receive client packets that are labeled with the httpd packet type and it allows Dropbox to send and receive traffic from http classified ports.&lt;br /&gt;&lt;br /&gt;The last rule of the bunch allows all dropbox process types to bind TCP and UDP sockets to ports that are labeled with the &quot;dropbox_port_t&quot;&amp;nbsp; port type. We labeled UDP/TCP 17500 with that type.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;dev_list_sysfs(dropbox_domain)&lt;br /&gt;dev_read_sysfs(dropbox_domain)&lt;br /&gt;dev_read_urand(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Above allows all Dropbox process types to list directories with the generic &quot;sysfs_t&quot; type. This is generic content in &quot;/sys&quot;. The second rule allow Dropbox to actually read files with this type.&lt;br /&gt;&lt;br /&gt;The third rule allows all Dropbox process types to read character device nodes with &quot;urandom_device_t&quot; device node type. E.g. /dev/urandom.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;dev_dontaudit_getattr_all_blk_files(dropbox_domain) # panic&lt;br /&gt;dev_dontaudit_getattr_all_chr_files(dropbox_domain) # panic&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;&quot;Dontaudit&quot; is a access vector that tells SELinux to silently block a specified interaction or operation.&lt;br /&gt;&lt;br /&gt;In the above case we silently deny any Dropbox process type to get attributes of all block and character files that are classified &quot;device_node&quot;.&lt;br /&gt;&lt;br /&gt;To expose &quot; hidden denials&quot; one needs to issue the &quot;semodule -DB&quot;&amp;nbsp; command which will build the policy database without any &quot; dontaudit&quot; rules. To reinsert the &quot;dontaudit&quot; rules simply issue 'semodule -B&quot;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;fs_getattr_tmpfs(dropbox_domain)&lt;br /&gt;fs_getattr_xattr_fs(dropbox_domain)&lt;br /&gt;fs_rw_inherited_tmpfs_files(dropbox_domain) # this is that xserver shm thing &lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This allow all Dropbox process types to get attributes of filesystems with the &quot;tmpfs_t&quot;&amp;nbsp; filesystem type. This a common access vector for processes that maintain content in the &quot; /dev/shm&quot;&amp;nbsp; location.&lt;br /&gt;&lt;br /&gt;The second rule allow any Dropbox process type to get attribute of any filesystem that supports extended attributes. E.g. types that are classified &quot;filesystem type&quot; as well as &quot;Extended attribute file system&quot;. This is to allow Dropbox to stat &quot;/&quot;&amp;nbsp; which is a common thing to do.&lt;br /&gt;&lt;br /&gt;The Third rule is related to X server interaction. I am not sure why it is the way it is but it has been this way for as long as i can remember. Inherited means that it doesnt actually opens the &quot;generic tmpfs&quot; file but it still reads and writes it. That means that either Dropbox got passed a open file or that there is a leaked file descriptor. Since, if i remember correctly , things will break if you do not allow this, i assume that X server or whatever passed the open file to Dropbox and dropbox reads and write it.&lt;br /&gt;&lt;br /&gt;Note that the file is not labeled with the &quot;dropbox_tmpfs_t&quot;&amp;nbsp; &quot;user tmpfs content&quot; file type either. Instead it is labeled with a generic type for content in &quot;/dev/shm&quot;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;auth_read_passwd(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Allow all Dropbox process types to read files with the passwd_file_t file type. E.g. &quot;/etc/passwd&quot; amongst others.&lt;br /&gt;&lt;br /&gt;This could simply be a side effect from Dropbox running a bash shell. The shell needs to read the password file in order to get the information needed for the shell prompt (user name etc.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;init_getattr_initctl(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Get attributes of initctl (named pipe i believe it was)&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;libs_exec_ldconfig(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Execute ldconfig program without a process type transition. It probably runs ldconfig on that file it maintains in &quot;$TMP&quot;&amp;nbsp; that it also mmaps.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;mount_exec(dropbox_domain)&lt;br /&gt;mount_manage_pid_files(dropbox_domain) # mount: read/write /run/mount/utab&lt;/pre&gt;&lt;/blockquote&gt;Execute the mount command without a process type transition. Not sure what it does with mount. &lt;br /&gt;&lt;br /&gt;Mount reads and write /run/mount/utab which is labeled with the mount pid file type.&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;sysnet_exec_ifconfig(dropbox_domain)&lt;br /&gt;sysnet_read_config(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Executes ifconfig command without a process type transition and read files that are classified network configuration files (net_conf_t) This is probably &quot;/etc/resolve.conf&quot;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;userdom_manage_user_home_content_dirs(dropbox_domain)&lt;br /&gt;userdom_manage_user_home_content_files(dropbox_domain)&lt;br /&gt;userdom_mmap_user_home_content_files(dropbox_domain) # libraries in ~/.dropbox-dist&lt;br /&gt;userdom_user_home_dir_filetrans_user_home_content(dropbox_domain, dir) # cannot use named file transition due to random names&lt;br /&gt;userdom_use_user_terminals(dropbox_domain)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;These are interesting. These rules allow all dropbox process types to operate on content maintained by processes labeled with the user process type.&lt;br /&gt;&lt;br /&gt;In some cases this is bad news but in our case we will have to embrace it.&lt;br /&gt;&lt;br /&gt;Here is why&lt;br /&gt;&lt;br /&gt;The first two rules allow all Dropbox process types to manage directories and files that are labeled with the generic user home content type (user_home_t)&lt;br /&gt;&lt;br /&gt;I decided to keep &quot;~/Dropbox&quot; location generic. The idea of Dropbox is that users can &quot;drag and drop&quot;&amp;nbsp; content in there to synchronise with the Dropbox. Usually that is program Photos (~/Pictures), documents (~/Documents), maybe tunes (~/Audio or ~/Music). These locations should be generic since they are not related to any single user application.&lt;br /&gt;&lt;br /&gt;&quot;Drag and dropping&quot;&amp;nbsp; equals &quot;moving&quot; if done on a single partition. When you move a file you also move its context and so we want &quot;~/Dropbox&quot; to have the same type as the content that is expected to be dropped in there.&lt;br /&gt;&lt;br /&gt;If a user is stupid enough to drop his &quot; ~/.gnupg&quot; or &quot;~/.ssh&quot; directory into the &quot;~/Dropbox&quot; then the dropbox process type will not be able to access that content. E.g. it wont be able to synchronize your sensitive files.&lt;br /&gt;&lt;br /&gt;Unless ofcourse if you really want it to. In that case you would first manually relabel the content to the generic user home content type (user_home_t) with the &quot;chcon&quot; command and them drop it into your Dropbox.&lt;br /&gt;&lt;br /&gt;So leaving &quot;~/Dropbox&quot; type &quot;user_home_t&quot;&amp;nbsp; and allowing Dropbox to manage files and directories with the &quot;user_home_t&quot;&amp;nbsp; seems to me the sensible thing to do here.&lt;br /&gt;&lt;br /&gt;The third rule is a bit more controversial. The&amp;nbsp; Dropbox archive copies library files into ~/.dropbox-dist. I decided to only give &quot;dropboxd, dropbox and library.zip&quot;&amp;nbsp; in there a private type for simplicitly but the side effect is the now all dropbox process types need to mmap generic user home content files (the libraries).&lt;br /&gt;&lt;br /&gt;The fourth rule is a file type transition rule. The Dropbox installed creates &quot;~/Dropbox&quot; which we want to have type &quot;user_home_t&quot;. But this location has a fixed name so we could have used a named file transition rather than a normal file transition. However during installation Dropbox also create a directory in &quot;~&quot;&amp;nbsp; with a random name andso we could not use a named file type transition for that anyways, and so it was decided to use this rule&lt;br /&gt;&lt;br /&gt;Basically it dictates that if any Dropbox process type creates a directory in a directory with type &quot;user_home_dir_t&quot;&amp;nbsp; (~) that the directory should be created with the &quot;user_home_t&quot; generic user home content type.&lt;br /&gt;&lt;br /&gt;The fifth rule allows any dropbox process type to &quot;use&quot;&amp;nbsp; user terminals. This will allow Dropbox to print any messages to the terminal when you run &quot;./dropboxd&quot;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;optional_policy(`&lt;br /&gt; dbus_session_bus_client(dropbox_domain) # probably not actually optional&lt;br /&gt; dbus_connect_session_bus(dropbox_domain) # probably not actually optional&lt;br /&gt;')&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This will allow anydropbox domain to become a DBUS session bus client and to aquire service on the session bus. Since i was under the assumption that DBUS is not a requirement for Dropbox i wrapped these rules in a &quot;optional_policy&quot;&amp;nbsp; block that basically tells the policy compiler that these rules are optional. E.g. if they are not available for use then do not sweat it and proceed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;optional_policy(`&lt;br /&gt; gnome_read_generic_data_home_dirs(dropbox_domain) # searching ~/.local/share&lt;br /&gt; gnome_read_home_config(dropbox_domain) # ibus, might not be optional&lt;br /&gt;&lt;br /&gt; # hack&lt;br /&gt; gen_require(`&lt;br /&gt;  type config_home_t;&lt;br /&gt; ')&lt;br /&gt;&lt;br /&gt; allow dropbox_domain config_home_t:dir setattr_dir_perms;&lt;br /&gt;')&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;These rules are related to content in X desktop (XDG) standard locations. Basically all Dropbox process types need to be able to read IBUS files in &quot;~/.config&quot; These IBUS files are labeled with the generic &quot;config_home_t&quot;&amp;nbsp; user home content type.&lt;br /&gt;&lt;br /&gt;Dropbox is probably using some Gnome library that does this on behalf of Dropbox. It also wants to set attributes of generic &quot;config_home_t&quot;&amp;nbsp; directories and search generic &quot;data_home_t&quot;&amp;nbsp; directories (~/.local/share).&lt;br /&gt;&lt;br /&gt;Okay... I think i touched on everything now, except...&lt;br /&gt;&lt;br /&gt;How to actually implement this policy&lt;br /&gt;&lt;br /&gt;Create a working directory and change directory into it:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;mkdir ~/mydropbox; cd ~/mydropbox;&lt;/blockquote&gt;Create three &quot;mydropbox&quot;&amp;nbsp; source policy files:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;touch mydropbox.{te,if,fc}&lt;/blockquote&gt;Copy the policy above in their respective files&lt;br /&gt;&lt;br /&gt;Next, create another file:&lt;br /&gt;&lt;br /&gt;touch myunconfineduser.te&lt;br /&gt;&lt;br /&gt;and paste the following in that file:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre&gt;policy_module(myunconfineduser, 1.0.0)&lt;br /&gt;&lt;br /&gt;gen_require(`&lt;br /&gt; type unconfined_t;&lt;br /&gt; role unconfined_r;&lt;br /&gt;')&lt;br /&gt;&lt;br /&gt;dropbox_role_template(unconfined, unconfined_r, unconfined_t)&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This is what actually calls or if you will activates the &quot;dropbox_role_template()&quot;&amp;nbsp; that i have created in the &quot;~/mydropbox/mydropbox.if&quot;&amp;nbsp; interface file.&lt;br /&gt;&lt;br /&gt;Now build the two policy packages. You may or may not need to install the &quot;selinux-policy-devel&quot;&amp;nbsp; package for this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;Make -f /usr/share/selinux/devel/Makefile&lt;/blockquote&gt;&lt;br /&gt;Next install the policy packages that were created in &quot;~/mydropbox&quot;:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;sudo semodule -i mydropbox.pp myunconfineduser.pp&lt;/blockquote&gt;&lt;br /&gt;If you have already installed Dropbox then make sure to restore the context of the &quot;~/.dropbox&quot; directories and the &quot;dropboxd, dropbox and library.zip&quot;&amp;nbsp; files in &quot;~/.dropbox-dist&quot;:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;restorecon -R -v -F ~ &lt;/blockquote&gt;If you have not yet installed Dropbox:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre class=&quot;command-line&quot;&gt;cd ~ &amp;amp;&amp;amp; wget -O - &quot;https://www.dropbox.com/download?plat=lnx.x86_64&quot; | tar xzf -&lt;/pre&gt;&lt;/blockquote&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;pre class=&quot;command-line&quot;&gt;~/.dropbox-dist/dropboxd&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;b&gt;Disclaimer:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;I do not encourage nor endorse the use of Dropbox. Security means taking responsibility. Do not trust your content to third parties. &lt;/b&gt;</description>
	<pubDate>Sat, 01 Dec 2012 10:17:35 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dan Walsh: Using Apache and SELinux Together</title>
	<guid>http://danwalsh.livejournal.com/61349.html</guid>
	<link>http://danwalsh.livejournal.com/61349.html</link>
	<description>A few months ago, I wrote an article on &lt;a href=&quot;http://drupalwatchdog.com/2/2/apache-selinux&quot; rel=&quot;nofollow&quot;&gt;&amp;quot;Using Apache and SELinux Together&amp;quot;&lt;/a&gt; for DrupalWatchDog Magazine.&amp;nbsp; They publish it first in hard copy, and then after a couple of months publish it on line.&amp;nbsp; Here is a link to the online version.&lt;br /&gt;&lt;br /&gt;http://drupalwatchdog.com/2/2/apache-selinux&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Thu, 01 Nov 2012 17:42:31 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 8: Introducing sepolicy generate</title>
	<guid>http://danwalsh.livejournal.com/61107.html</guid>
	<link>http://danwalsh.livejournal.com/61107.html</link>
	<description>&lt;b&gt;sepolgen&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;sepolgen is the tool that I recommend people use to start generating policy.&amp;nbsp; We have decided to merge this tool into the sepolicy suite&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sepolicy generate&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;man sepolicy-generate&lt;br /&gt;&lt;br /&gt;sepolicy-generate(8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-generate(8)&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-generate - Generate an initial SELinux policy module template.&lt;br /&gt;&lt;br /&gt;SYNOPSIS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy generate [-h] [-t TYPE] [-n NAME] [-T TEST] [ command | confineduser ]&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Use sepolicy generate to generate an SELinux policy Module.&amp;nbsp; sepolicy generate will generate 4 files.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type Enforcing File NAME.te&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This file can be used to define all the types rules for a particular domain.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Interface File NAME.if&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This file defines the interfaces for the types generated in the te file, which can be used by other policy domains.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File Context NAME.fc&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp; file defines the default file context for the system, it takes the file types created in the te file and associates file paths to the types.&amp;nbsp; Tools like restorecon and RPM will use these paths to put down labels.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RPM Spec File NAME_selinux.spec&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This file is an RPM SPEC file that can be used to install the SELinux policy on to machines and setup the labelling. The spec file also installs the interface file&amp;nbsp; and&amp;nbsp; a&amp;nbsp; man page describing the policy.&amp;nbsp; You can use sepolicy manpage -d NAME to generate the man page.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shell File NAME.sh&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This&amp;nbsp; is a helper shell script to compile, install and fix the labelling on your test system.&amp;nbsp; It will also generate a man page based on the installed policy, and compile and&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; build an RPM suitable to be installed on other machines&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If a generate is possible, this tool will print out all generate paths from the source domain to the target domain&lt;br /&gt;&lt;br /&gt;OPTIONS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -h, --help&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Display help message&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -t, --type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specify the type of policy you want to create.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Valid Options:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 : Standard Init Daemon (Default)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 : DBUS System Daemon&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 : Internet Services Daemon&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3 : Web Application/Script (CGI)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 : User Application&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 : Sandbox&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6 : Minimal Terminal User Role&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7 : Minimal X Windows User Role&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8 : User Role&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9 : Admin User Role&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10 : Root Admin User Role&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -n, --name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specify alternate name of policy. The policy will default to the executable or name specified.&lt;br /&gt;&lt;br /&gt;EXAMPLE&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy generate /usr/sbin/rwhod&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generating Policy for /usr/sbin/rwhod named rwhod&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Created the following files in:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rwhod.te # Type Enforcement file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rwhod.if # Interface file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rwhod.fc # File Contexts file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rwhod_selinux.spec # Spec file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rwhod.sh # Setup Script&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sepolicy generate has some nice new features over sepolgen.&lt;ol&gt;&lt;li&gt;&lt;span&gt;sepolicy generate&lt;/span&gt; does not to be run as root.&lt;/li&gt;&lt;li&gt;&lt;span&gt;sepolicy generate&lt;/span&gt; now generates a RPM spec file. This spec file can be used to build and RPM package that will install the policy package file (pp) and interface file (if) in the correct location, install it into the kernel and fix the labelling.&lt;/li&gt;&lt;li&gt;The &lt;span&gt;sepolicy generate&lt;/span&gt;d setup script&amp;nbsp;continues to install the policy and setup the labelling, and also generates a man page based on the installed policy using &lt;span&gt;sepolicy manpage&lt;/span&gt;, finally it build and compiles the policy and man page into an rpm ready to be installed on other machines.&lt;/li&gt;&lt;/ol&gt;selinux-polgengui no longer needs to be run as root either, since it is using the sepolicy generate python bindings to generate the policy files. sepolgen command will now just execute sepolicy generate as a shell script.</description>
	<pubDate>Wed, 31 Oct 2012 18:23:56 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 8: Introducing sepolicy transition</title>
	<guid>http://danwalsh.livejournal.com/60801.html</guid>
	<link>http://danwalsh.livejournal.com/60801.html</link>
	<description>Another advanced topic of SELinux, that is hard to understand is process transitions.&amp;nbsp; Basically this is the mechanism where most processes get their labels.&amp;nbsp; The init_t domain transition to the initrc_t domain when it executes an initrc_exec_t labelled script.&amp;nbsp; initrc_t transition to httpd_t when it executes and file labelled httpd_exec_t ...&lt;br /&gt;&lt;br /&gt;Two questions can arise from this,&lt;ul&gt;&lt;li&gt;What process domains can one process domain transition too?&lt;/li&gt;&lt;li&gt;Can one process domain transition to another?&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/46653.html&quot; rel=&quot;nofollow&quot;&gt;I orginally created a tool called setrans but now we are shipping it as part of the sepolicy suite.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; man sepolicy-transition&lt;br /&gt;sepolicy-transition(8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-transition(8)&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-transition - Examine the SELinux Policy and generate a process transition report&lt;br /&gt;&lt;br /&gt;SYNOPSIS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy transition [-h] -s SOURCE&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy transition [-h] -s SOURCE -t TARGET&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy transition will show all domains that a&amp;nbsp; give&amp;nbsp; SELinux&amp;nbsp; source domain can transition to, including the entrypoint.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If&amp;nbsp; a&amp;nbsp; target&amp;nbsp; domain is given, sepolicy transition will examine policy for all transition paths from the source domain to the&amp;nbsp; target&amp;nbsp; domain,&amp;nbsp; and&amp;nbsp; will&amp;nbsp; list the paths.&amp;nbsp; If a transition is possible, this tool will print out all transition paths from the source&amp;nbsp; domain&amp;nbsp; to&amp;nbsp; the&amp;nbsp; target domain&lt;br /&gt;&lt;br /&gt;OPTIONS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -h, --help&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Display help message&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -s, --source&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specify the source SELinux domain type.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -t, --target&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specify the target SELinux domain type.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If I want to see what process domains guest_t can transition too, I can execute the following:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# sepolicy transition -s guest_t&lt;br /&gt;guest_t @ abrt_helper_exec_t --&amp;gt; abrt_helper_t&lt;br /&gt;guest_t @ loadkeys_exec_t --&amp;gt; loadkeys_t&lt;br /&gt;guest_t @ chkpwd_exec_t --&amp;gt; chkpwd_t&lt;br /&gt;guest_t @ passwd_exec_t --&amp;gt; passwd_t&lt;br /&gt;guest_t @ updpwd_exec_t --&amp;gt; updpwd_t&lt;br /&gt;guest_t @ chfn_exec_t --&amp;gt; chfn_t&lt;br /&gt;guest_t @ oddjob_mkhomedir_exec_t --&amp;gt; oddjob_mkhomedir_t&lt;br /&gt;guest_t @ shell_exec_t --&amp;gt; httpd_user_script_t&lt;/span&gt;&lt;/p&gt;&lt;p&gt;If I wanted to see how httpd_t can read system_mail_t&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# sepolicy transition -s httpd_t -t system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_mojomojo_script_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; postfix_showq_t --&amp;gt; spamc_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; dovecot_deliver_t --&amp;gt; uux_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; dovecot_deliver_t --&amp;gt; sendmail_t --&amp;gt; uux_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; dovecot_deliver_t --&amp;gt; sendmail_t --&amp;gt; procmail_t --&amp;gt; clamscan_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; dovecot_deliver_t --&amp;gt; sendmail_t --&amp;gt; postfix_master_t --&amp;gt; postfix_local_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; dovecot_deliver_t --&amp;gt; sendmail_t --&amp;gt; postfix_master_t --&amp;gt; postfix_pipe_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; uux_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_openshift_script_t --&amp;gt; openshift_initrc_t --&amp;gt; openshift_domain --&amp;gt; openshift_t --&amp;gt; openshift_mail_t --&amp;gt; exim_t --&amp;gt; clamscan_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_suexec_t --&amp;gt; httpd_bugzilla_script_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; abrt_retrace_worker_t --&amp;gt; mock_t --&amp;gt; mount_t --&amp;gt; lvm_t --&amp;gt; insmod_t --&amp;gt; initrc_t --&amp;gt; daemon --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; abrt_retrace_worker_t --&amp;gt; mock_t --&amp;gt; mount_t --&amp;gt; lvm_t --&amp;gt; insmod_t --&amp;gt; initrc_t --&amp;gt; systemprocess --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; abrt_retrace_worker_t --&amp;gt; mock_t --&amp;gt; mount_t --&amp;gt; lvm_t --&amp;gt; insmod_t --&amp;gt; initrc_t --&amp;gt; sulogin_t --&amp;gt; unconfined_t --&amp;gt; dhcpc_t --&amp;gt; NetworkManager_t --&amp;gt; pppd_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; abrt_retrace_worker_t --&amp;gt; mock_t --&amp;gt; mount_t --&amp;gt; lvm_t --&amp;gt; insmod_t --&amp;gt; initrc_t --&amp;gt; sulogin_t --&amp;gt; unconfined_t --&amp;gt; rpm_t --&amp;gt; rpm_script_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; abrt_retrace_worker_t --&amp;gt; mock_t --&amp;gt; mount_t --&amp;gt; lvm_t --&amp;gt; insmod_t --&amp;gt; initrc_t --&amp;gt; sulogin_t --&amp;gt; unconfined_t --&amp;gt; rpm_script_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; passenger_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_bugzilla_script_t --&amp;gt; system_mail_t&lt;br /&gt;httpd_t --&amp;gt; httpd_mojomojo_script_t --&amp;gt; system_mail_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note currently this command does not take into account boolean settings, it is just showing you that it is possible.&amp;nbsp; Future enhancements would be to list the booleans required to allow the access.&lt;/p&gt;</description>
	<pubDate>Mon, 29 Oct 2012 13:26:28 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 8: Introducing sepolicy network</title>
	<guid>http://danwalsh.livejournal.com/60528.html</guid>
	<link>http://danwalsh.livejournal.com/60528.html</link>
	<description>One problem uses have with SELinux is understanding the network protections.&amp;nbsp; SELinux controls which ports a domain is able to connect to and which ports it is able to bind to.&amp;nbsp; Since SELinux is a type enforcement system, it controls ports access via types.&amp;nbsp; Processes get assigned types and port numbers get assigned types.&amp;nbsp; Since users think in terms of port numbers, we built a tool to more easily allow users understand the relationships.&lt;a href=&quot;http://danwalsh.livejournal.com/53182.html&quot; rel=&quot;nofollow&quot;&gt;&amp;nbsp; I orginally called this tool senetwork, but now we are shipping it as part of the sepolicy suite.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; man sepolicy-network&lt;br /&gt;sepolicy-network(8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-network(8)&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-network - Examine the SELinux Policy and generate a network report&lt;br /&gt;&lt;br /&gt;SYNOPSIS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy network [-h] (-l | -p PORT [PORT ...] | -t TYPE [TYPE ...] | -d DOMAIN [DOMAIN ...])&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Use sepolicy network to examine SELinux Policy and generate network reports.&lt;br /&gt;&lt;br /&gt;OPTIONS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -d, --domain&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate a report listing the ports to which the specified domain is allowed to connect and or bind.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -l, --list&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List all Network Port Types defined in SELinux Policy&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -h, --help&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Display help message&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -t, --type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate a report listing the port numbers associate with the specified SELinux port type.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -p, --port&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate a report listing the SELinux port types associate with the specified port number.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;sepolicy network allows you to ask SELinux what port type is associated with a specific port number.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sepolicy network --port 8080&lt;br /&gt;8080: tcp unreserved_port_t 1024-32767&lt;br /&gt;8080: udp unreserved_port_t 1024-32767&lt;br /&gt;8080: tcp http_cache_port_t 8080&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Or what port number is associated with a port type.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sepolicy network -t dns_port_t&lt;br /&gt;dns_port_t: tcp: 53&lt;br /&gt;dns_port_t: udp: 53&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that sepolicy also supports bash completion.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sepolicy network -t d&amp;lt;tab&amp;gt;&lt;br /&gt;daap_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dccm_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dhcpc_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp; dict_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dns_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dogtag_port_t &amp;nbsp;&lt;br /&gt;dbskkd_port_t&amp;nbsp;&amp;nbsp; dcc_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dhcpd_port_t&amp;nbsp;&amp;nbsp;&amp;nbsp; distccd_port_t&amp;nbsp; dnssec_port_t &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Finally you can ask which ports a process domain type is allowed to connect or bind:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# sepolicy network -d cupsd_t&lt;br /&gt;cupsd_t: tcp name_connect&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; all ports&lt;br /&gt;cupsd_t: tcp name_bind&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reserved_port_t: 1-511&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rpc_port_type: all ports &amp;gt; 500 and&amp;nbsp; &amp;lt; 1024&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ipp_port_t: 631,8610-8614&lt;br /&gt;cupsd_t: udp name_bind&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; howl_port_t: 5353&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ipp_port_t: 631,8610-8614&lt;/span&gt;&lt;br /&gt;</description>
	<pubDate>Sat, 27 Oct 2012 11:57:24 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 8: Introducing sepolicy manpage</title>
	<guid>http://danwalsh.livejournal.com/60366.html</guid>
	<link>http://danwalsh.livejournal.com/60366.html</link>
	<description>In my previous blog, I introduced the sepolicy command, today I am going to talk about sepolicy manpage.&amp;nbsp; This is probably the most important command in the sepolicy command suite.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;man sepolicy-manpage&lt;br /&gt;sepolicy-manpage(8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-manpage(8)&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy-manpage - Generate a man page based on the installed SELinux Policy&lt;br /&gt;&lt;br /&gt;SYNOPSIS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy manpage [-w] [-h] [-p PATH ] [-a | -d ]&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Use sepolicy manpage to generate manpages based on SELinux Policy.&lt;br /&gt;&lt;br /&gt;OPTIONS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -a, --all&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate Man Pages for All Domains&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -d, --domain&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate a Man Page for the specified domain. (Supports multiple commands)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -h, --help&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Display help message&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -w, --web&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate an additonal HTML man pages for the specified domain(s).&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -p, --path&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specify the directory to store the created man pages. (Default to /tmp)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We are now using this tool to generate hundreds of man pages to document SELinux policy on every process domain.&lt;br /&gt;Each confined domains will have an _selinux extension added for example.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;man httpd_selinux&lt;br /&gt;httpd_selinux(8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELinux Policy documentation for httpd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_selinux(8)&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_selinux - Security Enhanced Linux Policy for the httpd processes&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Security-Enhanced Linux secures the httpd processes via flexible mandatory access control.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The&amp;nbsp; httpd&amp;nbsp; processes&amp;nbsp; execute with the httpd_t SELinux type. You can check if you have these processes running by executing the ps command&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with the -Z qualifier.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For example:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ps -eZ | grep httpd_t&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;These are pretty extensive man pages including sections:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Process types associated with the domain, the tool attempts to associate all process types that begin with the same prefix as the target domain.&lt;/li&gt;&lt;li&gt;File Types associated with the domain. &amp;nbsp; This will list all file types that are included in this policy.&amp;nbsp; (Using the prefix to gather the information)&amp;nbsp; The man page describes what the type is used for, along with the default path labelling on the system.&lt;/li&gt;&lt;li&gt;Booleans associated with the domain.&amp;nbsp; The manpage lists all booleans matching the prefix and then describes what the boolean is used for.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Port Types associated with the domain.&amp;nbsp; The manpage lists the port types matching the prefix and describes the default port numbers assigned to these port types.&lt;/li&gt;&lt;li&gt;Sharing Types associated with the domain.&amp;nbsp; If the domain uses &amp;quot;Sharing Types&amp;quot;&amp;nbsp; like public_content_t, the man page will have a section explaining how to use them.&lt;/li&gt;&lt;li&gt;Managed Files section describes the types that the domain is allowed to write and the default paths associated with these types.&lt;/li&gt;&lt;/ul&gt;This is pretty extensive documentation, and the beauty of it, is that it is automatically generated so it will not get out of date.&amp;nbsp;&lt;br /&gt;In Fedora 18, the man page for Apache is over 1600 lines long.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; man httpd_selinux&amp;nbsp; | wc -l&lt;br /&gt;1603&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Currently in Fedora 18 we have over 700 man pages.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; man -k selinux | grep _selinux | wc -l&lt;br /&gt;734&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Miroslav Grepl is building a web site that will list all SELinux Policy Man pages for RHEL6, Fedora 17 and Fedora 18.&lt;br /&gt;</description>
	<pubDate>Fri, 26 Oct 2012 12:05:56 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 8: Introducing sepolicy</title>
	<guid>http://danwalsh.livejournal.com/60135.html</guid>
	<link>http://danwalsh.livejournal.com/60135.html</link>
	<description>Over the years people have struggled to understand SELinux Policy and how it confined applications.&amp;nbsp; Administrators would want to know what types the Apache process can read or write.&amp;nbsp; What booleans were available for samba.&amp;nbsp; Can one domain write to the users home directory?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sepolicy python bindings&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The tool suite we had to do this was called setools, which included apol (A tcl/tk graphical tool) and sesearch and seinfo.&amp;nbsp; I found that I hardly ever used apol and mainly used sesearch and seinfo.&amp;nbsp; But I wanted more control.&amp;nbsp; I decided to add python bindings for these two commands, which in prior releases were in setools package.&amp;nbsp; These python bindings were rejected for merging upstream, for whatever reason.&amp;nbsp; I decided to move them into their own package sepolicy.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; python&lt;br /&gt;Python 2.7.3 (default, Aug&amp;nbsp; 9 2012, 17:23:57)&lt;br /&gt;[GCC 4.7.1 20120720 (Red Hat 4.7.1-5)] on linux2&lt;br /&gt;Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; import sepolicy&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; sepolicy.info(sepolicy.ATTRIBUTE)&lt;/span&gt;&lt;br /&gt;Returns a dictionary of all information about SELinux Attributes&lt;br /&gt;&lt;span&gt;&amp;gt;&amp;gt;&amp;gt;sepolicy.search([sepolicy.ALLOW])&lt;/span&gt;&lt;br /&gt;Returns you a dictionary of all allow rules in the policy.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;sepolicy command&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Using these python bindings we have begun to build&amp;nbsp; a new series of commands that I have found very useful for understanding policy.&amp;nbsp; I decided to combine these tools into a new command line tool sepolicy.&amp;nbsp;&amp;nbsp;&amp;nbsp; Some of these tools I have blogged about in the past but now I have consolidated them into a single tool and made it part of the distribution.&amp;nbsp; Over the next couple of blogs I will explain some of the tools.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; man sepolicy&lt;br /&gt;&lt;br /&gt;sepolicy(8)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy(8)&lt;br /&gt;&lt;br /&gt;NAME&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy - SELinux Policy Inspection tool&lt;br /&gt;&lt;br /&gt;SYNOPSIS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; semanage {manpage,network,communicate,transition,generate} OPTIONS&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Arguments:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; communicate&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Query SELinux policy to see if domains can communicate with each other sepolicy-communicate(8)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; generate&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate SELinux Policy module template sepolicy-generate(8)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; manpage&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Generate SELinux man pages sepolicy-manpage(8)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; network&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Query SELinux policy network information sepolicy-network(8)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; transition&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Query SELinux Policy to see how a source process domain can transition to the target process domain sepolicy-transition(8)&lt;br /&gt;&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sepolicy&amp;nbsp; is&amp;nbsp; a&amp;nbsp; tools set that will query the installed SELinux policy and generate useful reports, man pages, or even new policy modules.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; See the argument specific man pages for options and descriptions.&lt;/span&gt;&lt;br /&gt;</description>
	<pubDate>Fri, 26 Oct 2012 11:27:36 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: sandbox can now shred in Fedora 18 and RHEL7</title>
	<guid>http://danwalsh.livejournal.com/59788.html</guid>
	<link>http://danwalsh.livejournal.com/59788.html</link>
	<description>I have heard from a couple of people who are real concerned about security, that they wanted sandbox to not only delete the content but to &amp;quot;shred&amp;quot; it on exit.&lt;br /&gt;&lt;br /&gt;policycoreutils-2.1.13-17.fc18&lt;br /&gt;policycoreutils-2.1.13-17.el7&lt;br /&gt;&lt;br /&gt;man shred&lt;br /&gt;...&lt;br /&gt;DESCRIPTION&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Overwrite&amp;nbsp; the specified FILE(s) repeatedly, in order to make it harder&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for even very expensive hardware probing to recover the data.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;cat untrustedcontent | sandbox --shred sandbox -M filter.sh &amp;gt; /tmp/trustedcontent&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sandbox -X -s -W metacity firefox&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Fri, 26 Oct 2012 10:33:34 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: Process Confinement in Fedora 18</title>
	<guid>http://danwalsh.livejournal.com/59536.html</guid>
	<link>http://danwalsh.livejournal.com/59536.html</link>
	<description>I have not done this blog for a while.&lt;a href=&quot;http://danwalsh.livejournal.com/33287.html&quot; rel=&quot;nofollow&quot;&gt; Fedora 12?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A good estimate of the number of different confined processes is to count the number of types with the domain attribute.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;seinfo -adomain -x | tail -n +2 | wc -l&lt;br /&gt;707&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: I am removing the first line because it lists the attribute name.&lt;br /&gt;&lt;br /&gt;Not all domain types are confined. If we want to look at the number of unconfined domains, we can use the unconfined_domain_type attribute.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;seinfo -aunconfined_domain_type -x | tail -n +2 | wc -l&lt;br /&gt;61&lt;/span&gt;&lt;br /&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; width=&quot;200&quot;&gt;&lt;caption&gt;Unconfined Domains&lt;/caption&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;sosreport_t&lt;/td&gt;&lt;td&gt;bootloader_t&lt;/td&gt;&lt;td&gt;devicekit_power_t&lt;/td&gt;&lt;td&gt;nova_api_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nova_network_t&lt;/td&gt;&lt;td&gt;dirsrvadmin_unconfined_script_t&lt;/td&gt;&lt;td&gt;nova_objectstore_t&lt;/td&gt;&lt;td&gt;certmonger_unconfined_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;unconfined_cronjob_t&lt;/td&gt;&lt;td&gt;abrt_handle_event_t&lt;/td&gt;&lt;td&gt;setfiles_mac_t&lt;/td&gt;&lt;td&gt;initrc_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;fsadm_t&lt;/td&gt;&lt;td&gt;lvm_t&lt;/td&gt;&lt;td&gt;mdadm_t&lt;/td&gt;&lt;td&gt;rpm_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;wine_t&lt;/td&gt;&lt;td&gt;nova_vncproxy_t&lt;/td&gt;&lt;td&gt;unconfined_dbusd_t&lt;/td&gt;&lt;td&gt;nova_volume_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nova_scheduler_t&lt;/td&gt;&lt;td&gt;prelink_t&lt;/td&gt;&lt;td&gt;anaconda_t&lt;/td&gt;&lt;td&gt;boinc_project_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nova_ajax_t&lt;/td&gt;&lt;td&gt;rpm_script_t&lt;/td&gt;&lt;td&gt;system_cronjob_t&lt;/td&gt;&lt;td&gt;openshift_initrc_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;samba_unconfined_net_t&lt;/td&gt;&lt;td&gt;kdumpctl_t&lt;/td&gt;&lt;td&gt;devicekit_disk_t&lt;/td&gt;&lt;td&gt;firstboot_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;samba_unconfined_script_t&lt;/td&gt;&lt;td&gt;nagios_eventhandler_plugin_t&lt;/td&gt;&lt;td&gt;httpd_unconfined_script_t&lt;/td&gt;&lt;td&gt;depmod_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;insmod_t&lt;/td&gt;&lt;td&gt;kernel_t&lt;/td&gt;&lt;td&gt;livecd_t&lt;/td&gt;&lt;td&gt;puppet_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;tomcat_t&lt;/td&gt;&lt;td&gt;apmd_t&lt;/td&gt;&lt;td&gt;clvmd_t&lt;/td&gt;&lt;td&gt;crond_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;inetd_t&lt;/td&gt;&lt;td&gt;init_t&lt;/td&gt;&lt;td&gt;udev_t&lt;/td&gt;&lt;td&gt;virtd_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nagios_unconfined_plugin_t&lt;/td&gt;&lt;td&gt;rgmanager_t&lt;/td&gt;&lt;td&gt;devicekit_t&lt;/td&gt;&lt;td&gt;inetd_child_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;nova_direct_t&lt;/td&gt;&lt;td&gt;semanage_t&lt;/td&gt;&lt;td&gt;sge_shepherd_t&lt;/td&gt;&lt;td&gt;xdm_unconfined_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;unconfined_t&lt;/td&gt;&lt;td&gt;abrt_watch_log_t&lt;/td&gt;&lt;td&gt;sge_job_t&lt;/td&gt;&lt;td&gt;xserver_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;If you disable the unconfined policy package, which I recommend.&lt;br /&gt;&lt;br /&gt;This leaves only user domains unconfined, along with some domains that do not make sense to confine.&amp;nbsp; (anaconda, firstboot, kernel,rpm)&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semodule -d unconfined&lt;br /&gt;seinfo -aunconfined_domain_type -x | tail -n +2 | wc -l&lt;br /&gt;14&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; width=&quot;200&quot;&gt;&lt;caption&gt;Unconfined Domains&lt;/caption&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;rpm_t&lt;/td&gt;&lt;td&gt;anaconda_t&lt;/td&gt;&lt;td&gt;rpm_script_t&lt;/td&gt;&lt;td&gt;openshift_initrc_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;firstboot_t&lt;/td&gt;&lt;td&gt;kernel_t&lt;/td&gt;&lt;td&gt;livecd_t&lt;/td&gt;&lt;td&gt;unconfined_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;You can disable all unconfined domains by disabling unconfineduser module&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# semodule -d unconfineduser&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note: You need to setup all your users as confined users, before removing the unconfineduser module.&lt;br /&gt;Disabling the unconfined and unconfineduser policy modules is the equivalent of what we used to call strict policy.&lt;br /&gt;&lt;br /&gt;One other interesting domain is permissive domains. Permissive domains can be listed with the --permissive qualifier.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# seinfo --permissive -x | tail -n +3 | wc -l&lt;br /&gt;31&lt;/span&gt;&lt;br /&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; width=&quot;200&quot;&gt;&lt;caption&gt;Permissive Domains&lt;/caption&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;phpfpm_t&lt;/td&gt;&lt;td&gt;virt_qemu_ga_t&lt;/td&gt;&lt;td&gt;pkcsslotd_t&lt;/td&gt;&lt;td&gt;realmd_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;mandb_t&lt;/td&gt;&lt;td&gt;rngd_t&lt;/td&gt;&lt;td&gt;slpd_t&lt;/td&gt;&lt;td&gt;glusterd_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;stapserver_t&lt;/td&gt;&lt;td&gt;sensord_t&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;A couple of other interesting statistics.&lt;br /&gt;&lt;br /&gt;Total number of file types.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;seinfo -afile_type -x | tail -n +2&amp;nbsp; | wc -l&lt;br /&gt;2375&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In order to get the number of allow rules, you need to use sesearch&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch --allow | wc -l&lt;/span&gt;&lt;br /&gt;81736&lt;br /&gt;&lt;br /&gt;Dontaudit Rules&lt;br /&gt;&lt;br /&gt;&lt;span&gt;sesearch --dontaudit | wc -l&lt;/span&gt;&lt;br /&gt;6532</description>
	<pubDate>Thu, 18 Oct 2012 19:00:26 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 7: Secure Linux Containers</title>
	<guid>http://danwalsh.livejournal.com/59144.html</guid>
	<link>http://danwalsh.livejournal.com/59144.html</link>
	<description>&lt;h1&gt;&lt;span&gt;Secure Linux Containers&lt;/span&gt;&lt;/h1&gt;&lt;p&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/Securecontainers&quot; rel=&quot;nofollow&quot;&gt;In Fedora 18 we have enhanced the libvirt-sandbox package to allow for easy creation of Secure Containers.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Containers are a form of isolating one or more processes from the rest of the system.&amp;nbsp; Some times containers are described as lightweight virtualization.&amp;nbsp; Containers are really just a userspace concept.&amp;nbsp; The Linux kernel has no concept of a container.&amp;nbsp; The kernel implements namespaces and cgroups.&amp;nbsp; Userspace tools can combine these kernel services into a &amp;quot;container&amp;quot;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Namespaces&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Namespaces are a way of changing a processes view of its environment from its parents processes.&amp;nbsp; For example the file system namespace allows me to change a processes view of the file system hierarchy.&amp;nbsp; pam_namespace introduced way back in Fedora 6/RHEL5, allowed a login program to create a namespace and mount file systems that would not be seen by the ancestor processes.&amp;nbsp; Meaning I could have multiple processes with different /tmp directories and multiple home directories mounted on /home/dwalsh.&lt;br /&gt;&lt;br /&gt;The kernel currently implements 5 name spaces.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;mount - mounting&amp;nbsp; and unmounting filesystems will not affect rest of the system&amp;nbsp;&lt;/li&gt;&lt;li&gt;UTS - setting hostname, domainname will not affect rest of the system&lt;/li&gt;&lt;li&gt;IPC - process will have independent namespace for System V message queues, semaphore sets and shared memory segments&lt;/li&gt;&lt;li&gt;network - process will have independent IPv4 and IPv6 stacks, IP routing tables, firewall rules, the /proc/net&amp;nbsp; and&amp;nbsp; /sys/class/net&amp;nbsp; directory trees, sockets etc.&lt;/li&gt;&lt;li&gt;pid - processes have an independent pids from the rest of the system.&amp;nbsp; Each namespace can have its own pid 1.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;span&gt;Note: A UID namespace is being developed, but is not ready to be used yet, and I have some concerns about how well this will work. Our tools do not currently use the UID namespace.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;pam_namespace, sandbox -X, unshare, systemd allow allow you to take advantage of namespaces.&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Cgroups&quot; rel=&quot;nofollow&quot;&gt;&lt;b&gt;CGROUPS&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Wikipedia describes cgroups as:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; cgroups (control groups) is a Linux kernel feature to limit, account and isolate resource usage (CPU, memory, disk I/O, etc.) of process groups.&lt;br /&gt;&lt;br /&gt;Basically you can use cgroups to control the amount of resources a process or groups of processes can get on a system.&amp;nbsp;&lt;br /&gt;&lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/Presentations/cgroups.ogv&quot; rel=&quot;nofollow&quot;&gt;I put together a little screen-cast of cgroups to demonstrate their power.&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;LXC&lt;/b&gt;&lt;br /&gt;Tools like LXC have existed for a while to allow users to create containers but the tool set is at a very low level&lt;b&gt;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Libvirt-lxc&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;quot;Libvirt is a C toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes). The main package includes the libvirtd server exporting the virtualization support.&amp;quot;&lt;br /&gt;&lt;br /&gt;libvirt-lxc was introduced in Fedora 16. It enhanced the libvirt API to allow users to build containers using libvirt.&amp;nbsp; This allows you to manage your kvm/qemu virtualization along with your linux containers, all within the same framework.&amp;nbsp; The only problem, is setting up a linux container using the libvirt api is fairly difficult.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/VirtSandbox&quot; rel=&quot;nofollow&quot;&gt;libvirt-sandbox&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Dan Berrange created a new package called libvirt-sandbox in Fedora 17.&amp;nbsp; The libvirt-sandbox package provides an application development library (libvirt-sandbox) to facilitate the embedding of virtualization into applications.&amp;nbsp; One of the main advantages of this new tool set, was that it greatly simplified the API for creating virtual machines and containers.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SELinux&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Using containers by itself does not give you good security separation.&amp;nbsp; The reason for this is kernel file systems like /proc, /sys, cgroupsfs and selinuxfs are not containerized.&amp;nbsp; A privileged process running within a container can affect other processes running outside of the container or processes running in other containers.&amp;nbsp; In libvirt-sandbox and libvirt-lxc you can use SELinux Labelling to further lock down privileged processes, for example preventing mounting of random file systems or stopping processes from disabling SELinux.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;virt-sandbox-service&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Dan Berrange and I have been working to enhance libvirt-sandbox.&amp;nbsp; We have added a command line tool called virt-sandbox-service which allows a user to easily create an application sandbox.&amp;nbsp; virt-sandbox-service allows an administrator to run multiple services on the same machine each service in a secure Linux Container.&amp;nbsp;&amp;nbsp; Some major features of virt-sandbox-service containers.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Use systemd within the container as the init processes.&lt;/li&gt;&lt;li&gt;Uses standard unit files for starting and stopping containerized applications.&lt;/li&gt;&lt;li&gt;Shares the /usr partition, meaning if you are running hundreds of Apache containers, and update Apache code, each container will instantly use the new version of Apache.&lt;/li&gt;&lt;li&gt;Uses SELinux MCS Labelling to separate each container, preventing even root processes from interfering with the host or other containers.&lt;/li&gt;&lt;/ul&gt;The goal of this tool is not to allow general purpose applications to run within the container, although we will work to get most services to be able to run.&amp;nbsp; The tool is not goaled at running full OS chroot, but more towards particular applications.&lt;br /&gt;&lt;br /&gt;I have done preliminary tests on running.&amp;nbsp; httpd, mysql, postgresql, dovecot within these containers.&amp;nbsp; I am hoping people begin to play with the tool and help us expand which applications can run within the container.&amp;nbsp; Also you can run multiple applications within a container at the same time.&amp;nbsp; For example, I have tested httpd and mysql running within the same container.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to use:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# yum install libvirt-sandbox httpd&lt;/span&gt;&lt;br /&gt;There is a bug in the tool right now where it will not work without an /selinux file.&lt;br /&gt;&lt;span&gt;# touch /selinux&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Use the virt-sandbox-service command to create a container.&lt;/p&gt;&lt;pre&gt;&lt;span&gt;virt-sandbox-service create -C -l s0:c1,c2 -u httpd.service container1
Created sandbox container dir /var/lib/libvirt/filesystems/container1
Created sandbox config /etc/libvirt-sandbox/services/container1.sandbox
Created unit file /etc/systemd/system/container1_sandbox.service&lt;/span&gt;

&lt;/pre&gt;&lt;p&gt;Manipulate the data within the container while running outside of the container.&lt;/p&gt;&lt;pre&gt;&lt;span&gt;cd /var/lib/libvirt/filesystems/container1/var/log
touch content
ls -lZ content
# Make sure the content gets created with the correct MCS label.
# Content should be labeled with s0:c1,c2&amp;nbsp;: Not s0
&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span&gt;Now create a file with a bad label for the container.
cat &amp;quot;Secret&amp;quot; &amp;gt; badcontent
chcon -l s0:c3,c4 badcontent
 
&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Start the container:&lt;/p&gt;&lt;pre&gt;&lt;span&gt;virt-sandbox-service start container1
&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;In another window&lt;/p&gt;&lt;p&gt;Make sure the processes are running with the proper SELinux label. ps -eZ | grep svirt_lxc You should see processes like systemd, systemd-journal, dhclient and httpd running within the container with the MCS label of s0:c1,c2&lt;/p&gt;&lt;p&gt;Connect to the container&lt;/p&gt;&lt;pre&gt;&lt;span&gt;virt-sandbox-service connect container1
id 
getenforce   # Should tell you SELinux is disabled.
setenforce 1 # Should be denied
touch /file  # Should deny you creating this file
touch /var/www/html/content  # Should be allowed
cat /var/www/html/badcontent # Should be denied
Configure the apache server any way you would like, and manipulate html pages
ifconfig eth0  # Grap IP Address for use on next test
# Use the shell running with in the container to attempt to break out of the container. 
^] 
&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;On your hosts Firefox use the IP within the container&lt;/p&gt;&lt;pre&gt;&lt;span&gt;firefox $IP # Using IP address from container, make sure you see the content.
&lt;/span&gt;
Shut down the container
&lt;/pre&gt;&lt;pre&gt;&lt;span&gt;virt-sandbox-service stop container1
&lt;/span&gt;
Now lets try to do the same but starting and stopping the container using systemctl commands
&lt;/pre&gt;&lt;pre&gt;&lt;span&gt;systemctl start container1_sandbox.service
systemctl enable container1_sandbox.service # Check on reboot if the container is running
&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Make sure the container is running.&lt;/p&gt;&lt;pre&gt;&lt;span&gt;virt-sandbox-service connect container1
ps -eZ
^]

&lt;/span&gt;&lt;span&gt;I would like to hear what you think?  What enhancements you would like to see?  What 
applications would you like to see run within the containers.  

Since this is a first version, we think there could be some growing pains, so use at your own 
risk, but we would love to work with the community to improve this tool set.
&lt;/span&gt;
&lt;/pre&gt;</description>
	<pubDate>Thu, 18 Oct 2012 15:54:24 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 6: KRB5 Credential Cache Moved under /run/user directory</title>
	<guid>http://danwalsh.livejournal.com/59060.html</guid>
	<link>http://danwalsh.livejournal.com/59060.html</link>
	<description>&lt;h1&gt;&lt;span&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/KRB5CacheMove&quot; rel=&quot;nofollow&quot;&gt;&lt;span&gt;KRB5 Credential Cache Move&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p&gt;The default location of a user's Kerberos Credential Cache (CC) has moved from /tmp to user directory under /run/user.&lt;br /&gt;&lt;br /&gt;Back in the 1980's, when Kerberos was first developed, various login programs were enhanced to talk to the Kerberos servers to authenticate users, and to store credentials (tickets and session keys) that they obtained while doing so in a file, sometimes called a ticket file, but now more commonly called a credential cache (ccache for short), for the user to use during their session.&lt;br /&gt;&lt;br /&gt;The cache had to be owned by the user, so that additional tickets obtained by the user could be added to the cache, and so that it could be cleared or just destroyed.&lt;br /&gt;&lt;br /&gt;For the sake of users whose credentials were needed for accessing a remote home directory, login programs could not store the credentials in the user's home directory.&amp;nbsp; Since the only other location where a user could write to was the /tmp directory, the cache file was stored there by default.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Security Problems with the Credential Cache file in /tmp.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;There were a couple of problems with storing the cache file in /tmp:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;All users of the system can write to /tmp.&amp;nbsp; To sidestep the possibility that a rogue user could trick the system into writing a user's credentials to an incorrect location, many login facilities would generate uniquely-named credential caches for users.&amp;nbsp; Others used predictable but different names for various other reasons.&lt;/li&gt;&lt;li&gt;But when the name of a user's credential cache isn't predictable, it can cause problems for services which don't run as part of the user's session, and which therefore can't consult the $KRB5CCNAME environment variable to discover which cache to use.&amp;nbsp; Services like these, for example rpc.gssd (the daemon which handles the client parts of Kerberized NFS), have historically had to make a best-guess as to what the Kerberos credential cache file's name was, and they had to do that by trawling through /tmp, looking for potential matches.&lt;/li&gt;&lt;li&gt;/tmp can be setup using pam_namespace such that processes running in the &amp;quot;root&amp;quot; namespace will see a different /tmp then the user sees when he logs in.&amp;nbsp; This can prevent services from even being able to find the Credential Cache.&lt;/li&gt;&lt;li&gt;The /tmp directory is often not a temporary file system.&amp;nbsp;&amp;nbsp; Logging out of the system or rebooting the system would not guarantee the Credential Cache would be removed/destroyed.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;b&gt;SSSD to the rescue in Fedora 18&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In Fedora 18 the Credential Cache file was moved by SSSD, System Security Services Daemon, to /run/user/UID/krb5cc_XXXXXX/tkt.&lt;br /&gt;Where XXXXXX is a random number.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;For example on my box when I execute klist i see the following:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; klist&lt;br /&gt;Ticket cache: DIR::/run/user/3267/krb5cc_ca3a4331e17e8e80cb0c46ea507840bc/tkt&lt;br /&gt;Default principal: dwalsh@REDHAT.COM&lt;br /&gt;&lt;br /&gt;Valid starting&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expires&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Service principal&lt;br /&gt;10/12/12 12:48:17&amp;nbsp; 10/12/12 22:48:17&amp;nbsp; krbtgt/REDHAT.COM@REDHAT.COM&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; renew until 10/12/12 12:48:17&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;Note: There are two colons between &amp;quot;DIR&amp;quot; and the path part of the ccache name gives away that the parent of the named path is the directory that's being used to hold the cache file (or possibly more than one cache file).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The main benefit here is that /run/user/3267 and all its sub-directories have a mask of 700 and are owned by dwalsh:dwalsh. No other users know that the cache is there, and they can't tell how big it is or when it was last touched.&amp;nbsp; This means we don't have to deal with other users trying to mess around in /tmp.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;Secondarily /run is always tmpfs,&amp;nbsp; if the user logs out cache gets destroyed and if the system crashes the cache file is also gone.&lt;br /&gt;&lt;br /&gt;Since the tickets are stored in a predictable path, privileged processes like rpc.gssd have an easy time finding the correct tickets.&amp;nbsp;&amp;nbsp; And since they are off of /tmp, pam_namespace will not hide the credential cache from the system services.&lt;br /&gt;&lt;br /&gt;Finally now SSSD can actually get multiple tickets from different domains and easily store them in the /run directory, allowing a user&lt;br /&gt;to login into multiple kerberos domains at the same time.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;</description>
	<pubDate>Mon, 15 Oct 2012 18:50:06 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 5: Systemd Secures Journald from attack</title>
	<guid>http://danwalsh.livejournal.com/58647.html</guid>
	<link>http://danwalsh.livejournal.com/58647.html</link>
	<description>&lt;span&gt;&lt;b&gt;Forward Secure Sealing (FSS)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Forward Secure Sealing is a new feature of systemd/journald in Fedora 18.&lt;br /&gt;&lt;br /&gt;If your machine is cracked, (Did you disable SELinux?) and a hacker gets administrative control, he wants to cover their tracks, by modifying the system log files.&amp;nbsp; This presents a problem in that you might not know when the machine was hacked and whether any of your log files have been tampered with.&amp;nbsp; Before FSS&amp;nbsp; the only way to know your log files have not been tampered with is to store them on a different machine, IE Setup rsysog and auditlogs to be sent to different machines.&amp;nbsp; With FSS you can verify the journald logs on your system and know if they have been tampered with.&amp;nbsp; Even better you will have an idea when the hacker started tampering with them, and which part of the logs files are still valid.&lt;br /&gt;&lt;br /&gt;The basic idea is you establish a verification ID and store it externally or just use a QR code and store it on a smart phone.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://plus.google.com/115547683951727699051/posts/g1E6AxVKtyc&quot; rel=&quot;nofollow&quot;&gt;Read&amp;nbsp;Lennart Poettering posting on Google+ For more explanation.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;https://lh4.googleusercontent.com/-Yby5d7CcSj0/UDKe0Hy1E4I/AAAAAAAACVY/D54WBgKGiYI/w497-h373/sealing.png&quot; title=&quot;&quot; /&gt;&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 09 Oct 2012 14:14:05 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 4: FreeIPA/SSSD distributes Confined SELinux Users</title>
	<guid>http://danwalsh.livejournal.com/58508.html</guid>
	<link>http://danwalsh.livejournal.com/58508.html</link>
	<description>&lt;span&gt;&lt;b&gt;FreeIPA now supports the distribution of SELinux Users&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.google.com/url?sa=t&amp;amp;rct=j&amp;amp;q=&amp;amp;esrc=s&amp;amp;source=web&amp;amp;cd=1&amp;amp;cad=rja&amp;amp;ved=0CCYQFjAA&amp;amp;url=http%3A%2F%2Fdanwalsh.livejournal.com%2F18312.html&amp;amp;ei=px10ULzsFZCG0QH-ioEg&amp;amp;usg=AFQjCNFU9-1YuMLPCvXOMgZAcKMYUX8t7w&quot; rel=&quot;nofollow&quot;&gt;Confined SELinux Users was introduced a while ago.&amp;nbsp;&lt;/a&gt; The basic idea is to give users different access depending on the machine they log into.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Using myself as an example, I regularly login to 5 different machines, not including VMs.&amp;nbsp; My Laptop, My Test machine, shell.devel.redhat.com, people.redhat.com and people.fedoraproject.com.&amp;nbsp;&lt;ul&gt;&lt;li&gt;people.redhat,com and people.fedoraproject.com: I should login as guest_u:guest_r:guest_t:s0.&amp;nbsp; These machines are used to share content via the Web Servers.&amp;nbsp; I should be only allowed to modify my home directory.&amp;nbsp; I should not have access to the network, setuid applications like su and sudo, or be able to build and execute code in the home directory.&lt;/li&gt;&lt;li&gt;shell.devel.redhat.com.&amp;nbsp; This machine is a shared developer shell machine, to be used by all developers.&amp;nbsp; I should be allowed to execute content in the home directory and maybe setup and test networking applications, since this is a development machine.&amp;nbsp; But I am not an administrator, I should not be allowed to execute su or sudo.&amp;nbsp; user_u:user_r:user_t:s0-s0:c0.c1023&amp;nbsp; would be a good SELinux user label for this machine.&lt;/li&gt;&lt;li&gt;My Laptop and test machines, (holycross and redsox), should either be setup to use unconfined_t or staff_t.&amp;nbsp; In my case I run them with staff_u:staff_r:staff_t:s0-s0:c0.c1023, and administrator processes as staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023.&lt;/li&gt;&lt;/ul&gt;The problem with this configuration is that each one of these machines has to be setup individually.&amp;nbsp; My identity is shared by a directory server and authorization is confirmed by kerberos.&amp;nbsp; But until now, there was no standard way to setup these confined users on a centralized server.&lt;br /&gt;&lt;br /&gt;One big advantage of FreeIPA is it adds identity to machines.&amp;nbsp; FreeIPA knows the difference between dwalsh on people.redhat.com versus dwalsh on shell.devel.redhat.com.&amp;nbsp; The FreeIPA team added the ability to store SELinux Users definitions based on User/Machine mappings.&lt;br /&gt;&lt;br /&gt;In Fedora 18 you will be able to setup confined users using the FreeIPA gui.&lt;br /&gt;&lt;br /&gt;&lt;img alt=&quot;&quot; height=&quot;827&quot; src=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/SELinux%20User%20Maps.png&quot; title=&quot;&quot; width=&quot;700&quot; /&gt;&lt;br /&gt;&lt;br /&gt;At Red Hat we could setup a user/machine mapping like all users on people.redhat.com will login with the SELinux user/level&amp;nbsp; guest_u:s0.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;SSSD plays a large role in assigning the SELinux User/Level from IPA to the user process at login.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When a user logins to a box say through sshd, sshd uses the pam stack.&amp;nbsp; One of the first pam modules used is pam_sss. pam_sss sends a request to SSSD telling it that dwalsh is logging in.&amp;nbsp; SSSD contacts the FreeIPA server and asks what SELinux User/Level should dwalsh get when he logs in.&amp;nbsp; SSSD takes the string returned and creates a file in /etc/selinux/POLICYTYPE/logins/dwalsh.&amp;nbsp; During the session of the pam stack, the pam_selinux&amp;nbsp; module is called.&amp;nbsp; pam_selinux reads /etc/selinux/POLICYTYPE/logins/dwalsh and tells the kernel to launch the user process with the SELinux User specified in FreeIPA, for example guest_u:guest_r:guest_t:s0.&lt;br /&gt;&lt;br /&gt;Currently SSSD only supports FreeIPA for this transaction.&amp;nbsp; In the future it could be modified to use other sources for SELinux information.&lt;br /&gt;&lt;pre&gt;
&lt;span&gt;Note: In FreeIPA you can set up a set of the Host Based Access Control rules. These rules define which users (and groups of users) have access to which machines (and groups of machines) via which login services (like ssh, ftp, sudo, su etc.) The administrator can reuse the user-host associations defined in the HBAC rules to define SELinux user mapping rules. This helps to avoid duplicate management and express a notion: user set X can access set of hosts Y and would get SELinux user Z.&lt;/span&gt;

&lt;/pre&gt;&lt;b&gt;I have been asked many times when I have given the Confined SELinux Users talk, about how would you manage confined users in a large environment, now we have a solution.&lt;/b&gt;</description>
	<pubDate>Tue, 09 Oct 2012 13:03:46 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dominick Grift: Easy ways to help improve refpolicy contrib</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-599643298734095008</guid>
	<link>http://selinux-mac.blogspot.com/2012/10/easy-ways-to-help-improve-refpolicy.html</link>
	<description>Here is what you can do to help improve refpolicy contrib for your distro and everyone else:&lt;br /&gt;&lt;br /&gt;1. See if the file context specification from the various modules in refpolicy contrib match the locations of the corresponding packages that your distribution uses.&lt;br /&gt;&lt;br /&gt;Here is how i do that on Fedora:&lt;br /&gt;&lt;br /&gt;I basically check each modules file context files.&lt;br /&gt;&lt;br /&gt;Find which package installs the executable file, either with the full path or if my package manager cannot find that using a wild card:&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;br /&gt;yum whatprovides /usr/sbin/someapp&lt;/blockquote&gt;or if it cannot find that:&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;yum whatprovides *\someapp&lt;/blockquote&gt;&lt;br /&gt;Then you should figure out which (applicable) locations that package installs.&lt;br /&gt;&lt;br /&gt;Applicable locations are among others:&lt;br /&gt;&lt;br /&gt;&lt;i&gt;/etc/someapp /etc/sysconfig/someapp /etc/default/someapp /var/lib/someapp /var/log/someapp /var/spool/someapp /etc/init.d/someapp /etc/rc.d/init.d/someapp /var/run/someapp /var/cache&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;In Fedora i use the handy repoquery tool for that. This tool allows me to list the files that a specificied package installs without me actually having to install the package&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;repoquery -ql someapp | less&lt;/blockquote&gt;&lt;br /&gt;&amp;nbsp;Labeling files properly is very important for SELinux operation and so you can improve your distributions SELinux experience by making use applicable files and locations are labeled correctly by fixing or adding the appropriate file context specification.&lt;br /&gt;&lt;br /&gt;2. Somewhat related to (1): label service etc files with a declared private type for etc files and allow the service to read files it owns with the private type, then also allow the &quot;service&quot;_admin() to find and manage content with that type.&lt;br /&gt;&lt;br /&gt;In the past we only use to label service etc files with a private&quot;files config file&quot; private type if the file has sensitive information.&lt;br /&gt;&lt;br /&gt;Later we came up with an idea to confine root using &quot;service&quot;_admin interfaces that give the caller access to manage a particular service and its files.&lt;br /&gt;&lt;br /&gt;However we do not want to give the &quot;service&quot;_admin access to manage generic etc_t files since that will allow the process to manage things it shouldnt, instead of just the configuration files for the service that the caller is allowed to manage.&lt;br /&gt;&lt;br /&gt;So we need to find each config file a confined service owns label that with a declared &quot;files_config_file&quot; file type, allow the owning service to read applicable content with that type and allow the service admin to get to and manage content with that type.&lt;br /&gt;&lt;br /&gt;You can use the method of (1) to find which etc files a package installs where&lt;br /&gt;&lt;br /&gt;Then if needed declare a new files_config_file type&lt;br /&gt;&lt;br /&gt;&lt;b&gt;type someapp_conf_t;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;files_config_file(someapp_conf_t)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Then make sure the file or directory is labeled correctly in the file context file. Some examples:&lt;br /&gt;&lt;br /&gt;Single configuration file:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;/etc/someapp\.conf -- gen_context(system_u:object_r:someapp_conf_t,s0)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A configuration directory and all its contents:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;/etc/someapp(/.*)? gen_context(system_u:object_r:someapp_conf_t,s0)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Then allow the service domain type to read the content:&lt;br /&gt;&lt;br /&gt;in case of a single file:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;allow someapp_t someapp_conf_t:file read_file_perms;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;in case of a directories and its contents:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;read_files_pattern(someapp_t, someapp_conf_t, someapp_conf_t)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If your service domain type is not already allowed to read generic etc_t files (e.g. if it does not have a rule similar to for example: files_read_etc_files(someapp_t) then you will also need to allow the service domain type to traverse etc_t directories so that it can actually get to there:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;files_search_etc(someapp_t)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If the module has a service admin interface, for example someapp_admin in the someapp.if interface file, then add the rules that will allow the caller to get to and manage content with the new type:&lt;br /&gt;&lt;br /&gt;a. Import the type by adding for example;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;type someapp_conf_t;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;to the existing &quot;&lt;i&gt;gen_require(`')&lt;/i&gt;&quot; block on top of the interface.&lt;br /&gt;&lt;br /&gt;b. Add the rules to allow caller to get to and manage the content with the new type , for example:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;files_search_etc($1)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;admin_pattern($1, someapp_conf_t)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Note: also consider environment files in /etc/sysconfig. We would want the service administrator to be able to manage those as well.&lt;br /&gt;&lt;br /&gt;If you are unsure about some specifics then look into existing source policy modules. Much efford goes into writing these modules as consistently as possible.&lt;br /&gt;&lt;br /&gt;This allows you to see patterns easily and will help you read the policy.&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Mon, 08 Oct 2012 06:21:59 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 3: New Confined/Permissive Process Domains</title>
	<guid>http://danwalsh.livejournal.com/58178.html</guid>
	<link>http://danwalsh.livejournal.com/58178.html</link>
	<description>Each Fedora we release a bunch of new domains that will run in permissive mode for the release.&amp;nbsp; When the next release is released, the permissive domains are made enforcing.&lt;br /&gt;&lt;br /&gt;In my blog,&lt;a href=&quot;http://danwalsh.livejournal.com/42394.html&quot; rel=&quot;nofollow&quot;&gt;10 things you probably did not know about SELinux.. #4&lt;/a&gt;, I describe how you can interact with permissive domains.&lt;br /&gt;&lt;br /&gt;In &lt;a href=&quot;http://danwalsh.livejournal.com/54343.html&quot; rel=&quot;nofollow&quot;&gt;Fedora 17&lt;/a&gt;, we added 11 new permissive domains, 10 of which are now enforcing in Fedora 18.&amp;nbsp; matahari policy was removed, since the project was cancelled.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 17 Permissive Domains/ Now Confined in Fedora 18&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;couchdb_t, blueman_t, httpd_zoneminder_script_t, zoneminder_t, selinux_munin_plugin_t, sge_shepherd_t, sge_execd_t,&lt;br /&gt;sge_job_t, keystone_t, pacemaker_t &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 18 Permissive Domains&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp; pkcsslotd_t (daemon manages PKCS#11 objects between PKCS#11-enabled applications)&lt;br /&gt;&amp;nbsp;&amp;nbsp; slpd_t&amp;nbsp; (Server Location Protocol Daemon)&lt;br /&gt;&amp;nbsp;&amp;nbsp; sensord_t (Sensor information logging daemon)&lt;br /&gt;&amp;nbsp;&amp;nbsp; mandb_t&amp;nbsp; (Cron job used to create /var/cache/man content)&lt;br /&gt;&amp;nbsp;&amp;nbsp; glusterd_t (policy for glusterd service)&lt;br /&gt;&amp;nbsp;&amp;nbsp; stapserver_t (Instrumentation System Server) Note: This was back ported to Fedora 17.&lt;br /&gt;&amp;nbsp;&amp;nbsp; realmd_t (dbus system service which manages discovery and enrollment in realms and domains like Active Directory or IPA)&lt;br /&gt;&amp;nbsp;&amp;nbsp; phpfpm_t (FastCGI Process Manager) &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 18 Confined Domains&lt;/b&gt;&lt;br /&gt;With the open sourcing of OpenShift we have created several new process domains.&amp;nbsp; openshift controls separation between each of its users and users applications, which means it needs to be confined out of the box.&amp;nbsp; &lt;span&gt;openshift_t &lt;/span&gt;is the type that each application runs as, with a difference MCS label.&amp;nbsp; I will blog on the openshift policy in the future.&lt;br /&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openshift_app_t, openshift_cgroup_read_t, openshift_initrc_t, httpd_openshift_script_t, openshift_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 18 Domains Removed&lt;/b&gt;&lt;br /&gt;&lt;span&gt;matahari (Project cancelled)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 18 Domains Reorganization&lt;/b&gt;&lt;br /&gt;We split &lt;span&gt;sandbox&lt;/span&gt; and &lt;span&gt;sandboxX&lt;/span&gt; policy apart, in order to shrink the policy size. and now disable sandbox policy by default.&amp;nbsp; We are doing this because not many people use sandbox (Character only version of sandbox, used for pipes and streams) versus sandboxX.&amp;nbsp; sandbox policy is very big, and disabling by default reduces the size of policy by around 8%.&lt;br /&gt;</description>
	<pubDate>Thu, 04 Oct 2012 14:32:16 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 2: Mutual Trusts with Active Directory domains</title>
	<guid>http://danwalsh.livejournal.com/58032.html</guid>
	<link>http://danwalsh.livejournal.com/58032.html</link>
	<description>&lt;p&gt;FreeIPA has a couple of new features that are showing up in Fedora 18.&amp;nbsp; Support for SELinux Confined User labelling will be covered in a future blog...&amp;nbsp; In this blog I will be talking about better integration with Windows environments.&lt;br /&gt;&lt;br /&gt;I am saddened to realize that there are still people out there using Microsoft Windows! &amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;My house has been Windows free for a number of years now.&amp;nbsp; It is a lot darker, but much more secure! :^)&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;I also have heard that those Windows environments are using Active Directory.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Well Fedora 18 will make these environments a little more secure.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/IPAv3Trusts&quot; rel=&quot;nofollow&quot;&gt;&lt;b&gt;&lt;span&gt;FreeIPA and Active Directory can be setup with mutual trust.&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In Fedora 18 it is possible to create a trust relationship between an FreeIPA and an Active Directory domain.&amp;nbsp; This means users defined in Active Directory can access resources defined in FreeIPA.&amp;nbsp; In a future release,&amp;nbsp; users defined in FreeIPA will be able to access resources defined in Active Directory.&amp;nbsp; You can manage all of your user accounts in a single place.&amp;nbsp; If you are using Active Directory to manage your users, you can now use the same user accounts on your Linux boxes.&lt;br /&gt;&lt;br /&gt;Fedora 17 FreeIPA used &lt;i&gt;winsync&lt;/i&gt; to allow users from an Active Directory domain to access resources in the IPA domain. To achieve this &lt;i&gt;winsync&lt;/i&gt; had to replicate the user and password data from an Active Directory server to FreeIPA server and attempt to keep them in sync.&amp;nbsp; Causing potential race conditions.&lt;/p&gt;&lt;p&gt;In Fedora 18,&amp;nbsp; SSSD, System Security Services Daemon, has been enhanced to work with AD.&amp;nbsp; SSSD understands some of the native AD controls and features that it did not understand in the previous Fedoras.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can set this up without using FreeIPA at all!&lt;br /&gt;&lt;br /&gt;In addition SSSD can work in the environment where it is connected to FreeIPA that is in trust relationships with AD. In this case, SSSD not only recognises users defined in FreeIPA but also recognizes users coming from the trusted AD domains.&amp;nbsp; SSSD can read user and group directory data directly from the Active Directory server.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Additionally if you do use FreeIPA you can setup Kerberos cross realm trust.&amp;nbsp; This allows Single-Sign-On between the Active Directory and the IPA domain.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;A user from the Active Directory Domain can access kerberized resources from the FreeIPA domain without being asked for a password. &lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;If you choose to setup users in the FreeIPA Domain, they will be able to access resources from the Active Directory domain.&lt;/b&gt; &lt;b&gt;No need to set POSIX attributes in the Active Directory Domain&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Single sign-on for all kerberized services is possible &lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;We may never get to full single sign on, where I only have one password asked of me, but this is a step in right direction.&lt;br /&gt;</description>
	<pubDate>Mon, 01 Oct 2012 15:45:30 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dominick Grift: Determine whether Cron can execute jobs on behalf of the user with login user SELinux permissions</title>
	<guid>tag:blogger.com,1999:blog-5024703430482213163.post-1636918091957103071</guid>
	<link>http://selinux-mac.blogspot.com/2012/09/determine-whether-cron-can-execute-jobs.html</link>
	<description>Cron would run jobs on behalf of users in a &quot;cronjob&quot; domain. This domain is reasonable restricted compared to the domain in which most users operate.&lt;br /&gt;&lt;br /&gt;Fedora changed this behaviour to allow Cron to execute these jobs in the default login user domain of the user that owns the job.&lt;br /&gt;&lt;br /&gt;Recently i added a boolean to Reference policy that enables one to tune the policy to allow Cron to run user cronjobs in the default login user domain conditionaly.&lt;br /&gt;&lt;br /&gt;By default Cron will still execute the jobs in the Cron job domain but if you toggle the &lt;i&gt;cron_userdomain_transition&lt;/i&gt; boolean to &lt;b&gt;true&lt;/b&gt; then Cron will run the jobs in the default login user domain of the user owning the job.&lt;br /&gt;&lt;br /&gt;This allows Cron to run jobs with the SE-Linux permissions that the owner of the job has.&lt;br /&gt;&lt;br /&gt;Cron is SELinux aware. It queries the policy to see to which domain it should transition when running a job.&lt;br /&gt;&lt;br /&gt;It does not do a automatic domain transition because it does not actually execute the Cron job. Instead if uses &lt;i&gt;&quot;setexec&quot;&lt;/i&gt; to domain transition.&lt;br /&gt;&lt;br /&gt;It looks to see to which domains the Cron job file is a entrypoint. Then it needs to be able to process transition to that domain and then it checks the default login user domain of a user and with this information it determines in which domain to execute the job&lt;br /&gt;&lt;br /&gt;By default:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;allow cronjob_t user_cron_spool_t:file entrypoint;&lt;br /&gt;allow crond_t cronjob_t:process transition;&lt;/blockquote&gt;&lt;br /&gt;Then there is a default context of for staff this is for example:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;system_r:crond_t:s0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; staff_r:cronjob_t:s0&lt;/blockquote&gt;&lt;br /&gt;But when you tune the policy with &lt;i&gt;cron_userdomain_transition &lt;/i&gt;then these rules will be replaced by:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;allow $1 user_cron_spool_t:file entrypoint;&lt;br /&gt;allow crond_t $1:process transition;&lt;/blockquote&gt;&lt;br /&gt;Where &lt;b&gt;$1&lt;/b&gt; is the calling login user domain, and then it will look up the default login user domain and role, for staff this is for example:&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;# semanage user -l | grep staff_u&lt;br /&gt;staff_u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SystemLow&amp;nbsp; SystemLow-SystemHigh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_r sysadm_r system_r unconfined_r&lt;/blockquote&gt;That means:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&quot;staff_r:staff_t&quot;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Then Cron daemon has permission to run the job in the staff domain with the staff role.&lt;br /&gt;&lt;br /&gt;The benefits of running jobs in the login user domain are that now your Cron job can interact with your processes and operate on your files as if it were you interacting with your processes and operating on your files.&lt;br /&gt;&lt;br /&gt;Needless to say that other SE-Linux rules that apply to you now also apply to your Cron jobs.&lt;br /&gt;&lt;br /&gt;The policy may still have some rough edges but it was tested on Gentoo and is said to work. I did make some changes after that but hopefully i have not introduced regression.&lt;br /&gt;&lt;br /&gt;Currently Redhat distributions do not have this &lt;i&gt;cron_userdomain_transition &lt;/i&gt;boolean and i am not sure if she will adopt it.</description>
	<pubDate>Sun, 30 Sep 2012 12:07:20 +0000</pubDate>
	<dc:creator>Dominick &quot;domg472&quot; Grift (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>Dan Walsh: Where does SELinux allow my application to write?</title>
	<guid>http://danwalsh.livejournal.com/57723.html</guid>
	<link>http://danwalsh.livejournal.com/57723.html</link>
	<description>&lt;span&gt;&lt;b&gt;SELinux's Number one goal:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Stop confined application/process from affecting other processes on the system.&amp;nbsp; &lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One of the biggest ways that a process can affect another process is by writing content that that process reads.&amp;nbsp;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If a hacked process can write ~/.bashrc in a users home directory; the next time the user logs in, the hacker gets control of a process running as unconfined_t.&lt;/li&gt;&lt;li&gt;If a hacked process can write to /etc/httpd/config, the hacker gets control of the Apache process.&lt;/li&gt;&lt;/ul&gt;Because of this SELinux blocks confined applications the ability to write content, unless the directories/files have the proper labels.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;Users want to know:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What label is my application allowed to write to?&amp;nbsp;&lt;br /&gt;Where on the file system are these labels?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;For example in another blog, I got asked today where can mozilla_plugins write their logs?&lt;br /&gt;&lt;br /&gt;Well in an effort to better document SELinux policy we have been auto-generating man pages, and have just added a new section called &lt;b&gt;MANAGED FILES&lt;/b&gt;.&amp;nbsp; This section of the man page will list the files/directories that a confined application is able to write.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;man mozilla_plugin_selinux&lt;br /&gt;...&lt;br /&gt;MANAGED FILES&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The SELinux user type mozilla_plugin_t can manage&amp;nbsp; files&amp;nbsp; labelled&amp;nbsp; with&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the&amp;nbsp; following&amp;nbsp; file types.&amp;nbsp; The paths listed are the default paths for&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; these file types.&amp;nbsp; Note the processes UID still need to have&amp;nbsp; DAC&amp;nbsp; per‐&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; missions.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gnome_home_type&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; home_cert_t&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /root/.cert(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.kde/share/apps/networkmanagement/certificates(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.pki(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.cert(/.*)?&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mozilla_home_t&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.java(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.adobe(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.gnash(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.galeon(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.spicec(/.*)?&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /home/[^/]*/.mozilla(/.*)?&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In Fedora 18, we now have 951 man pages related to SELinux.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&amp;gt; man -k selinux | wc -l&lt;br /&gt;951&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We will be generating these Man Pages in Fedora 17 and RHEL6/RHEL6 and hope to put them up on a web site so that &amp;quot;search engines&amp;quot; will have an easier time searching them.&lt;br /&gt;&lt;br /&gt;You can generate your own man pages using these tools, which should be showing up in policycoreutils soon.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/segenman&quot; rel=&quot;nofollow&quot;&gt;http://people.fedoraproject.org/~dwalsh/SELinux/genman/segenman&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/senetwork.py&quot; rel=&quot;nofollow&quot;&gt;http://people.fedoraproject.org/~dwalsh/SELinux/genman/senetwork.py&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Fri, 28 Sep 2012 12:40:43 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Dan Walsh: New Security Feature in Fedora 18 Part 1: SELinux Systemd Access Control</title>
	<guid>http://danwalsh.livejournal.com/57377.html</guid>
	<link>http://danwalsh.livejournal.com/57377.html</link>
	<description>&lt;p&gt;For Fedora 17 I did a series of blogs on new security features. I guess it is time to start it for Fedora 18.&lt;br /&gt;&lt;span&gt;If you want me to talk about a new security feature,&amp;nbsp; email dwalsh@redhat.com, or comment on this blog.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;New Feature in Fedora 18 &lt;a href=&quot;https://fedoraproject.org/wiki/Features/SELinuxSystemdAccessControl&quot; rel=&quot;nofollow&quot;&gt;SELinux Systemd Access Control.&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In previous versions of Fedora/RHEL SELinux could control which processes were able to start/stop services based on the label of the process and the label on the Init Script.&lt;br /&gt;&lt;br /&gt;For example NetworkManager (NetworkManager_t) was allowed to execute /etc/init.d/ntp (ntp_initrc_exec_t) but not allowed to access /etc/init.d/httpd (httpd_initrc_exec_t).&lt;br /&gt;&lt;br /&gt;With the advent of systemd we lost this ability since systemd starts and stops all services.&lt;br /&gt;&lt;br /&gt;We had to allow NetworkManager (NetworkManager_t) to execute systemctl which would send a dbus message to systemd, and systemd would start/stop whatever service NetworkManager requested. Actually we ended up allowing NetworkManager to do everything systemctl could do.&amp;nbsp;&amp;nbsp; We also wanted to setup confined administrators, but we ended up having to allow them to either start/stop all services or no services.&amp;nbsp; We could no longer allow the webadm_t to only start/stop httpd_t.&lt;br /&gt;&lt;br /&gt;In Fedora 18, we have fixed this by making systemd an SELinux Access Manager.&amp;nbsp; Now systemd will retrieve the label of the process running systemctl or the process that sent systemd a dbus message.&amp;nbsp; systemd will then look up the label of the unit file that the process wanted to configure.&amp;nbsp; Finally systemd will ask the kernel if SELinux policy allows the specific access between the process label and the unit file label.&amp;nbsp; This means a hacked NetworkManager or any other application that needs to interact with systemd for a specific service can now be confined via SELinux.&amp;nbsp; Policy writers can use these fined grained controls to confine administrators.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Policy changes.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;We have added a new class to SELinux Policy called &amp;quot;&lt;span&gt;service&lt;/span&gt;&amp;quot;.&amp;nbsp; The service class has the following permissions defined:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;start stop status reload kill load enable disable&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This means a policy writer can allow a domain to get the status on a service or start and stop a service, but not enable or disable a service.&amp;nbsp; This gives us better control then we have ever had in the past.&lt;br /&gt;&lt;br /&gt;To demonstrate this, I setup webadm_t as my root process:&lt;br /&gt;&lt;span&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/18578.html&quot; rel=&quot;nofollow&quot;&gt;Note: For more information on setting up confined users see my other blogs.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# id -Z&lt;br /&gt;staff_u:webadm_r:webadm_t:s0-s0:c0.c1023&lt;br /&gt;# /bin/systemctl status httpd.service&lt;br /&gt;httpd.service - The Apache HTTP Server&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Active: inactive (dead)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; CGroup: name=systemd:/system/httpd.service&lt;br /&gt;&lt;br /&gt;# /bin/systemctl status NetworkManager.service&lt;br /&gt;Failed to issue method call: SELinux policy denies access.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In a separate window running as unconfined_t, I can look at the AVC message created.&lt;br /&gt;&lt;br /&gt;# id -Z&lt;br /&gt;staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023&lt;br /&gt;# ausearch -m user_avc&lt;br /&gt;time-&amp;gt;Thu Sep 27 08:54:10 2012&lt;br /&gt;type=USER_AVC msg=audit(1348750450.105:135): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc:&amp;nbsp; denied&amp;nbsp; { &lt;span&gt;status&lt;/span&gt; } for auid=3267 uid=0 gid=0 path=&amp;quot;&lt;span&gt;/usr/lib/systemd/system/NetworkManager.service&lt;/span&gt;&amp;quot; &lt;span&gt;cmdline=&amp;quot;/bin/systemctl status NetworkManager.service&amp;quot;&lt;/span&gt; scontext=staff_u:webadm_r:&lt;span&gt;webadm_t&lt;/span&gt;:s0-s0:c0.c1023 tcontext=system_u:object_r:&lt;span&gt;NetworkManager_unit_file_t&lt;/span&gt;:s0 tclass=&lt;span&gt;service&lt;/span&gt;&amp;nbsp; exe=&amp;quot;/usr/lib/systemd/systemd&amp;quot; sauid=0 hostname=? addr=? terminal=?'&lt;br /&gt;&lt;br /&gt;And of course you could use audit2allow to write policy to allow this access.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;audit2allow -la&lt;br /&gt;#============= webadm_t ==============&lt;br /&gt;allow webadm_t NetworkManager_unit_file_t:service status;&lt;br /&gt;&lt;br /&gt;# audit2allow -laR&lt;br /&gt;#============= webadm_t ==============&lt;br /&gt;networkmanager_systemctl(webadm_t)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Make sure you have the latest systemd and selinux-policy to try this out.&amp;nbsp; These are my current versions:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;rpm -q selinux-policy systemd&lt;br /&gt;selinux-policy-3.11.1-26.fc18.noarch&lt;br /&gt;systemd-191-2.fc18.x86_64&lt;/span&gt;&lt;/p&gt;</description>
	<pubDate>Thu, 27 Sep 2012 13:21:17 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Paul Moore: My LPC and LSS 2012 Presentations</title>
	<guid>urn:lj:livejournal.com:atom1:paulmoore:7947</guid>
	<link>http://paulmoore.livejournal.com/7947.html</link>
	<description>&lt;p&gt;I gave a brief presentation on virtualization security at the Linux Plumbers Conference this year as well as a lightning talk on seccomp/libseccomp at the Linux Security Summit.  The slides for both presentations are available below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Virtualization Security Discussion: &lt;a href=&quot;http://www.paul-moore.com/files/lj/virt_security-pmoore-lpc2012-r1.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.paul-moore.com/files/lj/virt_security-pmoore-lpc2012-r1.pdf&lt;/a&gt;&lt;br /&gt;Syscall Filtering Made (sort of) Easy: &lt;a href=&quot;http://www.paul-moore.com/files/lj/libseccomp-pmoore-lss2012-r1.pdf&quot; rel=&quot;nofollow&quot;&gt;http://www.paul-moore.com/files/lj/libseccomp-pmoore-lss2012-r1.pdf&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;</description>
	<pubDate>Wed, 12 Sep 2012 22:00:29 +0000</pubDate>
</item>
<item>
	<title>James Morris: Linux Security Summit 2012 – Slides published</title>
	<guid>http://blog.namei.org/?p=553</guid>
	<link>http://blog.namei.org/2012/09/11/linux-security-summit-2012-slides-published/</link>
	<description>&lt;p&gt;Slides from the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2012&quot;&gt;Linux Security Summit 2012&lt;/a&gt; talks are now available via the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2012/Schedule&quot;&gt;schedule page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It seems to have been a very successful event, with the move to a two-day format allowing for a day of refereed presentations, and then a day of more collaborative discussion.  We&amp;#8217;re aiming for a a similar format next year.&lt;/p&gt;
&lt;p&gt;Thanks to everyone who made the event happen: presenters, attendees, the program committee, and of course, the great team at Linux Foundation, who made everything work flawlessly!&lt;/p&gt;
&lt;p&gt;ETA: The slides from Matthew Garrett&amp;#8217;s keynote on UEFI Secure Boot are &lt;a href=&quot;http://kernsec.org/files/security_summit_uefi_2012.odp&quot;&gt;now up&lt;/a&gt;.&lt;/p&gt;</description>
	<pubDate>Mon, 10 Sep 2012 14:40:40 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>Dan Walsh: Running unconfined scripts from a confined domain</title>
	<guid>http://danwalsh.livejournal.com/57276.html</guid>
	<link>http://danwalsh.livejournal.com/57276.html</link>
	<description>I received the following email from an engineer named Marko.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;I've got a program (actually a shell script) which does various things and sudoers is configured so that users can run it without a pw being asked. By using sudo from the cmd line everything works as expected.&lt;br /&gt;&lt;br /&gt;However, if the script is invoked by udev rules (and thus run as root) under certain circumstances, it fails on several cases due to AVCs as the commands it is trying to execute won't work or the services it starts/stops fail partially as the context (udev_t) is not what it'd be when run with sudo from the command line. Examples include inability to communicate with dbus, accessing log/config files, etc. So figuring out all of those would be quite a task and if the local program is later changed it might require even more policy changes.&lt;br /&gt;&lt;br /&gt;So what would a custom policy look like for a program &amp;quot;foo&amp;quot; so that it would work equally well when invoked by udev like it now works when a user invokes it from the command like with sudo? Any examples, blog posts, howtos, etc to look at?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Basically since his users are most likely running as unconfined_t, the sudo command is running the script as unconfined_t and SELinux is not blocking anything.&amp;nbsp; When he runs the command out of udev, it is running as udev_t and udev_t is not allowed the access.&lt;br /&gt;&lt;br /&gt;To solve this problem, Marko has three choices:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Add the allow rules to allow udev to have all the access required to run his application&lt;/li&gt;&lt;li&gt;Write policy for his application and transition from udev and unconfined_t to this new domain.&lt;/li&gt;&lt;li&gt;Write policy to allow udev_t to transition to unconfined_t when running only his application.&lt;/li&gt;&lt;/ol&gt;Since Marko did not want to all udev scripts this access, he chose not to do 1.&amp;nbsp; Marko decided it would be to difficult to do 2 and difficult to maintain, so he chose to do 3.&lt;br /&gt;&lt;br /&gt;Here is the original policy written by Marko.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;# cat myapp.fc /usr/sbin/myapp --&lt;br /&gt;gen_context(system_u:object_r:myapp_exec_t, s0)&lt;br /&gt;&lt;br /&gt;# cat myapp.te&lt;br /&gt;policy_module(myapp, 1.0.0)&lt;br /&gt;&lt;br /&gt;require {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;type fs_t; type setfiles_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;type udev_t; type unconfined_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;class process transition;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;type myapp_exec_t;&lt;br /&gt;&lt;br /&gt;allow setfiles_t myapp_exec_t:file { getattr relabelto };&lt;br /&gt;allow myapp_exec_t fs_t:filesystem { associate };&lt;br /&gt;&lt;br /&gt;allow unconfined_t myapp_exec_t:file *;&lt;br /&gt;&lt;br /&gt;domain_auto_trans(udev_t, myapp_exec_t, unconfined_t);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Not bad.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The first problem I notice is lots of rules around myapp_exec_t.&amp;nbsp; Since the myapp_exec_t was never defined as a particular TYPE of type.&amp;nbsp; Since myapp_exec_t is planned to be used on a file or directory it needs to have the attribute&amp;nbsp; file_type.&amp;nbsp; All domains that interact with all files/directories, have rules defined in policy which allow them to interact with the attribute file_type.&amp;nbsp; You can add the file_type attribute to a file by using the files_type(myapp_exec_t) interface.&amp;nbsp; This will eliminate most of the rules involving myapp_exec_t.&lt;br /&gt;&lt;br /&gt;As a rule of thumb, anytime you define a new type in policy you should call an interface to define the &amp;quot;TYPE&amp;quot; of the type.&amp;nbsp; domain_type() for processes, files_type for files/directories, dev_node() for devices corenet_port() for network ports etc.&lt;br /&gt;&lt;br /&gt;Here is a my simpler policy.&lt;br /&gt;&lt;br /&gt;&lt;span&gt;policy_module(myapp, 1.0.1)&lt;br /&gt;gen_require(`&lt;br /&gt;&amp;nbsp; type udev_t;&lt;br /&gt;&amp;nbsp; type unconfined_t;&lt;br /&gt;&amp;nbsp; role system_r;&lt;br /&gt;')&lt;br /&gt;&lt;br /&gt;type myapp_exec_t;&lt;br /&gt;files_type(myapp_exec_t)&lt;br /&gt;&lt;br /&gt;domain_auto_trans(udev_t, myapp_exec_t, unconfined_t);&lt;br /&gt;allow unconfined_t myapp_exec_t:file entrypoint;&lt;br /&gt;role system_r types unconfined_t;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The domain_auto_trans rule tells the SELinux kernel, when a process labeled udev_t executes a file labeled myapp_exec_t, transition the new process to unconfined_t.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;SELinux controls the labels of &amp;quot;entrypoint&amp;quot;, so we need to state that myapp_exec_t is an entrypoint to the unconfined_t domain.&lt;br /&gt;For a further description of the entrypoint access see:&lt;a href=&quot;http://www.informit.com/articles/article.aspx?p=606586&amp;amp;seqNum=2&quot; rel=&quot;nofollow&quot;&gt; SELinux By Example&lt;/a&gt; 2.2.4&lt;br /&gt;&lt;br /&gt;Finally I added the role definition for system_r, since udev_t will be running as system_r, when it executes myapp_t it will attempt to run unconfined_t was system_u:system_r:unconfined_t:s0.&amp;nbsp; roles system_r types unconfined_t, states that the unconfined_t type can be executed in the system_r role.&lt;br /&gt;&lt;br /&gt;While the ideal solution for this problem from a security point of view would have been to write policy for myapp_t, and have unconfined_t and udev_t transition to this domain, as a work around and not shutting SELinux off this is a decent alternative.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt;:&amp;nbsp; When ever you write a shell script that will have more privs then the calling app, you should be really carefull that the calling application can not effect the running app.&amp;nbsp; The script needs to up its environment and ignores stuff from the calling program, if the script takes arguments you must be sure these arguments are handled properly and can not get the script to do something unexpected.&amp;nbsp; SELinux will protect you somewhat but you need to be careful.&amp;nbsp; Every python scripts I write, I always use &lt;b&gt;&amp;quot;#! /usr/bin/python -Es&amp;quot;&lt;/b&gt; for example.&amp;nbsp; &lt;a href=&quot;https://developer.apple.com/library/mac/#documentation/opensource/conceptual/shellscripting/ShellScriptSecurity/ShellScriptSecurity.html&quot; rel=&quot;nofollow&quot;&gt;Apple has a nice page on this.&lt;/a&gt;&lt;br /&gt;</description>
	<pubDate>Wed, 05 Sep 2012 19:31:27 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>
<item>
	<title>Thomas Biege (Security): SUSE Cloud: How we secured the Cloud</title>
	<guid>tag:blogger.com,1999:blog-5240359826706545510.post-3189813332154886746</guid>
	<link>http://thetoms-random-thoughts.blogspot.com/2012/09/suse-cloud-how-we-secured-cloud.html</link>
	<description>&lt;div class=&quot;separator&quot;&gt;&lt;a href=&quot;https://www.suse.com/common/img/product_icons/suseCloud_doormat_prodIcon.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://www.suse.com/common/img/product_icons/suseCloud_doormat_prodIcon.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Yes we did it! We created SUSE Cloud, based on OpenStack, to provide a software stack for IaaS providers and companies that want to create purpose out of their bare metal IT equipment, to build private clouds as easy as installing RPM files.&lt;br /&gt;&lt;br /&gt;The project was very ambitious; integration work, bug fixing, adding features, packaging, testing, and finally releasing a cloud software stack with a SUSE gecko on it within less than 7 month.&lt;br /&gt;&lt;br /&gt;I was asked to take care of the security. It was a challenge because I was not familiar with the inherit security issues of Cloud technology and I had to realize that OpenStack was very complex. Additionally security seems not to be a major concern when OpenStack was designed. Don't get me wrong, the upstream developers have a well working security team, quick patches, professional response and process handling. But for example OpenStack makes heavy use of RESTful APIs which are publically available, authentication (authC) is password-based, connections were not encrypted by default, passwords are send over the wire without encryption, and so on.&lt;br /&gt;&lt;br /&gt;Even if the start of the project was very challenging for everyone involved it was a great success at the end. Let me tell you in this blog how we managed to ship the most secure OpenStack-based Cloud solution. But at first kudos to all people that helped making it possible. I had a lot of help from the SUSE Cloud team, then two of my former team-mates from the SUSE Security-Team (Sebastian Krahmer, Matthias Weckbecker) built the powerful validation and verification team to test the software for vulnerabilities based on an initial risk assessment, and last but not least, the OpenStack (especially the secuirty guys) community which is incredible! &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The secure application development process&lt;/h2&gt;As you know from my ealier postings, we introduced something equal to Mircosofts &quot;Secure Developemt Life Cylce&quot; process and I called it SAD, Secure Application Development. (Not very clever but good to remember)&lt;br /&gt;In this case we do not develop the stack from scratch, we do integration and add features. So, I had neither influence on the secure coding standards used nor on the code quality. Therefore we were limited to define security requirements and drive the &quot;Verification and Validation&quot; (V&amp;amp;V) process.&lt;br /&gt;&lt;h2&gt;&lt;b&gt;How to find a Needle in a Haystack&lt;/b&gt;&lt;/h2&gt;&lt;div&gt;... at the end you will see that we found many &quot;needles&quot;.&lt;br /&gt;&lt;br /&gt;When you try to get familiar with Cloud Computing you will stumble through a field of marketing buzzwords, various commercial Cloud providers with very special/limited solutions, different security guidelines and so on and so on... maybe you will feel lost.&lt;br /&gt;Well that was the way I felt when I started. I wanted to find Cloud-specific attack vectors / risks which are unique to this new technology... but there isn't much new technology involved in Cloud Computing and there isn't much research of the new stuff.&amp;nbsp;So, where to start?&lt;/div&gt;&lt;div&gt;&lt;div&gt;I decided to start with the things I know best and which are exposed to attackers, not only to grab the low hanging fruits first but also to save some time because time was something we didn't have for this project. These easy wins could be:&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Web-security issues of the Dashboard&lt;/li&gt;&lt;li&gt;deployment issues, like file permissions, host and network hardening&lt;/li&gt;&lt;li&gt;API security&lt;/li&gt;&lt;/ol&gt;Therefore my risk assessment was focused on these attack vectors.&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;&lt;h2&gt;Security Requirements&lt;/h2&gt;The German Federal Office for Information Security (&lt;a href=&quot;https://www.bsi.bund.de/EN/Home/home_node.html&quot; target=&quot;_blank&quot;&gt;BSI&lt;/a&gt;) provides some simple and effective &lt;a href=&quot;https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/Minimum_information/SecurityRecommendationsCloudComputingProviders.pdf?__blob=publicationFile&quot; target=&quot;_blank&quot;&gt;security requirements&lt;/a&gt; for Cloud Service Providers which I prefered to use because we are a German company and the set of recommendations is manageable.&lt;br /&gt;&lt;h2&gt;Our Testing&lt;/h2&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;My testing suite based on the OWASP testing guide v3&lt;/li&gt;&lt;li&gt;Fuzzing&lt;/li&gt;&lt;li&gt;API fuzzing&lt;/li&gt;&lt;li&gt;Manual reviews&lt;/li&gt;&lt;li&gt;Code reviews&lt;/li&gt;&lt;li&gt;Regression testing&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;h2&gt;Vulnerabilities and Hardening&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;CVE-2012-2094: The log viewer of the Dashboard was vulnerable to an XSS attack.&lt;/li&gt;&lt;li&gt;CVE-2012-2144: One of the first bugs we found was a Session Fixation vulnerability in the Dashboard&lt;/li&gt;&lt;li&gt;CVE-2012-3360: (&lt;a href=&quot;https://bugs.launchpad.net/nova/+bug/1015531&quot; target=&quot;_blank&quot;&gt;lpd#1015531&lt;/a&gt;) The Nova API was vulnerable to Path Traversal which allowed remote users to overwrite arbitrary files with chosen content.&lt;/li&gt;&lt;li&gt;CVE-2012-3537 The crowbar ohai plugin insecurely handles temp. files which leads to local privilege escalation&lt;/li&gt;&lt;li&gt;CVE-2012-3540: Just a few days before the Gold Master we found an Open Redirect vulnerability using the &lt;span&gt;next=&lt;/span&gt;&lt;span&gt; paramater&lt;/span&gt;, that would allow a remote attacker to execute a Phishing attack.&lt;/li&gt;&lt;li&gt;CVE-2012-3551: A simple XSS attack was possible using the &lt;span&gt;file=&lt;/span&gt;&lt;span&gt; parameter&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://bugs.launchpad.net/keystone/+bug/963098&quot; target=&quot;_blank&quot;&gt;lpd#963098&lt;/a&gt;&amp;nbsp;and &lt;a href=&quot;https://bugs.launchpad.net/horizon/+bug/948317&quot; target=&quot;_blank&quot;&gt;lpd#948317&lt;/a&gt;: Guessing passwords was very easy, there is no way to specify a mandatory password policy for newly created users in the Dashboard, authentication violations weren't logged by Keystone, and there is no limit &amp;nbsp;per client for guessing passwords. We tried to introduce cracklib to enforce a password policy, but it was just &lt;b&gt;&quot;a&quot;&lt;/b&gt; policy not the one the CSP would like to use, therefore a configureable regex was introduced in local_settings.py, BTW, don't foret to enable it. Additionally our Keystone server logs authentication violation in &lt;span&gt;/var/log/keystone&lt;/span&gt; now. A rate limit to stop online password guessing will be introduced later.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://bugs.launchpad.net/swift/+bug/1006414&quot; target=&quot;_blank&quot;&gt;lpd#1006414&lt;/a&gt;&amp;nbsp;: Remote command execution via &lt;span&gt;pickle&lt;/span&gt;. No CVE-ID assigned, severity unclear.&lt;/li&gt;&lt;li&gt;With SUSE Cloud it is possible to enable SSL for the API, the Dashboard (Session Cookies use &quot;secure&quot; and &quot;httpOnly&quot; flag in SSL mode), the VNC server, etc. All this interfaces to the Cloud are used via the Internet and are therefore easy to attack.&lt;/li&gt;&lt;li&gt;OpenStack, crowbar, ceph come with a lot of configuration files, a lot of them contain passwords, keys and other sensitive information. These files are not world-readable anymore in SUSE Cloud.&lt;/li&gt;&lt;li&gt;Default passwords/secrets/keys (for example to secure session cookies) are a big problem in current web-frameworks like Rails or Django, especially when you use cloned images in a VM. (Django's SECRET_KEY was fixed, take care yourself about static secrets)&lt;/li&gt;&lt;li&gt;Fuzzing the RESTful APIs of Nova/Compute and Keystone was done using the &lt;a href=&quot;https://gitorious.org/test-suite/test-suite&quot; target=&quot;_blank&quot;&gt;fuzz_xmlrpc.pl script&lt;/a&gt;&amp;nbsp;and did not reveal any additional suspicious actions (beside watching logs and error messages, behavior was monitored with an inotify and exec monitor). This testing was sufficient for the first round.&lt;/li&gt;&lt;li&gt;... and various other tiny issues...&amp;nbsp;&lt;/li&gt;&lt;li&gt;... about 40% of the current Essex security issues were found by us.&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Lessons learned&lt;/h2&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Agile development is something I really like, it doesn't try to tame the chaos, it is just open, pragmatic, and adaptive. The problem is that the code changes very often and even lately. This can cause failures to re-occurre therefore automatic regression testing is very important. (CI server)&lt;/li&gt;&lt;li&gt;To make automatic regression testing effective it is very important for security engineers to create testcases (proof-of-concept exploits) which is time consuming but a clear proof of the problem which helps developers to understand the problem, and to reproduce it automatically.&lt;/li&gt;&lt;li&gt;Even if&amp;nbsp;creative minds, which security engineers are IMO, didn't like it, but risk assessment based on design analysis is the key element to be successful.&lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;What will come next?&lt;/h2&gt;Automatic security tests are my major concern for the next product release, this would minimize regressions and gives the security engineers the time to concentrate on more sophisticated attacks as well on focusing on design improvements. I will try to leave my microcosm and get more involved in the upstream development as well as defining meaningful security guidelines for CSPs and for Cloud Computing software stack developers.&lt;br /&gt;This project brings a lot of joy and the next major release will become even more secure ... so remember to have fun! :-)&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Mon, 03 Sep 2012 03:59:56 +0000</pubDate>
	<dc:creator>Thomas (noreply@blogger.com)</dc:creator>
</item>
<item>
	<title>James Morris: Linux Security Summit 2012 – Schedule update</title>
	<guid>http://blog.namei.org/?p=550</guid>
	<link>http://blog.namei.org/2012/08/29/linux-security-summit-2012-schedule-update/</link>
	<description>&lt;p&gt;Just to let folks know who are attending, we&amp;#8217;ve added a lightning talks slot to the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2012/Schedule&quot;&gt;LSS 2012 schedule&lt;/a&gt;, on Friday 31st August at 2pm.&lt;/p&gt;
&lt;p&gt;If you have any emerging topics to discuss, come along on the day and contact me to schedule a slot.  We have one confirmed talk already: Dave Jones will be discussing his Trinity system call fuzzing work.&lt;/p&gt;
&lt;p&gt;Note that this change pushes the &lt;a href=&quot;http://kernsec.org/wiki/index.php/Linux_Security_Summit_2012/Abstracts/Bryant&quot;&gt;LF Linux Security Workgroup BoF&lt;/a&gt; back thirty minutes.&lt;/p&gt;</description>
	<pubDate>Wed, 29 Aug 2012 04:41:52 +0000</pubDate>
	<dc:creator>jamesm</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: mod_selinuxのアーキテクチャを考える(後編)</title>
	<guid>hatenablog://entry/12704830469096319078</guid>
	<link>http://kaigai.hatenablog.com/entry/20120818/1345236810</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://d.hatena.ne.jp/kaigai/20120811/1344667946&quot;&gt;&amp;#x524D;&amp;#x56DE;&amp;#x306E;&amp;#x8A18;&amp;#x4E8B;&lt;/a&gt;では、現在の mod_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/selinux&quot;&gt;selinux&lt;/a&gt; モジュールの問題点を解決するために複数のタスクキューにワーカースレッドを紐付ける方法を考え、そこから一歩考察を進めて、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;を使ってマルチプロセス実装にすればよりセキュアなWebアプリケーション環境を実現できるのではないか？というアイデアを紹介した。&lt;/p&gt;

&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;実際にやってみた。&lt;/h4&gt;
    &lt;p&gt;もちろん&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;の権限に紐付けてリクエストの送出先を切り替える&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;モジュールは存在しないので、既存のものに少し手を加える事にする。今回は（たぶん最も広く使われているであろう）&lt;a href=&quot;http://httpd.apache.org/mod_fcgid/&quot;&gt;mod_fcgid&lt;/a&gt;をベースに修正を加える事にする。&lt;/p&gt;&lt;p&gt;mod_fcgidモジュールでは&lt;a href=&quot;http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidwrapper&quot;&gt;FcgidWrapper&lt;/a&gt;ディレクティブを使って、例えば .&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/php&quot;&gt;php&lt;/a&gt; 拡張子を持つURLが指定された場合、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;プロトコルを介して/usr/bin/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/php&quot;&gt;php&lt;/a&gt;-cgiにリクエストを処理させるという指定ができる。&lt;br /&gt;
例えばこんな感じ。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;AddHandler      fcgid-script     .php
FcgidWrapper    /usr/bin/php-cgi .php&lt;/pre&gt;&lt;p&gt;で、mod_fcgidのソースを読んでみて気が付いたのだが、この人は&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;常駐プログラムが既に起動しているかどうかをチェックするために、内部テーブルをスキャンして、動作中のプロセスを起動したときの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%B3%A5%DE%A5%F3%A5%C9%A5%E9%A5%A4%A5%F3&quot;&gt;コマンドライン&lt;/a&gt;文字列（要はFcgidWrapperで指定した内容）と、これから起動する&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;常駐プログラムの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%B3%A5%DE%A5%F3%A5%C9%A5%E9%A5%A4%A5%F3&quot;&gt;コマンドライン&lt;/a&gt;文字列を比較するという処理を行っている。&lt;br /&gt;
そうすると、仮にラッパープログラムの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%B3%A5%DE%A5%F3%A5%C9%A5%E9%A5%A4%A5%F3&quot;&gt;コマンドライン&lt;/a&gt;文字列の一部を、HTTPリクエストを処理するセキュリティコンテキスト（あるいはユーザIDでも可）で置換するような仕組みを作ってあげれば、FcgidWrapperを次のように指定するだけで、後はmod_fcgidが善きに計らってくれる。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;FcgidWrapper  &quot;runcon %(SELINUX_CONTEXT) /usr/bin/php-cgi&quot; .php&lt;/pre&gt;&lt;p&gt;例えば、HTTPユーザ alice の場合に %(&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELINUX&quot;&gt;SELINUX&lt;/a&gt;_CONTEXT)が &quot;system_u:system_r:&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;_t:s0:c0&quot; に置換されたら、この設定内容は次のコマンドと等価である。おそらく、認証モジュールで設定するようなHTTP&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%B4%C4%B6%AD%CA%D1%BF%F4&quot;&gt;環境変数&lt;/a&gt;か何かを使うのが汎用的な実装だろう。兎に角、%(&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELINUX&quot;&gt;SELINUX&lt;/a&gt;_CONTEXT)の部分を動的に置換するというのがポイントである。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;FcgidWrapper  &quot;runcon system_u:system_r:httpd_t:s0:c0 /usr/bin/php-cgi&quot; .php&lt;/pre&gt;&lt;p&gt;もう一点。&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PHP&quot;&gt;PHP&lt;/a&gt;のような動的コンテンツであれば既存の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;の設定と同様にできるが、静的コンテンツの場合、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/apache&quot;&gt;apache&lt;/a&gt;/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;はhandlerフックの一番最後で他のモジュールが処理できないタイプのHTTPリクエストを処理する…という流れになる。&lt;br /&gt;
つまり、ap_hook_handler() に APR_HOOK_LAST を付けて関数ポインタを登録し、静的コンテンツを読むだけの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;常駐プログラムを実行するような拡張が必要になる。&lt;/p&gt;&lt;p&gt;この２点の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%CB%E2%B2%FE%C2%A4&quot;&gt;魔改造&lt;/a&gt;を加えた mod_fcgid がこちら。&lt;br /&gt;
  &lt;a href=&quot;https://github.com/kaigai/mod_fcgid&quot;&gt;https://github.com/kaigai/mod_fcgid&lt;/a&gt;&lt;/p&gt;

&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;KaiGai版 mod_fcgid のインストールと設定&lt;/h4&gt;
    &lt;p&gt;mod_fcgid(&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%CB%E2%B2%FE%C2%A4&quot;&gt;魔改造&lt;/a&gt;版)のインストールは以下の通り。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ git clone git://github.com/kaigai/mod_fcgid.git
$ cd mod_fcgid
$ git checkout --track origin/defhnd
$ ./configure.apxs &amp;amp;&amp;amp; make
$ sudo make install&lt;/pre&gt;&lt;p&gt;&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Apache&quot;&gt;Apache&lt;/a&gt;/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;の設定ファイルを編集。ここでは、.&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/php&quot;&gt;php&lt;/a&gt; ファイルに対してrunconを介して/usr/bin/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/php&quot;&gt;php&lt;/a&gt;-cgiを実行するのと同時に、静的コンテンツに対しては&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/fcgi&quot;&gt;fcgi&lt;/a&gt;-cat(後述)コマンドを実行する。&lt;br /&gt;
runconの引数に%(AUTHENTICATE_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELINUX&quot;&gt;SELINUX&lt;/a&gt;_TYPE)と%(AUTHENTICATE_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELINUX&quot;&gt;SELINUX&lt;/a&gt;_RANGE)が付いているが、これは実行時にHTTP&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%B4%C4%B6%AD%CA%D1%BF%F4&quot;&gt;環境変数&lt;/a&gt;と置換される。で、この&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%B4%C4%B6%AD%CA%D1%BF%F4&quot;&gt;環境変数&lt;/a&gt;を設定するのがauthn_dbd_moduleで、AuthDBDUserPWQueryが2個以上のカラムを返すとき、それらの内容はHTTP&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%B4%C4%B6%AD%CA%D1%BF%F4&quot;&gt;環境変数&lt;/a&gt;として後続のモジュールで参照する事ができる。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;LoadModule fcgid_module      modules/mod_fcgid.so
LoadModule dbd_module        modules/mod_dbd.so
LoadModule authn_dbd_module  modules/mod_authn_dbd.so

DBDriver    pgsql
DBDParams   &quot;host=localhost dbname=web user=apache&quot;

AddHandler      fcgid-script  .php
FcgidWrapper    &quot;/bin/runcon -t %(AUTHENTICATE_SELINUX_TYPE)  \
                             -l %(AUTHENTICATE_SELINUX_RANGE) \
                     /usr/bin/php-cgi&quot; .php
FcgidDocumentWrapper  &quot;/bin/runcon -t %(AUTHENTICATE_SELINUX_TYPE)  \
                                   -l %(AUTHENTICATE_SELINUX_RANGE) \
                           /usr/local/bin/fcgi-cat&quot;

&amp;lt;Directory &quot;/var/www/html&quot;&amp;gt;
# BASIC authentication
AuthType    Basic
AuthName    &quot;Secret Zone&quot;
AuthBasicProvider    dbd
AuthDBDUserPWQuery    &quot;SELECT upasswd, selinux_type, selinux_range \
                       FROM uaccount WHERE uname = %s&quot;
Require     valid-user
&amp;lt;/Directory&amp;gt;&lt;/pre&gt;&lt;p&gt;次に、認証DBのセットアップ。uaccountテーブルに&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/BASIC%C7%A7%BE%DA&quot;&gt;BASIC認証&lt;/a&gt;の情報をインプットしておく。$PGDATAは&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PostgreSQL&quot;&gt;PostgreSQL&lt;/a&gt;のDB&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%AF%A5%E9%A5%B9%A5%BF&quot;&gt;クラスタ&lt;/a&gt;のトップディレクトリ。まぁ、COPYコマンドで読めればドコでもいいんですが。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ htpasswd -c $PGDATA/uaccount.master alice
New password:
Re-type new password:
Adding password for user alice
$ htpasswd $PGDATA/uaccount.master bob
New password:
Re-type new password:
Adding password for user bob
$ createdb web&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;$ pgsql web
web=# CREATE USER apache;
CREATE ROLE
web=# CREATE TABLE uaccount (
     uname   text primary key,
     upasswd text,
     selinux_type text,
     selinux_range text
 );
CREATE TABLE
web=# GRANT SELECT on uaccount TO public;
GRANT
web=# COPY uaccount(uname,upasswd) FROM '/opt/pgsql/uaccount.master';
web=# COPY uaccount(uname,upasswd) FROM '/opt/pgsql/uaccount.master' DELIMITER ':';
COPY 2
web=# UPDATE uaccount SET selinux_type = 'httpd_t';
UPDATE 2
web=# UPDATE uaccount SET selinux_range = 's0:c0' WHERE uname = 'alice';
UPDATE 1
web=# UPDATE uaccount SET selinux_range = 's0:c1' WHERE uname = 'bob';
UPDATE 1
web=# SELECT * FROM uaccount;
 uname |                upasswd                | selinux_type | selinux_range
-------+---------------------------------------+--------------+---------------
 alice | $apr1$HQtZm8Sz$ZwXm9tx6Kz7g2wiE1LBUZ/ | httpd_t      | s0:c0
 bob   | $apr1$YJWn7hx3$iJyazYClFeFF0n8EgIMSi. | httpd_t      | s0:c1
(2 rows)&lt;/pre&gt;&lt;p&gt;次に、静的ドキュメントを参照するFactCGI常駐プログラムの&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/fcgi&quot;&gt;fcgi&lt;/a&gt;-catをビルドして /usr/local/bin にインストールする。こやつのビルドには &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/fcgi&quot;&gt;fcgi&lt;/a&gt;-devel パッケージも必要です。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ git clone git://github.com/kaigai/toybox.git
$ cd toybox
$ gcc -g fcgi-cat.c -lfcgi -o fcgi-cat
$ sudo install -m 755 fcgi-cat /usr/local/bin&lt;/pre&gt;&lt;p&gt;最後に、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%BB%A5%AD%A5%E5%A5%EA%A5%C6%A5%A3%A5%DD%A5%EA%A5%B7%A1%BC&quot;&gt;セキュリティポリシー&lt;/a&gt;を追加し、Booleanを調整して設定は終わり。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ make -f /usr/share/selinux/devel/Makefile webapps.pp
$ sudo semodule -i webapps.pp
$ sudo setsebool httpd_can_network_connect_db on&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;動かしてみた&lt;/h4&gt;
    &lt;p&gt;お試しとして、以下の内容の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PHP&quot;&gt;PHP&lt;/a&gt;スクリプトを実行させてみる。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;?php
echo &quot;&amp;lt;h3&amp;gt;&quot;.selinux_getcon().&quot;&amp;lt;h3&amp;gt;\n&quot;;
echo &quot;&amp;lt;h3&amp;gt;username = &quot;.$_SERVER[&quot;REMOTE_USER&quot;].&quot;&amp;lt;/h3&amp;gt;\n&quot;;

phpinfo();
?&amp;gt;&lt;/pre&gt;&lt;p&gt;ユーザ alice としてアクセスした場合。確かにDBで指定した通り、セキュリティコンテキストの末尾が &quot;:s0:c0&quot; となっている。&lt;br /&gt;
&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20120818053227&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120818/20120818053227.png&quot; alt=&quot;f:id:kaigai:20120818053227p:image&quot; title=&quot;f:id:kaigai:20120818053227p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;一方、ユーザ bob としてアクセスした場合。今度はセキュリティコンテキストの末尾が &quot;:s0:c1&quot; となっている。Server &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/API&quot;&gt;API&lt;/a&gt;の欄が &quot;CGI/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;&quot; となっている点にも注目。&lt;br /&gt;
&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20120818053226&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120818/20120818053226.png&quot; alt=&quot;f:id:kaigai:20120818053226p:image&quot; title=&quot;f:id:kaigai:20120818053226p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;では、静的ドキュメントを参照した場合。２つの画像ファイル test00.jpg と test01.jpg のセキュリティコンテキストはそれぞれ以下のように設定されているため、alice は test00.jpg を参照できるが、test01.jpg は見えないはず。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ ls -Z /var/www/html
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 mytest.php
-rwxr--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0:c0 test00.jpg
-rwxr--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0:c1 test01.jpg&lt;/pre&gt;&lt;p&gt;これが test00.jpg を参照したケース。正しく読み込めている。&lt;br /&gt;
&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20120818053858&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120818/20120818053858.png&quot; alt=&quot;f:id:kaigai:20120818053858p:image&quot; title=&quot;f:id:kaigai:20120818053858p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;今度は test01.jpg を参照した場合。サーバは 403 Forbidden を返している。ヒャッハー！&lt;br /&gt;
&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20120818053857&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120818/20120818053857.png&quot; alt=&quot;f:id:kaigai:20120818053857p:image&quot; title=&quot;f:id:kaigai:20120818053857p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;画像は省略するが、これをユーザbobで試した場合は逆の結果となる。&lt;/p&gt;&lt;p&gt;もちろん、これらは&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;で動作しているので、psコマンドを叩くと常駐プロセスの様子が見える。&lt;br /&gt;
確かにユーザ alice と bob それぞれのHTTPリクエストを処理するために、別個のプロセスが起動している。&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;[root@iwashi ~]# ps -AZ | grep php-cgi
system_u:system_r:httpd_t:s0:c0 23960 ?        00:00:00 php-cgi
system_u:system_r:httpd_t:s0:c1 24062 ?        00:00:00 php-cgi
[root@iwashi ~]# ps -AZ | grep fcgi-cat
system_u:system_r:httpd_t:s0:c0 24098 ?        00:00:00 fcgi-cat
system_u:system_r:httpd_t:s0:c1 24107 ?        00:00:00 fcgi-cat&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot;&gt;
    &lt;h4&gt;まとめ&lt;/h4&gt;
    &lt;p&gt;今までの mod_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/selinux&quot;&gt;selinux&lt;/a&gt; と違い、この方法では全てのDSOモジュールに作用させるという事はできない。&lt;br /&gt;
&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PHP&quot;&gt;PHP&lt;/a&gt;なら&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PHP&quot;&gt;PHP&lt;/a&gt;用の、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Ruby&quot;&gt;Ruby&lt;/a&gt;なら&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Ruby&quot;&gt;Ruby&lt;/a&gt;用の設定がそれぞれ必要となる。これは確かにデメリット。&lt;/p&gt;&lt;p&gt;その一方で、HTTPユーザ毎にアプリを実行するメモリ空間を分けられるという事は、セキュリティの観点からは非常に大きなアドバンテージである。Web管理者がその気になれば、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Apache&quot;&gt;Apache&lt;/a&gt;/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;では一切Webアプリの実行を行わず、ある種の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%A2%A5%D7%A5%EA%A5%B1%A1%BC%A5%B7%A5%E7%A5%F3%A5%B5%A1%BC%A5%D0&quot;&gt;アプリケーションサーバ&lt;/a&gt;として振る舞う&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;常駐プログラムが、HTTPユーザ毎に閉じたコンテナ環境を提供するという事も可能だろう。&lt;br /&gt;
セキュリティの強化を目的とするモジュールなので、ここのアドバンテージはでかい、と思う。&lt;/p&gt;

&lt;/div&gt;</description>
	<pubDate>Fri, 17 Aug 2012 20:53:30 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>KaiGai Kohei: mod_selinuxのアーキテクチャを考える(前編)</title>
	<guid>hatenablog://entry/12704830469096319080</guid>
	<link>http://kaigai.hatenablog.com/entry/20120811/1344667946</link>
	<description>&lt;p&gt;mod_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/selinux&quot;&gt;selinux&lt;/a&gt;は&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/apache&quot;&gt;apache&lt;/a&gt;/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;のプラグインで、利用者のHTTP要求の認証(BASICとかDIGESTとか)結果に基づいて、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PHP&quot;&gt;PHP&lt;/a&gt;スクリプトや静的コンテンツを参照するContents Handlerの実行権限を切り替える。&lt;br /&gt;
やっている事は単純で、ap_hook_handlerの先頭で mod_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/selinux&quot;&gt;selinux&lt;/a&gt; が処理を乗っ取り、一時的にワーカースレッドを作成して権限を縮退させる。で、以降のContents Handlerの実行はワーカースレッドに託されるという形になる。&lt;/p&gt;&lt;p&gt;だが、このデザインだと問題になる事が２点。&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ap_invoke_handler()が再入可能ではない&lt;/li&gt;
&lt;li&gt;Bounds domainの範囲でしかドメイン遷移ができない&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;前者の問題について。CGIが自サーバ内のURLを含むLocation: ヘッダを返した場合など、internal redirectionという処理が走り、cgi_handlerのコンテキストでap_invoke_handler()が再び呼ばれる事がある。&lt;br /&gt;
この場合、再びHTTP認証が実行され、その結果、cgi_hanclerのコンテキストとは異なるsecurity contextが指定される事があり得る。が、既にsecurity contextを変更する権限を放棄しているハズなので、詰む。この場合はエラーを返してごめんなさいするしかない。&lt;br /&gt;
この問題は、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;に限った話ではなく、CAP_SETUIDを放棄するシナリオでも同じ。&lt;/p&gt;&lt;p&gt;後者の問題について。これは&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;固有の話で、マルチスレッドのアプリがドメイン遷移を行う場合、遷移先のドメインは bounds domain 制約を満足する必要がある。&lt;br /&gt;
（いや、これは元々私の提案だが・・・。）&lt;br /&gt;
ドメイン &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;_t が user_webapp_t の bounds domain であるという状態は、user_webapp_t の持っている権限は全て &lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;_t も持っているという事。つまり、ドメイン遷移元の&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;_tは、システム管理系のツール等もWeb経由で実行させると考えると、相当に広範な権限を付与する必要がある・・・事になる。&lt;br /&gt;
実際に&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%BB%A5%AD%A5%E5%A5%EA%A5%C6%A5%A3%A5%DD%A5%EA%A5%B7%A1%BC&quot;&gt;セキュリティポリシー&lt;/a&gt;を書くとなると、これが地味に効いてくる。&lt;br /&gt;
端的に言って、書きにくい・・・。（´ω｀;;）&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20120811141418&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120811/20120811141418.png&quot; alt=&quot;f:id:kaigai:20120811141418p:image&quot; title=&quot;f:id:kaigai:20120811141418p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
まず前者の問題を解決するため、mod_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/selinux&quot;&gt;selinux&lt;/a&gt;の構造を上の模式図のように変更してみた。このデザインではsecurity context毎にタスクキューを持ち、ap_handler_hookの先頭でHTTP認証に応じてキューにタスクを振り分けるという形になる。&lt;br /&gt;
キューは on demand で生成され、適合する security context が存在しない場合にはTask Launcher Threadにキュー生成要求を行ってこれを作成してもらう。&lt;br /&gt;
このデザインだと、ap_invoke_handler()の延長でinternal redirectionが走った場合でも、再帰して呼び出されたap_handler_hookの先頭で行う処理は『適切なキューに処理要求を投げる』だけなので問題は生じない。&lt;/p&gt;&lt;p&gt;・・・と、ここまで実装してハタと気が付いた。&lt;/p&gt;&lt;p&gt;これって本質的には (1)プロトコル処理サーバ と (2)&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%A2%A5%D7%A5%EA%A5%B1%A1%BC%A5%B7%A5%E7%A5%F3%A5%B5%A1%BC%A5%D0&quot;&gt;アプリケーションサーバ&lt;/a&gt; の分離と同じことだよねと。&lt;br /&gt;
だとすると、上のデザインでは各キューに紐付いていたワーカースレッドをワー&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%AB%A1%BC%A5%D7&quot;&gt;カープ&lt;/a&gt;ロセスとして分離すると、最初に挙げた２つの問題のうち後者の Bounds domain の制限を取り払う事ができるようになる。&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://f.hatena.ne.jp/kaigai/20120811141416&quot; class=&quot;hatena-fotolife&quot;&gt;&lt;img src=&quot;http://cdn-ak.f.st-hatena.com/images/fotolife/k/kaigai/20120811/20120811141416.png&quot; alt=&quot;f:id:kaigai:20120811141416p:image&quot; title=&quot;f:id:kaigai:20120811141416p:image&quot; class=&quot;hatena-fotolife&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;つまり、利用者のcredentials（uid/gid/security context）毎にワー&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%AB%A1%BC%A5%D7&quot;&gt;カープ&lt;/a&gt;ロセスをon demandで起動し、HTTPリクエストの解析は&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/apache&quot;&gt;apache&lt;/a&gt;/&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/httpd&quot;&gt;httpd&lt;/a&gt;自身で行う一方で、静的コンテンツの参照も含めたHTTPリクエストの処理をワー&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/%A5%AB%A1%BC%A5%D7&quot;&gt;カープ&lt;/a&gt;ロセスで実行するようにすれば、問題は全て解決するのではなかろうか。&lt;/p&gt;&lt;p&gt;幸いな事に、この手のプロトコルとして&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/FastCGI&quot;&gt;FastCGI&lt;/a&gt;が既に定義されており、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/PHP&quot;&gt;PHP&lt;/a&gt;や&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Ruby&quot;&gt;Ruby&lt;/a&gt;、&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/Java&quot;&gt;Java&lt;/a&gt;などメジャーどころの言語はこれに対応している。&lt;/p&gt;&lt;p&gt;．．．とすると、mod_&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/selinux&quot;&gt;selinux&lt;/a&gt;を拡張するよりも、mod_fcgidに対する追加機能として&lt;a class=&quot;keyword&quot; href=&quot;http://d.hatena.ne.jp/keyword/SELinux&quot;&gt;SELinux&lt;/a&gt;（やその他のセキュリティ機構を包含する）仕組みを提案した方が、メンテナンスが楽になるのかな、と考え中。&lt;/p&gt;</description>
	<pubDate>Sat, 11 Aug 2012 06:52:26 +0000</pubDate>
	<dc:creator>kaigai</dc:creator>
</item>
<item>
	<title>Dan Walsh: Article I wrote on Harvard PAAS.</title>
	<guid>http://danwalsh.livejournal.com/56976.html</guid>
	<link>http://danwalsh.livejournal.com/56976.html</link>
	<description>Occasionally I write longer articles that I feel are too long for a blog...&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://www.linux.com/news/enterprise/systems-management/613339:harvard-goes-paas-with-selinux-sandbox?utm_source=twitterfeed&amp;amp;utm_medium=twitter&quot; rel=&quot;nofollow&quot;&gt;Harvard CS Uses PAAS and Fedora.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Kind of nice to get the message out to other people also.&amp;nbsp; Thanks to OpenSource.com for publishing it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Sat, 04 Aug 2012 11:52:22 +0000</pubDate>
	<dc:creator>dwalsh@redhat.com</dc:creator>
</item>

</channel>
</rss>
