<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Brindle on Security &#187; Security</title>
	<atom:link href="http://securityblog.org/brindle/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://securityblog.org/brindle</link>
	<description>The ramblings of security neophyte Joshua Brindle</description>
	<pubDate>Fri, 10 Oct 2008 01:38:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>Stackoverflow.com and the SELinux poll</title>
		<link>http://securityblog.org/brindle/2008/10/08/stackoverflowcom-and-the-selinux-poll/</link>
		<comments>http://securityblog.org/brindle/2008/10/08/stackoverflowcom-and-the-selinux-poll/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 23:28:55 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[poll]]></category>

		<category><![CDATA[selinux]]></category>

		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/?p=41</guid>
		<description><![CDATA[So, stackoverflow.com was released to public beta pretty recently and I must say I&#8217;m impressed. It looks like a great place to go to get tough programming (and other) questions answered. 
So, in order to give it a spin I posted the question Do you disable SELinux? 
It didn&#8217;t get nearly as many answers as What’s your favorite “programmer” [...]]]></description>
			<content:encoded><![CDATA[<p>So, stackoverflow.com was released to public beta pretty recently and I must say I&#8217;m impressed. It looks like a great place to go to get tough programming (and other) questions answered. <br />
So, in order to give it a spin I posted the question <a title="Do you disable SELinux?" href="http://stackoverflow.com/questions/97816/do-you-disable-selinux" target="_blank">Do you disable SELinux?</a> </p>
<p>It didn&#8217;t get nearly as many answers as <a href="http://stackoverflow.com/questions/84556/whats-your-favorite-programmer-cartoon" target="_blank">What’s your favorite “programmer” cartoon</a> but I did get mostly good feedback, it seems like the audience on stackoverflow, in general, have seen the positive progress of SELinux and many have chosen to keep it enabled (or even write policies and make it work for them).</p>
<p>Good to hear!</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/10/08/stackoverflowcom-and-the-selinux-poll/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SELinux on Ubuntu (part 1)</title>
		<link>http://securityblog.org/brindle/2008/09/14/selinux-on-ubuntu-part-1/</link>
		<comments>http://securityblog.org/brindle/2008/09/14/selinux-on-ubuntu-part-1/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 01:32:42 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[selinux]]></category>

		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/?p=28</guid>
		<description><![CDATA[I&#8217;m in the process of moving my server from an ancient decrepit Gentoo install to a shiny new Ubuntu Hardy install with SELinux enabled.

The policy installed with Ubuntu is fairly limited. It is a very small base policy with a cups module available. This was the result of Ubuntu politics but obviously I wanted something [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of moving my server from an ancient decrepit Gentoo install to a shiny new Ubuntu Hardy install with SELinux enabled.</p>
<p><span id="more-28"></span></p>
<p>The policy installed with Ubuntu is fairly limited. It is a very small base policy with a cups module available. This was the result of Ubuntu politics but obviously I wanted something more comprehensive. The first thing I did was grab the reference policy from oss.tresys.com and try to figure out what policies I wanted installed. Reference policy has 259 modules and I didn&#8217;t want all of them. </p>
<p>I took the Gentoo policy ebuild to start, since it is a much smaller policy than Fedora has and I added modules for the services I was going to run. The result (for now) is this:</p>
<pre>application = base
authlogin = base
bootloader = base
clock = base
consoletype = base
corecommands = base
corenetwork = base
cron = base
devices = base
dmesg = base
domain = base
files = base
filesystem = base
fstools = base
getty = base
hostname = base
hotplug = base
init = base
iptables = base
kernel = base
libraries = base
locallogin = base
logging = base
miscfiles = base
mls = base
mcs = base
modutils = base
mount = base
mta = base
netutils = base
nscd = base
raid = base
selinux = base
selinuxutil = base
ssh = base
staff = base
storage = base
su = base
sysadm = base
sysnetwork = base
terminal = base
udev = base
unconfined = base
userdomain = base
usermanage = base
unprivuser = base
 
dovecot = module
postfix = module
bind = module
mysql = module
apache = module
dpkg = module
spamassassin = module
ntp = module</pre>
<p> </p>
<p>This is a relatively small policy, yeilding a 500k policy.23. </p>
<p>Then I ran in to my first problem. The SELinux libraries installed on Hardy won&#8217;t build the most recent reference policy due to a bug that was fixed after Ubuntu&#8217;s libraries were built. So I had to upgrade my libraries and policy compiler. Since I normally develop on Fedora I assumed I could grab some sort of source deb, update the code and rebuild it. I couldn&#8217;t figure out how to do that though, all of the source pointers go to the developers repository which looked just like the upstream source. I have no idea how to build debs so I gave up and just built from the selinux userspace git tree. </p>
<p>After getting a toolchain I could build the policy on and building and installing the policy I relabeled the filesystem and tried rebooting. Thats when the second problem happened. I couldn&#8217;t log in via ssh (doh!) and the server is located alot of miles away (like 1000 or something). Good thing the machine has a remote administration console. So I logged in via that and took a look at ps -AZ to see what was going on (I was certain that ssh was running in the wrong context and that is why I couldn&#8217;t log in, even in permissive). Everything was running in sysadm_t !?! This was pretty baffling to me, I did some sesearch&#8217;s on the policy (btw, the setools package pulls in the whole thing which requires gtk, tcl, tk, whatever.. too bad there isn&#8217;t a setools-console package). Well it turns out that if the upstart_init boolean isn&#8217;t set to true then initrc_t transitions to sysadm_t on shell_exec_t, I have no clue why, very strange. Set the boolean and everything looks good (yay).</p>
<p>Now everything is up and running in the right context (well, mostly everything, mysqld_safe, logger and dd (run for klogd apparently) are running in initrc_t, which is effectively unconfined) I&#8217;ll work on those later.</p>
<p>Right now I&#8217;m getting tons of denials, most are related to having a tmpfs /var/run I think, also udev is doing all sorts of crazy things (but then again doesn&#8217;t it always). Hopefully I&#8217;ll get these taken care of and I&#8217;ll write another article about the success (assuming I succeed and don&#8217;t give up <img src='http://securityblog.org/brindle/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> )</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/09/14/selinux-on-ubuntu-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web browsers, security and Google Chrome</title>
		<link>http://securityblog.org/brindle/2008/09/02/web-browsers-security-and-google-chrome/</link>
		<comments>http://securityblog.org/brindle/2008/09/02/web-browsers-security-and-google-chrome/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 00:15:09 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[google chrome]]></category>

		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/?p=25</guid>
		<description><![CDATA[Securing web browsers has always been a little tricky. With so many web applications available today, including corporate intranet sites, email and so on with confidential or proprietary information it is always a bit troublesome that web browsers essentially run in one security domain. The last thing I want is for a teller at my [...]]]></description>
			<content:encoded><![CDATA[<p>Securing web browsers has always been a little tricky. With so many web applications available today, including corporate intranet sites, email and so on with confidential or proprietary information it is always a bit troublesome that web browsers essentially run in one security domain. The last thing I want is for a teller at my bank to go to some site that ends up getting bank info from another tab.  <span id="more-25"></span></p>
<div class="entry">
<div>
<p>There have been several improvements in the web browsing space though. Microsoft Internet Explorer has protected mode but that doesn&#8217;t use system based access control to enforce separation of internal web pages from external ones, for example. On Linux we&#8217;ve started using nsplugin to load plugins (flash, whatever) into a separate process. This is particularly nice on SELinux systems since we can transition those plugins into a domain that can&#8217;t do much, such as read files in home directories, access the network, etc. Dan Walsh has a nice writeup about this at <a title="http://danwalsh.livejournal.com/15700.html" href="http://danwalsh.livejournal.com/15700.html" target="_blank">his blog</a></p>
<p>That still doesn&#8217;t separate sites of differing security domains (my bank, joke site my friend sent in an email, the company sharepoint server, etc) into separate processes that cannot interact with each other.</p>
<p>I had a customer once that actually augmented Firefox to be a multi-level browser. This was a Trusted Solaris solution and really didn&#8217;t address the problem. All of the sites were still inside the same browser process and they had only augmented it to try and keep that data separate. Something that used process and domain separation would be better. If we trusted the web browser to not leak data none of this would be necessary!</p>
<p>The best we can hope for is manually separating browsers. I&#8217;ve blogged in the past about using network access controls in SELinux to ensure an &#8220;internal&#8221; browser can&#8217;t browse the the internet, and an &#8220;internet&#8221; browser can&#8217;t browse into the intranet. This requires user intervention to understand and keep track of multiple browsers, hardly an elegant solution. Surely there is a better way.</p>
<p>Now comes Google Chrome, a shiny (haha) new browser that has some great ideas. Google also published an interesting <a title="http://blogoscoped.com/google-chrome/" href="http://blogoscoped.com/google-chrome/" target="_blank">set of comics </a>that describe some of the ideas and features.</p>
<p>The ones I found most interesting: Each tab is rendered in a separate process, plugins run in a separate process and a javascript virtual machine. This means tabs shouldn&#8217;t be able to get data from other tabs (now I don&#8217;t have to worry about crazy scary Myspace pages reading my bank account number).</p>
<p>There are a couple things to worry about, first they claim plugins are poorly written and therefore must have access to all tabs (which is particularly scary given the Flash vulnerabilities as of late). The ideal solution is to have a plugin process per-rendering process, this would keep plugins from interacting with each other and other rendering processes. They claim this is a long term goal, that they would work with plugin writers to make this easier, we can only hope.</p>
<p>Second, and much more worrisome is on slide 29, the claim that they know their sandboxing works because they wrote it, wrong! If we trusted the applications to begin with we&#8217;d have no need for additional access control.</p>
<p>Now all this brings me to my main point. Granted Chrome is only available for Windows at the moment but hopefully it&#8217;ll be available on Linux before long. And then we might have something interesting to work on. Different security domains for different sites? That would be great. Different domains for plugins? Yes! SELinux enforced sandboxes?</p>
<p>So here is the idea: We label sites by dns name or IP and have Chrome execute the rendering processes in different domains. *.tresys.com would run in internal_website_t and not be able to send data to the internet! my bank site would run in bank_website_t and only be able to send data to my banks address. Even if I have some sort of browser or plugin exploit going on it won&#8217;t matter, only data can be sent to the appropriate place (this is the beauty of mandatory access control, even a broken application can&#8217;t do anything bad). This should work because Chrome even creates new rendering processes if you jump from one domain to another (It does this today). If I go to facebook and then to myspace in the same tab a new process is created for myspace. I&#8217;d like to go so far as to put the javascript vm in another process, since it is executing dynamically generated code, or else we&#8217;ll have to give the rendering process the ability to execheap, execstack, not a good permission to give something already susceptable to vulnerabilities.</p>
<p>What is the net result of this? It is like the manual separation I and others have talked about before but from the user perspective it is seamless. Tabs in the same browser running in different security domains without the users knowledge, seamless mandatory security on web browsing, I can&#8217;t wait!</p>
<p>If this should happen to reach any of the Chrome developers I&#8217;d love to talk to you about the possibilites. Combining this browser (which is excellent BTW, I&#8217;m using it to write this blog post) with the mandatory separation afforded by SELinux would make an incredibly powerful platform for securing web applications.</p></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/09/02/web-browsers-security-and-google-chrome/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Security Anti-Pattern: MLS for Guards</title>
		<link>http://securityblog.org/brindle/2008/05/18/security-anti-pattern-mls-for-guards/</link>
		<comments>http://securityblog.org/brindle/2008/05/18/security-anti-pattern-mls-for-guards/#comments</comments>
		<pubDate>Sun, 18 May 2008 18:06:15 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[BLP]]></category>

		<category><![CDATA[CDS]]></category>

		<category><![CDATA[Guard]]></category>

		<category><![CDATA[MLS]]></category>

		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/?p=24</guid>
		<description><![CDATA[This article was requested, and was a long time coming anyway.
I&#8217;ve gone over Multi-Level Security (MLS) a little bit before. It&#8217;s basically a security policy that is implemented by many trusted operating systems (such as Trusted Solaris) that is hierarchical and inflexible by nature. Specifically Bell-LaPadula (BLP) is used by many operating systems because it [...]]]></description>
			<content:encoded><![CDATA[<p>This article was requested, and was a long time coming anyway.</p>
<p>I&#8217;ve gone over Multi-Level Security (MLS) a little bit before. It&#8217;s basically a security policy that is implemented by many trusted operating systems (such as Trusted Solaris) that is hierarchical and inflexible by nature. Specifically Bell-LaPadula (BLP) is used by many operating systems because it reflects the real world security policy used by the government and military. In BLP subjects and objects have a label consisting of a level (Secret, Top Secret, Unclassified, etc) and a set of non-hierarchical categories (US Only, Army, etc).</p>
<p>The sensitivies are hierarchical in that a higher sensitivity process labeled top secret can read and write top secret objects but only read unclassified objects. This prevents the &#8216;downgrade&#8217; of classified information. For systems that conform to this kind of policy it makes perfect sense, a multi-level desktop system allows users to keep top secret and unclassified material on the same system but does not allow the release of top secret data to unclassified environments or users. Lower levels can also write to higher levels, in some cases. This may seem bad but considering what the policy is trying to accomplish allowing an unclassified process to write a top secret document doesn&#8217;t disclose top secret data. The catch is that the unclassified process would never be able to read the document after writing it. This policy is only usable for confidentiality, to prevent information from being released inappropriately. It cannot address integrity or other security goals I have mentioned in other articles.</p>
<p>Because traditional trusted operating systems only implemented BLP (and in some rare cases Biba for integrity) the users of such systems (primarily government and military) had to use it even when it wasn&#8217;t appropriate. One such case is a guard, or cross domain solution (CDS). A CDS is a system that allows two or more networks of differing security properties to be connected to one another. A typical CDS can connect a top secret to a secret network, for example, and allow information from the secret network onto the top secret network but not vice versa. CDS&#8217;s also do the opposite, allowing a controlled release of information from top secret to secret, or between two coalition networks (Such as Australia and the US). CDS&#8217;s always have some safety mechanism built in to prevent malicious data, or inappropriate data from going across it (if it didn&#8217;t it wouldn&#8217;t be any more useful than a crossover cable between the networks). These safety mechanisms are virus scanners, &#8220;dirty word&#8221; filters, document disassemblers (for example to take a word document and convert it to plain text or pdf), etc. The type of safety mechanism primarily depends on what kinds of networks the system is connecting.</p>
<p>For now we&#8217;ll talk about the first case, letting information flow from a secret network to a top secret network. Since a BLP system is designed to let information go from secret to top secret already it seems like an obvious fit, right? If the CDS was a very simple system with a process to read incoming data, a virus filter and an outgoing process it seems like a BLP policy would be fine. We are going to call the set of processes that pass data through the system the pipeline.</p>
<p>Wrong, there are actually multiple issues here. Because the lower levels would be allowed to write to higher levels, but not read from them we could label the incoming process Unclassified, the middle process Secret and the outgoing process Top Secret. This allows flow from the incoming process to the outgoing process. The main problem here is that since the levels are hierarchical there is nothing that stops the Unclassified process from writing directly to the Top Secret process (oops). Well, people figured this out and thought of a great work-around. Remember those categories? Categories allow reading and writing when the subject dominates (or has a superset) the categories of the object. So you give the incoming process categories that dominate the categories of the middle process but not the outgoing process.</p>
<p>So that problem is solved (albeit in an interesting way) but CDS&#8217;s are never that simple (I mean never). The requirements that are imposed on CDS&#8217;s specify pesky little things like logging, auditing, monitoring, emergency shutdown, etc. So now our simple CDS needs all processes to be able to talk to a logging system, and a monitoring system must ask the processes for their state and get back a response. So now we have one or more huge processes that can talk to and receive data from every process in the pipeline. That wouldn&#8217;t be so bad except the functional requirements of every guard I&#8217;ve seen says that those logs have to end up on the high side for consumption, which is obvious, they certainly can&#8217;t go to the low side because that would be a violation of the security policy. This, of course, allows information to flow through the logging and monitoring process out the other side without going through the set of filters. Sure, the advocates will say the logging and monitoring system is part of the TCB (Trusted Computing Base), the part of the system that is trusted to not do nasty things, but in a system like this do you want such processes to be trusted?</p>
<p><img src="http://securityblog.org/images/bad-cds.png" alt="Bad CDS" /><br />
The above (totally professionally done) diagram shows the attack vector that would be used to get data through such a system. Because the logging/monitoring app is allowed to violate the MAC policy it is possible to use it to bypass filters 2, 3 and 4.</p>
<p>So basically its impossible to use a BLP policy on a guard and ensure that all data is passed through all filters before it reaches the other side, the policy simply wasn&#8217;t made for that kind of thing. It has been the standard operating procedure to shoehorn CDS&#8217;s into that policy for a very long time, however.</p>
<p>Before I get into how SELinux helps this I&#8217;ll quickly cover the other two types of guards I previously mentioned. First the High-to-Low guard. This kind of guard basically allows controlled downgrading of information; it will run filters like a &#8216;dirty word&#8217; filter to ensure nothing that shouldn&#8217;t be getting downgraded isn&#8217;t. It may also redact some data. This CDS is a direct violation of the BLP policy, as such the processes essentially have to be MAC Exempt, or not subject to the policy, essentially making the existence of the policy irrelevant, it should be easy to see why this is an inappropriate use of BLP. The second was a CDS between two coalition partners. In this case the BLP policy doesn&#8217;t even mean anything since there is no high side and low side, merely &#8216;different&#8217; sides.</p>
<p>So, those are the reasons why BLP is inappropriate for CDS&#8217;s, why is SELinux different?</p>
<p>SELinux primarily uses type enforcement for policy decisions. Type enforcement allows fine grained policy to be written for all subjects and objects on the system. In the case of CDS&#8217;s you can literally say incoming process can write to virus scanner (but not read) and virus scanner can write to outgoing process. We call this an assured pipeline. This can be used for any size or type of pipeline, we even have a tool called CDS Framework that lets you visualize the CDS system. But wait, what about all that logging and auditing and monitoring? Simple, since the policy can describe arbitrary relationships between processes we can break that logging and monitoring process up into filter size chunks, then allow each filter to read and write from the logging and monitoring app. The logging and monitoring app can then send its logs through the same pipeline as the data, it will end up on the high side but there is no additional large process you have to trust to allow it to happen. Using type enforcement we can ensure that every single bit of information that comes leaves the guard passed through every filter (we can&#8217;t, of course guarantee that the filters worked). Since type enforcement is not hierarchical the direction of the CDS doesn&#8217;t matter, we can do the same thing for High-to-Low that we do for Low-to-High, or even between coalition networks.</p>
<p><img src="http://securityblog.org/images/good-cds.png" alt="Good CDS" /><br />
The above diagram shows a possible CDS configuration using type enforcement. It allows for logging and monitoring and simply passes those messages back through the filters to get them to the high side. In this configuration no single part of the pipeline is trusted to violate the policy, and filters can never be bypassed. This policy would be impossible to enforce with BLP.</p>
<p>Don&#8217;t take this to mean that I hate MLS and never think it&#8217;s useful. I&#8217;m not saying it kicks puppies (although it does occasional pee on rugs I&#8217;m told). MLS has a time and a place, just like everything else. The point I&#8217;m trying to make is that it shouldn&#8217;t be used if it isn&#8217;t appropriate, as has been done in the past (and continues to be done today).</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/05/18/security-anti-pattern-mls-for-guards/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is the BSD license more liberal or conservative than the GPL?</title>
		<link>http://securityblog.org/brindle/2008/04/11/is-the-bsd-license-more-liberal-or-conservative-than-the-gpl/</link>
		<comments>http://securityblog.org/brindle/2008/04/11/is-the-bsd-license-more-liberal-or-conservative-than-the-gpl/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 20:21:00 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[bsd]]></category>

		<category><![CDATA[conservative]]></category>

		<category><![CDATA[gpl]]></category>

		<category><![CDATA[liberal]]></category>

		<category><![CDATA[license]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/2008/04/11/is-the-bsd-license-more-liberal-or-conservative-than-the-gpl/</guid>
		<description><![CDATA[Recently I was looking around for a piece of software and I thought to myself &#8220;I need something with a more liberal license than the GPL&#8221;.. Then I thought &#8220;Wait, is liberal the right word there? Hrm&#8221;&#8230;
So what do you guys think?
]]></description>
			<content:encoded><![CDATA[<p>Recently I was looking around for a piece of software and I thought to myself &#8220;I need something with a more liberal license than the GPL&#8221;.. Then I thought &#8220;Wait, is liberal the right word there? Hrm&#8221;&#8230;<br />
So what do you guys think?</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/04/11/is-the-bsd-license-more-liberal-or-conservative-than-the-gpl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Secure doesn&#8217;t mean anything.</title>
		<link>http://securityblog.org/brindle/2008/03/30/secure-doesnt-mean-anything/</link>
		<comments>http://securityblog.org/brindle/2008/03/30/secure-doesnt-mean-anything/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 16:26:54 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[biba]]></category>

		<category><![CDATA[database]]></category>

		<category><![CDATA[integrity]]></category>

		<category><![CDATA[mandatory-access-control]]></category>

		<category><![CDATA[openbsd]]></category>

		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/2008/03/30/secure-doesnt-mean-anything/</guid>
		<description><![CDATA[No, seriously. I&#8217;m not trying to be ironic because the title of my blog is &#8220;Brindle on Security&#8221;, which I should probably change to something more creative anyway.
During my tenure at Gentoo, running the Hardened Gentoo project, the most common question by far was &#8220;How do I secure my system?&#8221; Warning, this article may contain [...]]]></description>
			<content:encoded><![CDATA[<p>No, seriously. I&#8217;m not trying to be ironic because the title of my blog is &#8220;Brindle on Security&#8221;, which I should probably change to something more creative anyway.</p>
<p>During my tenure at Gentoo, running the Hardened Gentoo project, the most common question by far was &#8220;How do I secure my system?&#8221; Warning, this article may contain some flamebait, avoid it if you can&#8217;t resist flaming back ;).</p>
<p>Eventually we gave up and just pointed people to websites, perhaps this post can serve as that page. The answer was &#8220;What do you mean &#8217;secure&#8217; your system?&#8221; Security isn&#8217;t, and can&#8217;t be, a goal by itself. You need to know what exactly you are trying to protect yourself against, your threat model, as it were.<br />
<span id="more-22"></span><br />
SELinux has the ability to protect against many different threat models. In Hardened Gentoo we also had some complimentary projects that protected against things that SELinux couldn&#8217;t, such as PaX (kernel level memory execution protection and memory layout randomization) and SSP (userspace level stack smashing protection). Fedora also has comparable technologies such as Exec Shield baked in by default.</p>
<p>So I saw a thread recently that said something to the concern of &#8220;Why use SELinux, which is security bolted onto Linux when you can use OpenBSD which has security as part of the development process?&#8221; It&#8217;s an interesting question I suppose, if you can decode it. The OpenBSD mantra seems to be develop software correctly in the first place and you don&#8217;t need additional layers of security. The baffling part is that you&#8217;ll rarely find an OpenBSD user that actually knows what security OpenBSD actually, tangibly provides.</p>
<p>All that said, there are different kinds of security that you might want to implement, and lots of different solutions to attain them.</p>
<h2>System Integrity</h2>
<p>System integrity is what most people mean when they say &#8220;secure my system&#8221;. Do you want system integrity? The answer is almost always yes. Some people want very good system integrity and end up using a read only medium, like a livecd or dvd, to run their systems. This, of course, only works if you aren&#8217;t storing important data on those systems, for things like web front ends to applications servers it might work fine.</p>
<p>System integrity is what OpenBSD users mean when they say they have a secure system. They integrate quality control into their development process to ensure that as few bugs as possible get into their code and the result is suppose to be high system integrity.</p>
<p>Quality control alone doesn&#8217;t give you complete system integrity, however. Your kernel can be well coded but that doesn&#8217;t mean much if other processes running as root are vulnerable. Just take a look at ps and see how many applications are running as root. If any of those services are vulnerable your system may have less integrity than previously thought. The fact is everyone runs third party apps on their UNIX/Linux systems. Most users run Apache, samba, syslog, etc and all have components running as root. Even OpenBSD isn&#8217;t without vulnerabilities, quality control only goes so far, after that more is necessary.</p>
<p>Memory protection techniques can help protect against some of these vulnerabilities. NX support on modern processors prevent some exploits that use bugs to add shellcode to  running applications but that won&#8217;t prevent someone from using code already present in the address space, such as system(). Memory layout randomization only provides stop gap protection since the layout can eventually be brute forced, if the administrator isn&#8217;t watching very closely.</p>
<p>Mandatory access control is a way of addressing the gaps between a well coded kernel and vulnerable third party applications. If Apache shouldn&#8217;t be able to write to anything in /usr then MAC can prevent that. This, by itself, is a huge win for system integrity since it is generally thought that /usr is the highest integrity part of the system.</p>
<p>Now for some explanation. On most systems you can think of integrity as either low or high. High integrity files are files that are system objects. Things in /usr are pretty much all system objects. If a system object gets changed the behavior of the system is changed. A rootkit is going to target these high integrity files, for example. Other examples of high integrity objects are, ofcourse, anything in /boot, /lib, /sbin, /bin, most files in /etc, and so on. User files, on the other hand, are generally low integrity files. Anything in /home is untrusted. User data should never be able to affect the integrity of the system.</p>
<p>The integrity of a process is determined simply by where it gets its input. If a process reads user data, or data off of an untrusted network it is considered low integrity. Apache, which reads /home/*/public_html and receives queries from the internet, is low integrity. RPM, which is run by the administrator, reads rpm&#8217;s downloaded from your vendor (hopefully) and installs files all over the system, is high integrity (this is an assessment of how it operates, not whether it is free of vulnerabilities).</p>
<p>Now that you know how to determine the integrity level of objects and processes lets talk about the security policy to maintain system integrity. Biba is a hierarchical integrity policy, similar to Bell LaPadula but, interestingly, the exact opposite. It allows processes to both read and write to objects of the same integrity, no surprises there. Next it allows high integrity processes to write to low integrity objects, but not read them and last it allows low integrity processes to read high integrity objects but not write them.</p>
<p><img alt="Biba" title="Biba" src="/images/biba.png" /></p>
<p>Though the use of Biba is very limited and has never hit a mainstream operating system it is a very good practice, if implemented in a usable way. The standard SELinux policies implement something between Biba and &#8216;least privilege&#8217;, with a nice balance to ensure system integrity without making the system completely unusable. Biba, for example, isn&#8217;t very flexible. Since processes and objects are simply labeled with their integrity there is no way to make practical changes to the policy. You either fall within the constraints of Biba or you are entirely MAC exempt.</p>
<p>The SELinux Apache policy doesn&#8217;t allow Apache to write to the high integrity files we talked about above (/usr, /lib, /bin, etc) while allowing it to write to its logs, its cache, etc. Since objects in SELinux have fine grained labeling we can restrict access to apache high integrity objects, such as apache modules, the apache configuration and so on. In many ways SELinux lets us constrain applications more than Biba while at the same time making practical exceptions when necessary. This brings me to my next kind of security.</p>
<h2>Application and Data Integrity</h2>
<p>While system integrity is generally of the utmost importance, since it is the basis on which you can build other security goals, in some cases it is not enough. Sometimes the most important part of a system is the applications it is running, or the data those applications manage.</p>
<p>For example, if you are running a database server the most important part of the system quite possibly could be the data in that database. How do you protect that data?</p>
<p>We can go back to the mantra of well coded systems with quality control but that, once again, fails when you consider other applications running on the system. Granted you&#8217;ll need to trust the database server itself with the data, there is no way around that but the other applications that can access the data can be problematic. Generally database files would be owned by a non-root user with the correct permissions set to prevent other applications from accessing them without going through the database server. Of course root applications can bypass all those restrictions.</p>
<p>There are multiple ways to protect the data. One way is run only the database server on the system and nothing else. That way there is nothing else to protect the data from. This can work in well controlled environments but there are always going to be apps running, like the system logger and sometimes, particularly on UNIX like systems, there is a tendency to put multiple applications on a single system. There will always be the need for backup apps, log monitors, log rotators, etc. This may be a risk you are willing to take, and that is what threat modeling is all about. If you can accept the risk then your security may already meet your needs.</p>
<p>Another way people have tried recently is with hypervisors. Unfortunately the current generation of hypervisors always require a domain 0 or host OS that essentially has full access to the disk, the network interfaces, sometimes the memory, etc. Protecting the integrity of applications within a VM is impossible without first doing so on the host OS, as I pointed out in my <a title="Why Blu-Ray scares me" href="http://securityblog.org/brindle/2008/01/24/why-blu-ray-scares-me/">Blu-ray post</a>.</p>
<p>MAC systems are IMHO a superior way to handle application and data integrity. SELinux policies can prevent anyone from accessing the database files aside from the database server itself. You may need the backup service to read the database files directly (unless it is configured to get backups directly from the database server itself) but you can easily make the backup server only able to read files without being able to write them, which is not something you can easily do without MAC.</p>
<h2>Pipelines</h2>
<p>Another security goal which is often overlooked outside of a small niche of guard architects are pipelines. Guards are systems with specific purposes to transfer data from one side to another, while going through a specific set of applications. In the real world one can envision a proxy server or a virus scanning email server as a guard. The idea is that data coming into a system must go through some number of applications before it is allowed to proceed.</p>
<p><img alt="pipeline" title="pipeline" src="/images/pipeline.png" /></p>
<p>In this security goal it is desired that any incoming email goes through a virus and spam filter before going on to the user mail directory and ultimately onto the end users system. This may be more of a functional goal than a security goal to some. As a former administrator I understand the security ramifications of unfiltered email getting through to the network. This kind of goal is generally enforced with configuration of the mail system but for some people that is not enough.</p>
<p>Pipelines obviously rely on system integrity to protect the layer below the pipeline itself, so those security goals are composed onto one another. An opensource project that my company developed called CDS Framework implements this sort of security goal.</p>
<h2>Conclusion</h2>
<p>There are other security goals one can implement, these are only examples. The first two are probably the most important for most users. The main thing I want people who read this to take away is that there is no such thing as a &#8217;secure system&#8217; or &#8216;added on security&#8217; or &#8216;baked in security&#8217;. Security by itself doesn&#8217;t mean anything. Users need to determine their threat model and security goals in order to determine what measures need to be taken in order to protect what they want protected.</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/03/30/secure-doesnt-mean-anything/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Why Blu-Ray scares me</title>
		<link>http://securityblog.org/brindle/2008/01/24/why-blu-ray-scares-me/</link>
		<comments>http://securityblog.org/brindle/2008/01/24/why-blu-ray-scares-me/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 02:30:54 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[bd+]]></category>

		<category><![CDATA[bluray]]></category>

		<category><![CDATA[DRM]]></category>

		<category><![CDATA[virtual machine]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/2008/01/24/why-blu-ray-scares-me/</guid>
		<description><![CDATA[Now that Blu-Ray has all but won the HD format war I guess its a little late to post this but oh well, I&#8217;ll do it anyway.
Disclaimer: I am an HDDVD owner but this post is not a result of  bitterness about my chosen format losing. The reason I&#8217;m posting here about (among others) [...]]]></description>
			<content:encoded><![CDATA[<p>Now that Blu-Ray has all but won the HD format war I guess its a little late to post this but oh well, I&#8217;ll do it anyway.</p>
<p>Disclaimer: I am an HDDVD owner but this post is not a result of  bitterness about my chosen format losing. The reason I&#8217;m posting here about (among others) is the actual reason I chose HDDVD. I also don&#8217;t want to talk about the pro&#8217;s and con&#8217;s of DRM or whether the DRM has been cracked and is accessible via other means. I am going to talk about the intentions of the format producers and what it means to consumers.</p>
<p><span id="more-21"></span><br />
So, basically the big security problem I have with Blu-Ray is that <a title="BD+" href="http://en.wikipedia.org/wiki/BD%2B" target="_blank">BD+</a> (a BluRay specific DRM mechanism) has some scary provisions to make movie producers happy. Basically the idea behind BD+ is that the movie, decoding, etc is done from within a virtual machine.</p>
<p>So the problem with using a virtual machine to protect the data from the person who owns the device is that the host inherently can access and manipulate the virtual machine itself, including the data. This presents a fundamental problem with the idea of protecting the content. So in order to address this the movie producer must be satisfied that the host machine is in a state where the virtual machine is considered safe.</p>
<p>This is where BD+ gets scary. It allows movie producers to package arbitrary host executables with the BD+ virtual machine that is run on the player before the virtual machine unencrypts any content. The idea, of course,  is that a vulnerable host (that is, a host that allows unauthorized access to the unencrypted content) can be patched in order to close the vulnerability. This has some serious ramifications including, but not limited to, producers being able to rootkit machines (see sony&#8217;s recent rootkit fiascos), spyware, broken patches that make systems more vulnerable, broken patches that break machines, patches that affect different OS releases differently, etc.</p>
<p>I almost wish a producer would create a PS3 patch that bricks a bunch of PS3&#8217;s just to show how very very dangerous &#8220;features&#8221; like this are.</p>
<p>So that is one of the features that scared me the most. There are other problems I had that caused me to choose HDDVD such as incomplete specifications for BluRay, fewer features in the original specifications, limits on the layering of the disks and so on. I now have a dilemma about whether to get a BluRay player knowing that, as a consumer, the choices I make validate the behavior of the producers. The most disturbing fact is that the consumers who don&#8217;t know about these issues have implicitly allowed the format producers and movie producers to build this incredibly anti-consumer system. C&#8217;est la vie I suppose.</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2008/01/24/why-blu-ray-scares-me/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Misunderstanding UNIX security</title>
		<link>http://securityblog.org/brindle/2007/07/15/misunderstanding-unix-security/</link>
		<comments>http://securityblog.org/brindle/2007/07/15/misunderstanding-unix-security/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 17:12:38 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[apparmor]]></category>

		<category><![CDATA[mandatory-access-control]]></category>

		<category><![CDATA[path-based-access-control]]></category>

		<category><![CDATA[selinux]]></category>

		<category><![CDATA[selinux-symposium]]></category>

		<category><![CDATA[unix-security]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/2007/07/15/misunderstanding-unix-security/</guid>
		<description><![CDATA[I just got a comment on my post about path based access control that was fairly startling to me. The more I thought about it, though, the more I thought maybe others shared the beliefs so I&#8217;m going to respond to it here.
inode-based security has analogous problems to path-based security.  Software opens paths, not [...]]]></description>
			<content:encoded><![CDATA[<p>I just got a comment on my post about path based access control that was fairly startling to me. The more I thought about it, though, the more I thought maybe others shared the beliefs so I&#8217;m going to respond to it here.</p>
<blockquote><p>inode-based security has analogous problems to path-based security.  Software opens paths, not inodes, so it very much matters what the permissions are for the file at /etc/shadow or /var/data/mydb, regardless of what the inode happens to be.  With an inode-based system, security may go out the window when programs replace or manipulate inodes, as many of them do.</p></blockquote>
<p>Software opens paths because paths are the exposed abstraction for userspace applications. Sure it matters what permissions are on /etc/shadow, but those permissions and the access control alike is <strong>always</strong> done at the inode level, as I will demonstrate below. Applications that manipulate inodes have always needed to set security attributes on those inodes, look at passwd source code and you will see that it creates the inode with mode 400 (r&#8212;&#8212;&#8211;).</p>
<blockquote><p>So, neither AppArmor nor SELinux provide bullet proof security or data integrity, although both may be useful in protecting against some problems.</p></blockquote>
<p>This is blatantly wrong,  SELinux provides controls to specify precisely how things can be labeled. If my policy does not allow an application that handles confidential information to relabel or create a file with a label that is accessible by other applications there are no circumstances where that application will be able to leak the data. Similarly if an application can&#8217;t read low-integrity data and write to high-integrity files there are no circumstances where the application can harm the data integrity. I suggest you read some of the papers about SELinux policy analysis and information flow to understand the issues and how SELinux can address them. Many are available at the <a href="http://selinux-symposium.org">SELinux symposium website</a>.</p>
<blockquote><p>But arguments like the ones in this blog really make me doubt whether the SELinux people even understand the issues or have much of a notion of how files and security work on real-world UNIX systems.</p></blockquote>
<p>As much as I&#8217;d like to ignore people using ad hominum attacks there may be others under this impression. Note the following demonstration as a counter example:</p>
<pre># ls -al /etc/shadow
-r-------- 1 root root 947 2007-06-06 03:40 /etc/shadow</pre>
<pre># ln /etc/shadow /tmp/shadow
# ls -al /tmp/shadow
-r-------- 2 root root 947 2007-06-06 03:40 /tmp/shadow</pre>
<pre># chmod 777 /tmp/shadow
# ls -al /etc/shadow
-rwxrwxrwx 2 root root 947 2007-06-06 03:40 /etc/shadow</pre>
<p>It should be clear at this point that the UNIX permissions absolutely do not have anything to do with paths, only with inodes. This is how real-world UNIX systems have always worked, path based mechanisms break that convention and are subject to the issues I&#8217;ve noted in the path based article. The simple fact is that UNIX systems never ever use paths to determine access to anything, access control has always been centered around inodes and permissions set on inodes. Do not think that the existance of paths changes that, these are merely an abstraction to make userspace more useful.</p>
<p>The arguments against SELinux by the AppArmor people, and others, are purely functionality based arguments. They want to use paths because paths are easy to understand and paths have conventions that can be reflected in their policy (eg., that passwords are always stored in /etc/shadow and therefore that file should be protected). SELinux provides mechanisms to enforce many different security policies including protecting /etc/shadow and /var/data/mydb.</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2007/07/15/misunderstanding-unix-security/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Secure Networking with SELinux</title>
		<link>http://securityblog.org/brindle/2007/05/28/secure-networking-with-selinux/</link>
		<comments>http://securityblog.org/brindle/2007/05/28/secure-networking-with-selinux/#comments</comments>
		<pubDate>Mon, 28 May 2007 17:51:26 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[mandatory-access-control]]></category>

		<category><![CDATA[networking]]></category>

		<category><![CDATA[opensource]]></category>

		<category><![CDATA[selinux]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/2007/05/28/secure-networking-with-selinux/</guid>
		<description><![CDATA[During the last year quite a bit of effort has gone into improving SELinux&#8217; networking support, thanks to the great SELinux community. While this support is still evolving it will be very beneficial for people to try it out and give feedback so the final result is useful to more users and meets the security [...]]]></description>
			<content:encoded><![CDATA[<p>During the last year quite a bit of effort has gone into improving SELinux&#8217; networking support, thanks to the great SELinux community. While this support is still evolving it will be very beneficial for people to try it out and give feedback so the final result is useful to more users and meets the security needs of a wider audience. As the network support in SELinux continues to evolve (there are already other ideas being discussed for possible inclusion) I&#8217;ll try to keep this post updated so that people who find it will have the latest information available.</p>
<p><span id="more-19"></span></p>
<p>Network support in SELinux means many things. In the old days (&#8221;old days&#8221; is very relative since it was only a few kernel releases back at this point) SELinux had fine grained network access control by way of many object classes. These object classes were netif (network interfaces), node (network addresses) and a handful of socket object classes (such as tcp_socket, udp_socket, rawip_socket and so on).</p>
<p>The SELinux policy directly labeled several kinds of network objects including interfaces (using netifcon), internet nodes (using nodecon) and ports (using portcon). The policy statements looked something like these:</p>
<p><code> netifcon eth0 system_u:object_r:external_netif_t system_u:object_r:external_packet_t </code></p>
<p><code>nodecon 192.168.1.1 255.255.255.255 system_u:object_r:external_node_t; portcon tcp 21 system_u:object_r:ftp_port_t ; </code></p>
<p>These labeled objects could then be given access to with normal SELinux rules:</p>
<p><code> allow ftpd_t external_netif_t : netif {tcp_send tcp_recv }; </code></p>
<p><code>allow ftpd_t external_node_t : node { tcp_send tcp_recv }; </code></p>
<p><code>allow ftpd_t ftp_port_t : tcp_socket { send_msg recv_msg name_bind }; </code></p>
<p>These basically gave ftpd_t the ability to bind to port 21, send and receive tcp messages on port 21 and send and receive tcp messages on eth0 (whose ip was 192.168.1.1). These worked fine, the only problem is that they weren&#8217;t specified in a single rule so they weren&#8217;t coupled. This means if there was another set of rules that let ftpd_t send and receive dns packets (for name resolution) only on the internal interface they could also send and receive dns packets on the external interface by virtue of the rules above. Note that these access controls can still be used en lieu of the ones I&#8217;m going to talk about next by setting the compat_net option in SELinux with echo 1 > /selinux/compat_net.</p>
<p>The labeling of these objects was eventually added to libsemanage and could be changed on end systems using the semanage command without modifying policies.</p>
<p>During the 2006 SELinux Symposium Developer Summit we discussed ideas on making the network labeling easier to use, more able to support typical network restrictions and most importantly to closely bind the interface, address and port. Fortunately for us netfilter in Linux already supports all these things as well as some additional benefits like connection tracking that can be used to more precisely restrict things that use dynamic ports such as ftp.</p>
<p>One may be thinking that the easiest way to handle this is to add a domain specifier to iptables so that one could write a rule that matched the SELinux domain as well as the ports, network interface and addresses to allow only ftp packets to reach ftpd_t. This would have decentralized the SELinux policy, however, by moving part of the decision making out of the SELinux security server and into the iptables policy and subsystem. This is generally undesirable as we&#8217;d like to keep a single, centralized, analyzable SELinux policy. That essentially left us with using netfilter and iptables to label packets, which would have SELinux allows rules written to allow or deny access. Lets look at how this might be used:</p>
<p><code> iptables -A INPUT -t mangle -p tcp --dport 21 -j SECMARK --selctx system_u:object_r:ftp_packet_t </code></p>
<p>This labels packets destined for port 21 as ftp_ packet_t. The SELinux rule that allows ftpd_t send and receive packets of this type is simply:</p>
<p><code> allow ftpd_t ftp_packet_t : packet { send recv }; </code></p>
<p>But this doesn&#8217;t do anything more than the old network controls did, lets look at something more interesting:</p>
<p><code> iptables -A INPUT -t mangle -p tcp --dport 21 -i eth0 -s 192.168.0.1/24 -j SECMARK --selctx system_u:object_r:ftp_packet_t </code></p>
<p>This labels only packets on eth0, coming from 192.168.0.1/24 and on tcp port 21 as ftp_packet_t. So this has the advantage of being able to couple anything that netfilter supports together. Another iptables rule such as:</p>
<p><code> iptables -A INPUT -t mangle -m state --state RELATED,ESTABLISHED -j CONNSECMARK -restore </code></p>
<p>will copy the label for related packets so when an ftp client attempts a file transfer the related port (which is dynamically assigned at the time of the transfer) will receive the same label. This takes advantage of netfilter&#8217;s connection tracking features to allow ftp to only receive packets related to its connections. This requires no additional policy rules or policy modifications of any kind since the labels are all we are changing.</p>
<p>What this brings over netfilter&#8217;s existing functionality is the ability to specify precisely which domains can access which packets, so it allows you to bring the firewall functionality all the way to the processes rather than just to the machine, which is significant if you have several services of differing security properties running on the same machine. This would, for example, allow you to have an internal Apache instance with access to company confidential data to only be accessible internally and another external Apache instance that serves static web content to the internet.</p>
<p>While most people think of network access controls in the terms of firewalls alone this is not the only network support in SELinux. The next kind of SELinux network support is labeled networking.</p>
<p>There are two methods of labeling network traffic in SELinux: NetLabel, which is an implementation of CIPSO, and IPSec based labeling. I&#8217;m not going to talk about NetLabel because it only supports the MLS portion of the SELinux context and is primarily useful for making SELinux cooperate with legacy trusted operating systems like Trusted HP-UX and Trusted Solaris. IPSec based labeling sends the entire context but currently only works between SELinux systems.</p>
<p>As NetLabel is primarily for supporting MLS and legacy trusted systems I&#8217;m not going to talk about it, lets instead move to IPSec based labeling.</p>
<p>I&#8217;m going to assume some knowledge of IPSec here so if you are unfamiliar with some of the terms please consult IPSec documentation. In particular you need to know what SPD&#8217;s and SA&#8217;s are and what their role in IPSec is.<br />
The first thing you need is a kernel that supports IPSec labeling. The easiest way (if you are using Red Hat) is to use the current Fedora rawhide kernel or the LSPP kernel. The LSPP kernel is available at <a href="http://people.redhat.com/sgrubb/files/lspp/">http://people.redhat.com/sgrubb/files/lspp/</a>. For the non-Red Hat users in the audience labeled IPSec is also available in the released version of linux-2.6.22.</p>
<p>You&#8217;ll also need an ipsec-tools that is capable of labeling, rawhides or the LSPP version will do here as well. Once you have everything you need installed you can start using labeled IPSec. We&#8217;ll start with simple labeled SA&#8217;s.</p>
<p>First I have a couple programs that will help test and ensure that everything is working. They are simple a simple client and server that connect, use getpeercon() to return what the context of the network socket is.</p>
<p><a href="/src/client.c">client.c</a></p>
<p><a href="/src/server.c">server.c</a></p>
<p>Build these by linking them against libselinux:</p>
<p><code>gcc -o client client.c -lselinux</code></p>
<p><code>gcc -o server server.c -lselinux</code></p>
<p>First lets try running them without IPSec to see what happens:</p>
<p>My test machines are 192.168.147.132 (scarecrow) and 192.168.147.130 (poisonivy), obviously replace with your addresses.</p>
<p>After running server on 192.168.147.132 and running client 192.168.147.132 on the other machine the output should look like this:</p>
<p><code>[root@poisonivy ~]# ./client 192.168.147.132 </code></p>
<p><code>getpeercon: Protocol not available Received: Hello, (null) from (null)</code></p>
<p><code> [root@scarecrow ~]# ./server </code></p>
<p><code>getsockopt: Protocol not available server: got connection from 192.168.147.130, (null) </code></p>
<p>getpeercon() returns protocol not available because no labeling was enabled on this connection, you can use the error to determine if you are using a labeled network socket or not.</p>
<p>If we make an SA between these 2 machines without specifying a context we&#8217;ll get the same results:</p>
<p><code> [root@scarecrow ~]# cat dev/ipsec/setkey.scarecrow.test  </code></p>
<p><code>spdflush; </code></p>
<p><code>flush;  </code></p>
<p><code>spdadd 192.168.147.130 192.168.147.132 any</code></p>
<p><code>    -P in ipsec         esp/transport//require;  </code></p>
<p><code>spdadd 192.168.147.132 192.168.147.130 any </code></p>
<p><code>    -P out ipsec         esp/transport//require; </code></p>
<p><code>[root@poisonivy ~]# cat dev/ipsec/setkey.poisonivy.test  </code></p>
<p><code>spdflush; </code></p>
<p><code>flush;  </code></p>
<p><code>spdadd 192.168.147.132 192.168.147.130 any  </code></p>
<p><code>    -P in ipsec          esp/transport//require;   </code></p>
<p><code>spdadd 192.168.147.130 192.168.147.132 any  </code></p>
<p><code>    -P out ipsec          esp/transport//require; </code></p>
<p>Then run:</p>
<p><code> [root@poisonivy ~]# setkey -f dev/ipsec/setkey.poisonivy.test       </code></p>
<p><code> [root@scarecrow ~]# setkey -f dev/ipsec/setkey.scarecrow.test </code></p>
<p>NOTE: both machines will need to be running racoon in order to create SA&#8217;s when the connections are attempted.</p>
<p>Running server and client the same as before will give the exact same results. You can use setkey -D to see the newly created SA&#8217;s. Notice that the SA&#8217;s are not be labeled.</p>
<p>If we add a -ctx statement to our setkey files such that:</p>
<p><code> [root@scarecrow ~]# cat dev/ipsec/setkey.scarecrow.test  </code></p>
<p><code>spdflush; </code></p>
<p><code>flush;  </code></p>
<p><code>spdadd 192.168.147.130 192.168.147.132 any </code></p>
<p><code>    -ctx 1 1 "system_u:object_r:default_t:s0"         </code></p>
<p><code>    -P in ipsec         esp/transport//require;  </code></p>
<p><code>spdadd 192.168.147.132 192.168.147.130 any </code></p>
<p><code>    -ctx 1 1 "system_u:object_r:default_t:s0"         </code></p>
<p><code>    -P out ipsec         esp/transport//require; </code></p>
<p>You can use setkey -DP to see the SPD entries on each machine, note the context field in the entries.<br />
Repeat this with the other machines setkey file. Note that you&#8217;d never use default_t in a label, this is an example to show what happens. This is _NOT_ the label that will be used to create SA&#8217;s, this label will be used in a &#8216;polmatch&#8217; rule to see which SPD entries a domain can match to. This will be explained later.</p>
<p>Running setkey -f results in an error now:</p>
<p><code> [root@scarecrow ~]# setkey -f dev/ipsec/setkey.scarecrow.test  </code></p>
<p><code>The result of line 8: Permission denied. </code></p>
<p><code>The result of line 14: Permission denied. </code></p>
<p>Looking for the denial:</p>
<p><code> [root@scarecrow ~]# tail /var/log/audit/audit.log  | grep AVC </code></p>
<p><code>type=AVC msg=audit(1179150979.762:33): avc:  denied  { setcontext } for  pid=21632 comm="setkey" scontext=root:system_r:unconfined_t:s0-s0:c0.c1023 tcontext=system_u:object_r:default_t:s0 tclass=association type=AVC msg=audit(1179150979.895:34): avc:  denied  { setcontext } for  pid=21632 comm="setkey" scontext=root:system_r:unconfined_t:s0-s0:c0.c1023 tcontext=system_u:object_r:default_t:s0 tclass=association </code></p>
<p>This is good, it means that we can protect who sets the labels on IPSec SPD&#8217;s. For now set permissive mode on both machines and run setkey again, it should now succeed.</p>
<p>Run the client and server again and you should see something like this on the client side:</p>
<p><code> [root@poisonivy ~]# ./client 192.168.147.132     </code></p>
<p><code>Received: Hello, root:system_r:unconfined_t:SystemLow-SystemHigh from root:system_r:unconfined_t:-SystemHigh</code></p>
<p>You can use setkey -D  to see the newly created SA&#8217;s and note the context field in each entry.<br />
Hopefully this image conveys how the SA&#8217;s are labeled, note that each side of the connection has 2 SA&#8217;s, one incoming and one outgoing with the appropriate labels. The outgoing SA for each system is always the local domain, the incoming SA for each system is always the remote domain.<br />
<img alt="labeled ipsec" title="labeled ipsec" src="/images/ipsec.png" /><br />
I&#8217;d like to thank <a title="Chris Ashworth" target="_blank" href="http://smashworth.org">Chris Ashworth</a> for the graphic, it is much simpler than mine and I think gives a better understanding of the labeled tunnels.</p>
<p>This demonstrates that the server sees root:system_r:unconfined_t:SystemLow-SystemHigh when it calls getpeercon() and the client sees root:system_r:unconfined_t:-SystemHigh. To show the difference more specifically run the client with a different context using runcon:</p>
<p><code> [root@poisonivy ~]# runcon -t httpd_t ./client 192.168.147.132         </code></p>
<p><code>Received: Hello, root:system_r:httpd_t:SystemLow-SystemHigh from root:system_r:unconfined_t:-SystemHigh </code></p>
<p>Now you can see the server sees httpd_t when it calls getpeercon(). So now we&#8217;ve seen how you can identify the process context on the other side of a connection, but what about the policy?</p>
<p>Lets clear out dmesg and setenforce 1; setenforce 0; to clear the AVC and start the process over.</p>
<p>First running setkey and then audit2allow -d should show:</p>
<p><code> allow unconfined_t default_t:association setcontext; </code></p>
<p>This means that unconfined_t (what your shell normally runs as) tried to set the context of an association to default_t. This is expected since we used default_t in our SPD entry. Run dmesg -c to clear the kernel buffer and try to run the server and client (with runcon):</p>
<p>Removing the irrelevant rules we should see something like this on the client side:</p>
<p><code> allow httpd_t default_t:association polmatch; </code></p>
<p>This rule means that the client (running as httpd_t) attempted to match against the SPD entry we added earlier. This is useful because you can use SELinux policy to enforce which SPD entries a domain may match against. For example, if you wanted to have some domains use high quality encryption and let the others use a faster, lower quality encryption you can do that by specifying which SPD types a domain may polmatch against.</p>
<p><code> allow httpd_t self:association sendto; </code></p>
<p>This is httpd_t sending data to an association labeled httpd_t. This basically just means that it is sending to the association created for it. Note that with the current controls you can not control which domains you are sending to on the other side.</p>
<p><code> allow httpd_t unconfined_t:association recvfrom; </code></p>
<p>This is the most significant control; it says that we are allowing httpd_t to receive from an association labeled unconfined_t, which is the result of the server running in unconfined_t. This lets you use policy to determine which domains on another machine can send data to which domains on the local machine.</p>
<p><code> allow unconfined_t default_t:association polmatch; </code></p>
<p>And this is the remote domain (the server) matching against the income SPD entry on this machine. Note that there were 2 SPD entries added, one for outgoing communication and one for incoming communication, both domains have to polmatch the SPD&#8217;s on the local machine (for outgoing) and the remote machine (for incoming).</p>
<p>There should be similar denials on the server side, only reversed so I won&#8217;t go over those.</p>
<p>As you can see you can do a significant amount with this technology, assuming that you control both policies (source and destination) you can be very certain which domains are talking to which domains across machines, similar to the SELinux IPC controls but across a network!</p>
<p>For example, one possible application of this technology is to have an &#8216;internal&#8217; and &#8216;external&#8217; browser on employee workstations. The internal browser would run in a domain that is allowed to access internal company web application servers that contain confidential customer information while the external browser can access the internet. This reduces the risk that rogue internet content can compromise your internal data. This kind of separation would be much more difficult (or impossible) without SELinux&#8217; advanced networking controls.</p>
<p>Using both labeled IPSec and netfilter secmark you can do some pretty amazing things with SELinux networking, and its only going to get better, stay tuned for more information.</p>
<p>A special thanks goes out to all the people that worked hard on getting this technology where it is now and the same ones trying to push it even further to have the best secure networking infrastructure around. These people include (in no particular order): James Morris, Venkat Yekkirala, Joy Latten, Paul Moore (who implemented NetLabel), and many others.<br />
<a href="http://marc.info/?a=117803237000001&#038;r=1&#038;w=2" /></p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2007/05/28/secure-networking-with-selinux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Don&#8217;t disable SELinux!</title>
		<link>http://securityblog.org/brindle/2007/05/05/dont-disable-selinux/</link>
		<comments>http://securityblog.org/brindle/2007/05/05/dont-disable-selinux/#comments</comments>
		<pubDate>Sat, 05 May 2007 22:47:11 +0000</pubDate>
		<dc:creator>Joshua Brindle</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[mandatory-access-control]]></category>

		<category><![CDATA[razor]]></category>

		<category><![CDATA[SAP]]></category>

		<category><![CDATA[selinux]]></category>

		<category><![CDATA[selinux-symposium]]></category>

		<guid isPermaLink="false">http://securityblog.org/brindle/2007/05/05/dont-disable-selinux/</guid>
		<description><![CDATA[A while back I wrote a post on companies telling their customers to disable SELinux in order to get applications running and why this is a very bad thing. While I don&#8217;t see the situation getting better in the near term I did see a blog posting today from an SAP employee about using SELinux [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I wrote <a target="_blank" href="http://securityblog.org/brindle/2006/05/21/software-not-working-disable-selinux/">a post</a> on companies telling their customers to disable SELinux in order to get applications running and why this is a very bad thing. While I don&#8217;t see the situation getting better in the near term I did see a <a target="_blank" href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/6453">blog posting today from an SAP employee</a> about using SELinux with SAP. This made me happy <img src='http://securityblog.org/brindle/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Since I don&#8217;t think his blog software uses trackbacks I&#8217;ll be contacting him to suggest some changes. Namely he says that SAP would not be able to send SELinux policy modules with their software to customers since it apparently gets installed in many different places.</p>
<p>I&#8217;d first like to mention to him (and anyone else reading this) that SELinux policy does not care about paths, only types. The policy part of the module can be the same for every SAP customer, specifying the exact interactions between their software and the rest of the system. The file context part of the module is not compiled and can be generated at install time and added to the policy they distribute with the semodule_package command. After installing the module and labeling the SAP related files everything should work the same.</p>
<p>Next I&#8217;d like to mention that, while this is a noble effort and I&#8217;m very happy to see enterprise vendors showing their customers how they can use SELinux, this article essentially tells people to audit2allow the SAP related denials into policy without reviewing exactly what those denials were or whether they were appropriate. My <a target="_blank" href="http://securityblog.org/brindle/2006/03/25/security-anti-pattern-status-quo-encapsulation/">status quo encapsulation article</a> is an analysis of this style of policy writing and why it is bad.</p>
<p>If a SAP engineer wanted to create a policy for SAP applications that implemented proper security objectives and have that added to the reference policy I&#8217;m sure we&#8217;d be more than happy to add it in. There are other options though. IBM has been working with my company, <a target="_blank" href="http://www.tresys.com">Tresys</a>, to develop a product, <a target="_blank" href="http://tresys.com/products/razor.html">Razor</a>, that takes generates policy for Websphere and DB2 by using configuration files that are understandable by the administrators of said applications. More information on the technique that Razor uses to create policies is available in a <a target="_blank" href="http://selinux-symposium.org/2006/slides/05-websphere.pdf">case study</a> from the 2006 <a target="_blank" href="http://selinux-symposium.org/">SELinux Symposium</a>. This product can be used to generate policy for all kinds of enterprise applications, including presumably SAP, that implement specific security goals instead of just encapsulating the status quo of the application.</p>
<p>All that said, I&#8217;m still glad to see some companies taking initiative and trying to work with their customers instead of against them.</p>
]]></content:encoded>
			<wfw:commentRss>http://securityblog.org/brindle/2007/05/05/dont-disable-selinux/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
