<?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>etbe &#187; Security</title>
	<atom:link href="http://etbe.coker.com.au/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://etbe.coker.com.au</link>
	<description>Linux, politics, and other interesting things</description>
	<pubDate>Thu, 24 Jul 2008 07:21:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>SE Linux Policy Loading</title>
		<link>http://etbe.coker.com.au/2008/07/24/se-linux-policy-loading/</link>
		<comments>http://etbe.coker.com.au/2008/07/24/se-linux-policy-loading/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 07:21:10 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

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

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=651</guid>
		<description><![CDATA[One of the most significant tasks performed by a SE Linux system is loading the &#8220;policy&#8220;.  The policy is the set of rules which determine what actions are permitted by each domain.
When I first started using SE Linux (in 2001) the kernel knew where to find the policy file and would just read the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most significant tasks performed by a SE Linux system is loading the &#8220;<B>policy</B>&#8220;.  The policy is the set of rules which determine what actions are permitted by each <B>domain</B>.</p>
<p>When I first started using SE Linux (in 2001) the kernel knew where to find the policy file and would just read the data from disk as soon as it had mounted the root filesystem.  Doing such things is generally considered to be a bad idea, but it was an acceptable mechanism for an early release.</p>
<p>One issue is that the policy needs to be loaded very early in the system boot process, before anything significant happens.  In the early days the design of SE Linux had no support for a process to change it&#8217;s security context other than by executing another process (similar to the way a non-root process in the Unix access control system can not change it&#8217;s UID, GID, or groups).  Although later on support for this was added, it was only available as the request of the application (an external process could not change the context of an application without using ptrace - a concept that is too horrible to contemplate) and I am not aware of anyone actually using it.  So it&#8217;s almost a requirement that there be no more than one active process in the system at the time that policy is loaded, therefore it must be init or something before init that loads the policy.</p>
<p>When it was decided that a user-space program had to instruct the kernel to load the policy we had to determine which program should do it and when it should be done, with the constraint that it had to be done early.  The most obvious solution to this problem was to load the policy in the initramfs (or initrd as it was known at the time).  One problem with this is that the initramfs is limited in size by kernel compilation options and may need to be recompiled to fit a bigger policy.  As an experiment to work around this limitation I had a small policy (which covered the domains for init and the scripts needed for the early stages for system boot) loaded in the initramfs and then later in the boot process (some time after the root filesystem was mounted read/write) the full policy was loaded.</p>
<p>A more serious problem with including policy in the initramfs was that it required rebuilding the initramfs every time the policy changed in a significant way, of course scripts could not determine when a change was significant (neither could most users) so that required needless rebuilds (which wastes time).  Even with a small policy for early booting loaded it was still sometimes necessary to change it and update the initramfs.  I believe that as a general rule an initramfs should only be rebuilt when a new kernel is installed or when a radical change is made to the boot process (EG moving from single disk to software RAID, changing between AMD and Intel CPU architecture, changing SCSI controller, or anything else that would make the old initramfs not boot the machine).  The initramfs that was used to boot my machine is known to actually work, the same can not be said for any new initramfs that I might generate.</p>
<p>But the deciding factor for me was support of machines that did not use an initramfs or initrd (such as the <A HREF="http://en.wikipedia.org/wiki/Cobalt_Networks">Cobalt machines [1]</A> I own).</p>
<p>To solve these problems I first experimented with a wrapper for init.  The idea was to divert the real init to another file name (or use the <B>init=</B> kernel command-line option) and then have the wrapper load the policy before running the real init.  I never intended that to be a real solution, just to demonstrate a point.  Once I had proven that it was possible to load the policy from user-space before running the real init program it was a small step to patch init to do this.</p>
<p>One slightly tricky aspect of this was in getting the correct security context for init.  The policy has always been written to allow a domain transition from <B>kernel_t</B> to <B>init_t</B> when a file of type <B>init_exec_t</B> is executed.  The domain <B>kernel_t</B> is applied to all active processes (including kernel threads) at the time the policy is loaded.  So init only has to re-exec itself to get the correct context.  Fortunately init is designed to do this in the case of an upgrade so this was easy to manage.</p>
<p>Since that time every implementation of SE Linux apart from some embedded systems has used init to load the policy.</p>
<p>The latest trend in Linux distributions seems to be using <A HREF="http://upstart.ubuntu.com/">upstart [2]</A> as a replacement for the old SysV Init.  The Fedora developers decided to make <B>nash</B> (a program that comes from the <B>mkinitrd</B> source tree in Fedora and is a utility program for a Red Hat based initramfs) load the SE Linux policy as it would apparently be painful to patch every init to load the policy.</p>
<p>As far as I am aware there are only three different init programs in common use in Linux, the old SysV Init (which used to be used by everyone), Busybox (for rescuing broken systems and for embedded systems), and now Upstart (used by Ubuntu and Red Hat since Fedora 9).  Embedded systems need to work differently to other systems in many ways (having the one Busybox program supply the equivalent to most coreutils in one binary is actually a small difference compared to the other things), and modifying the policy load process for embedded systems is trivial compared to all the other SE Linux work needed to get an embedded system working well.  There are at least two commonly used initramfs systems (the Debian and Red Hat ones) and probably others.  As one init system (SysV Init) already has SE Linux support it seems that only one needs to be patched to have complete coverage.  I&#8217;ve just written a patch for Upstart (based on the version in Debian/Experimental) and sent it to an Ubuntu developer who&#8217;s interested in such things.  I also volunteer to patch any other init system that is included in Debian (I am aware of minit and will patch it as soon as it&#8217;s description does not include &#8220;<B>this package is experimental and not easy to install and use</B>&#8220;).</p>
<p>It seems to me that repeating the work which was done for SysV Init and upstart for any other init system will be little effort, at worst no greater than patching an initramfs systems (and I&#8217;ll do it).  As the number of initramfs systems that would need to be patched would exceed the number of init systems it seems that less work is involved in patching the init systems.</p>
<p>The amount of RAM required by the initramfs is in some situations a limitation on the use of a system, when I recently did <A HREF="http://etbe.coker.com.au/2008/05/22/xen-and-swap/">some tests on swap performance by reducing the amount of RAM available to a Xen DomU [3]</A> it was the initramfs that limited how small I could go.  So adding extra code to the initramfs is not desired.  While this will be a small amount of code in some situations (when I patched /sbin/init from Upstart it took an extra 64 bytes of disk space on AMD64), dragging in the libraries can take a moderate amount of space (the fact that an LVM or encrypted root filesystem causes SE Linux libraries to be included in the initramfs is something that I consider to be a bug and plan to fix).</p>
<p>Finally not all boot loaders support an initrd or initramfs.  I believe that any decision which prevents using such sweet hardware as Cobalt Qube and Raq machines from being used with SE Linux is a mistake.  I have both Qube and Raq machines running fine with Debian SE Linux and plan to continue making sure that Debian will support SE Linux on such hardware (and anything with similar features and limitations).</p>
<p><UL><br />
<LI>[1] <A HREF="http://en.wikipedia.org/wiki/Cobalt_Networks">http://en.wikipedia.org/wiki/Cobalt_Networks</A></LI><br />
<LI>[2] <A HREF="http://upstart.ubuntu.com/">http://upstart.ubuntu.com/</A></LI><br />
<LI>[3] <A HREF="http://etbe.coker.com.au/2008/05/22/xen-and-swap/">http://etbe.coker.com.au/2008/05/22/xen-and-swap/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=651&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_651" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/07/24/se-linux-policy-loading/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New SE Linux Policy for Lenny</title>
		<link>http://etbe.coker.com.au/2008/07/13/new-se-linux-policy-lenny/</link>
		<comments>http://etbe.coker.com.au/2008/07/13/new-se-linux-policy-lenny/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 12:15:23 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

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

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

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=635</guid>
		<description><![CDATA[I have just uploaded new SE Linux policy packages for Debian/Unstable which will go into Lenny (provided that the FTP masters approve the new packages in time).
The big change is that there are no longer separate packages for strict and targeted policies.  There is now a package named selinux-policy-default which has the features of [...]]]></description>
			<content:encoded><![CDATA[<p>I have just uploaded new SE Linux policy packages for Debian/Unstable which will go into Lenny (provided that the FTP masters approve the new packages in time).</p>
<p>The big change is that there are no longer separate packages for <B>strict</B> and <B>targeted</B> policies.  There is now a package named <B>selinux-policy-default</B> which has the features of both <B>strict</B> and <B>targeted</B>.  When you install it you get the features of <B>targeted</B>.  If you want the strict features then you need to run the following commands as root:</p>
<p><B>semanage login -m -s user_u __default__<br />
semanage login -m -s root root</B></p>
<p>Then you can logout and login and you get the main benefit of the <B>strict</B> policy (users being constrained).  IE you can convert from <B>targeted</B> to <B>strict</B> without a reboot!  The above only changes the access for user login sessions (and cron jobs).  To fully convert to the strict policy you need to remove the <B>unconfined</B> module with the command &#8220;<B>semodule -r unconfined</B>&#8220;, currently that results in a system that doesn&#8217;t boot - I&#8217;m working on this and will have it fixed before Lenny.  Also it&#8217;s possible to have some users unconfined and some restricted in the way that <B>strict</B> policy always did.</p>
<p>When running in the full <B>strict</B> configuration you need to run the command &#8220;<B>newrole -r sysadm_r</B>&#8221; immediately after logging in as root.  When you login you default to <B>staff_r</B> which doesn&#8217;t give you the access needed to perform routine sys-admin tasks.</p>
<p>Due to the change in the function of the policy packages (in terms of not having a strict package) it made sense to revise the naming (Fedora 9 has a package named <B>selinux-policy-targeted</B> which also provides the <B>strict</B> configuration - I don&#8217;t want to do that and don&#8217;t have as much legacy as Fedora).  This is why I decided to not have package names that include the word &#8220;<B>policy</B>&#8221; twice.  Of course all policy packages get new names, but the ones that matter needed new names anyway.</p>
<p>Another new feature is the package <B>selinux-policy-mls</B>, as the name suggests this implements <A HREF="http://en.wikipedia.org/wiki/Multilevel_security">Multi Level Security [1]</A>.  I don&#8217;t expect that the MLS policy will boot in enforcing mode in a regular configuration at this time (you could probably hack it to boot in permissive mode and switch to enforcing mode just before it starts networking).  I uploaded it in this state so that people can start testing it (there is a lot of testing that you can do in permissive mode) and so that it can get added to the package list in time for Lenny.  I expect that I&#8217;ll have it booting shortly (it should not be much more difficult than getting the <B>strict</B> configuration booting).</p>
<p>In terms of the use of MLS, I don&#8217;t expect that anyone will want to pay the money needed for <A HREF="http://en.wikipedia.org/wiki/Labeled_Security_Protection_Profile">LSPP [2]</A> certification.  NB The wikipedia page about LSPP really needs some work.</p>
<p>I believe that the main benefit for having MLS in Debian is for the use of students.  I periodically get requests from students for advice on how to get a job related to military computer security.  Probably the best advice I can offer is to visit the career section of an agency from your government that works on computer security issues, for US readers <A HREF="http://www.nsa.gov/careers/">the NSA careers page is here [3]</A>.  The second best advice I can offer is to work on MLS support in your favourite free OS.  Not only will you learn about technology that is used in military systems but you will also learn a lot about how your OS works as MLS breaks things.  ;)</p>
<p>Finally I&#8217;d like to thank Manoj for all his work.  For a while I didn&#8217;t have time to do much work on SE Linux and he did a lot of good work.  Recently he seems to have been busy on other things and I&#8217;ve had a little more time so I&#8217;m taking over some of it.</p>
<p><UL><br />
<LI>[1] <A HREF="http://en.wikipedia.org/wiki/Multilevel_security">http://en.wikipedia.org/wiki/Multilevel_security</A></LI><br />
<LI>[2] <A HREF="http://en.wikipedia.org/wiki/Labeled_Security_Protection_Profile">http://en.wikipedia.org/wiki/Labeled_Security_Protection_Profile</A></LI><br />
<LI>[3] <A HREF="http://www.nsa.gov/careers/">http://www.nsa.gov/careers/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=635&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_635" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/07/13/new-se-linux-policy-lenny/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is a GPG pass-phrase Useful?</title>
		<link>http://etbe.coker.com.au/2008/07/09/gpg-pass-phrase-useful/</link>
		<comments>http://etbe.coker.com.au/2008/07/09/gpg-pass-phrase-useful/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 21:00:53 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=629</guid>
		<description><![CDATA[Does a GPG pass-phrase provide a real benefit to the majority of users?
It seems that there will be the following categories of attack which result in stealing the secret-key data:

User-space compromise of account (EG exploiting a bug in a web browser or IRC client).
System compromise (EG compromising a local account and exploiting a kernel vulnerability [...]]]></description>
			<content:encoded><![CDATA[<p>Does a GPG pass-phrase provide a real benefit to the majority of users?</p>
<p>It seems that there will be the following categories of attack which result in stealing the secret-key data:<br />
<OL><br />
<LI>User-space compromise of account (EG exploiting a bug in a web browser or IRC client).<br />
<LI>System compromise (EG compromising a local account and exploiting a kernel vulnerability to get root access).<br />
<LI>Theft of the computer system while powered down when the system was configured to not use swap or to encrypt the swap space with a random key at boot time.</LI><br />
<LI>Theft of a computer system while running or that did not have encrypted swap.</LI><br />
<LI>Theft of unencrypted backup media.</LI><br />
</OL></p>
<p>Category 1 will permit an attacker to monitor user processes and intercept one that asks for a GPG pass-phrase as well as to copy the secret key.  Category 2 will do the same but for all users on the system.</p>
<p>Category 3 will give the potential for stealing the private key (if it&#8217;s not encrypted) but no direct potential for getting the pass-phrase.</p>
<p>Category 4 has the potential for copying a pass-phrase from memory or swap.  I am inclined to trust Werner Koch (and anyone else who submitted code to the GPG project) to have written code to correctly lock memory and scrub pass-phrase data and decrypted private key data from memory after use.  But I really doubt the ability of most people who write code to interface with GPG to do the same.  So every time that a GUI program prompts for a GPG pass-phrase I think that there is the potential for it to be stored in swap or to remain indefinitely in RAM.  Therefore stealing a machine that does not have it&#8217;s swap-space encrypted with a random key (which is the most practical way of encrypting swap) or stealing a running machine (<A HREF="http://etbe.coker.com.au/2008/02/17/hot-plug-and-how-to-defeat-it/">as mentioned in a previous post [1]</A>) can potentially grant a hostile party access to the pass-phrase.</p>
<p>So it seems to me that out of all the possible ways of getting access to a GPG private key, the only ones where a pass-phrase ones is going to really do some good are categories 3 and 5.  While it&#8217;s good to protect against those situations, it seems to me that the greatest risk to a GPG key is from category 1, with category 2 following close behind.</p>
<p><A HREF="http://etbe.coker.com.au/2008/06/06/se-linux-support-gpg/">I previously wrote about the slow progress towards using SE Linux and GPG code changes to make it more difficult to steal the secret key [2]</A> - something that I&#8217;ve been occasionally working on over the last 6 years.</p>
<p>Now it seems to me that the same benefits can and should be made available to people who don&#8217;t use SE Linux.  If a system directory such as <B>/var/spool/gpg</B> was mode 1770 then gpg could be setgid to group &#8220;gpg&#8221; so that it could create and access secret keys for users under /var/spool/gpg while the users in question could not directly access them.  Then the sys-admin would be responsible for backing up GPG keys.  Of course it would probably be ideal to have an option as to whether a new secret key would be created in the system spool or in the user home directory, and migrating the key from the user home directory to the system spool would be supported (but not migrating it back).</p>
<p>This would mean that an attacker who compromised a local user account (maybe through a vulnerability in a web browser or MUA) would not be able to get the GPG secret key.  They could probably get the pass-phrase by ptracing the MUA (or some other GUI process that calls GPG) but without the secret key itself that would not do as much good - of course once they had the pass-phrase and local access they could use the machine so sign and decrypt data which would still be a bad thing.  But it would not have the same scope as stealing the secret key and the pass-phrase.</p>
<p>I look forward to reading comments on this post.</p>
<p><UL><br />
<LI>[1] <A HREF="http://etbe.coker.com.au/2008/02/17/hot-plug-and-how-to-defeat-it/">http://etbe.coker.com.au/2008/02/17/hot-plug-and-how-to-defeat-it/</A></LI><br />
<LI>[2] <A HREF="http://etbe.coker.com.au/2008/06/06/se-linux-support-gpg/">http://etbe.coker.com.au/2008/06/06/se-linux-support-gpg/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=629&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_629" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/07/09/gpg-pass-phrase-useful/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Kernel Security vs Uptime</title>
		<link>http://etbe.coker.com.au/2008/06/27/kernel-security-vs-uptime/</link>
		<comments>http://etbe.coker.com.au/2008/06/27/kernel-security-vs-uptime/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 21:00:08 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Ha]]></category>

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

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=622</guid>
		<description><![CDATA[For best system security you want to apply kernel security patches ASAP.  For an attacker gaining root access to a machine is often a two step process, the first step is to exploit a weakness in a non-root daemon or take over a user account, the second step is to compromise the kernel to [...]]]></description>
			<content:encoded><![CDATA[<p>For best system security you want to apply kernel security patches ASAP.  For an attacker gaining root access to a machine is often a two step process, the first step is to exploit a weakness in a non-root daemon or take over a user account, the second step is to compromise the kernel to gain root access.  So even if a machine is not used for providing public shell access or any other task which involves giving user access to potential hostile people, having the kernel be secure is an important part of system security.</p>
<p>One thing that gets little consideration is the overall effect of applying security updates on overall uptime.  Over the last year there have been 14 security related updates (I count a silent data loss along with security issues) to the main Debian Etch kernel package.  Of those 14, it seems that if you don&#8217;t use DCCP, NAT for CIFS or SNMP, IA64, the dialout group,  then you will only need to patch for issues 2, 3 (for SMP machines), 4, 5, 7 (sound drivers get loaded on all machines by default), 9, 10, 11, 12, 13, and 14.</p>
<p>This means 11 reboots a year for SMP machines and 10 a year for uni-processor machines.  If a reboot takes three minutes (which is an optimistic assumption) then that would be 30 or 33 minutes of downtime a year due to kernel upgrades.  In terms of uptime we talk about the number of &#8220;nines&#8221;, where the ideal is generally regarded as &#8220;five nines&#8221; or 99.999% uptime.  33 minutes of downtime a year for kernel upgrades means that you get 99.993% uptime (which is &#8220;four nines&#8221;).  If a reboot takes six minutes (which is not uncommon for servers) then it&#8217;s 99.987% uptime (&#8221;thee nines&#8221;).</p>
<p>While it doesn&#8217;t seem likely to affect the number of &#8220;nines&#8221; you get, not using SMP has the potential to avoid future security issues.  So it seems that when using a Xen (or other virtualisation technology) assigning only one CPU to the DomUs that don&#8217;t need any more could improve uptime for them.</p>
<p>For Xen Dom0&#8217;s which don&#8217;t have local users or daemons, don&#8217;t use DCCP, NAT for CIFS or SNMP, wireless, CIFS, JFFS2, PPPoE, bluetooth, H.323 or SCTP connection tracking, then only issue 11 applies.  However for &#8220;five nines&#8221; you need to have 5 minutes of downtime a year or less.  It seems unlikely that a busy Xen server can be rebooted in 5 minutes as all the DomUs need to have their memory saved to disk (writing out the data to disk and reading it back in after a reboot will probably take at least a couple of minutes) or they need to be shutdown and booted again after the Dom0 is rebooted (which is a good procedure if the security fix affects both Dom0 and DomU use), and such shutdowns and reboots of DomU&#8217;s will take a lot of time.</p>
<p>Based on the past year, it seems that a system running as a basic server might get &#8220;four nines&#8221; if configured for a fast boot (it&#8217;s surprising that no-one seems to be talking about recent improvements to the speed of booting as high-availability features) and if the boot is slower then you are looking at &#8220;three nines&#8221;.  For a Xen server unless you have some sort of cluster it seems that &#8220;five nines&#8221; is unattainable due to reboot times if there is one issue a year, but &#8220;four nines&#8221; should be easy to get.</p>
<p>Now while the 14 issues over the last year for the kernel seems likely to be a pattern that will continue, the one issue which affects Xen may not be representative (small numbers are not statistically significant).  I feel confident in predicting a need for between 5 and 20 kernel updates next year due to kernel security issues, but I would not be prepared to bet on whether the number of issues affecting Xen will be 0, 1, or 4 (it seems unlikely that there would be 5 or more).</p>
<p>I will write a future post about some strategies for mitigating these issues.</p>
<p>Here is my summary of the Debian kernel linux-image-2.6.18-6-686 (Etch kernel) security updates according to it&#8217;s changelog, they are not in chronological order, it&#8217;s the order of the changelog file:<br />
<span id="more-622"></span><br />
<OL><br />
<LI>05 Jun 2008: CVE-2008-2358 for DCCP and CVE-2008-1673 for ASN.1 (NAT for CIFS and SNMP).</LI><br />
<LI>23 May 2008: CVE-2008-2136 memory leak in IPv6 over IPv4 tunnels, CVE-2007-6712 timer related bugs, CVE-2008-1615 ptrace on AMD64 architecture, and CVE-2008-2137 &#8220;Validate address ranges regardless of MAP_FIXED&#8221;.</LI><br />
<LI>07 May 2008: CVE-2008-1669 SMP race</LI><br />
<LI>11 Apr 2008: CVE-2007-6694 PPC only, CVE-2008-0007 Add VM_DONTEXPAND to vm_flags in drivers that register a fault handler but do not bounds check the offset argument, CVE-2008-1294 prevent user escape from RLIMIT_CPU, and CVE-2008-1375 fix dnotify race.</LI><br />
<LI>10 Feb 2008: CVE-2008-0010 and CVE-2008-0600 Fix missing access check in vmsplice.</LI><br />
<LI>25 Jan 2008: Not a security issue, but silent data loss on IA64.</LI><br />
<LI>22 Jan 2008: CVE-2007-6151 ISDN memory overrun, CVE-2008-0001 something related to checking the access to a directory, CVE-2007-2878 FAT filesystem related, CVE-2007-4571 ALSA bug that allows user to read kernel memory.</LI><br />
<LI>17 Sep 2007: Fix minor DOS attack for slightly privileged users (EG members of dialout group).</LI><br />
<LI>18 Dec 2007: CVE-2007-6063 overflows in ISDN subsystem, CVE-2007-6206 core dumping over an existing file can get the wrong ownership (<A HREF="http://etbe.coker.com.au/2007/01/05/core-files/">should be possible to use kernel.core_pattern to work around this [1]</A>), CVE-2007-5966 timer issue, CVE-2006-6058 Minix fs DOS attack via corrupted fs, and CVE-2007-6417 tmpfs memory leak.</LI><br />
<LI>29 Nov 2007: CVE-2007-3104 local kernel DOS attack (Oops), CVE-2007-4997 malicious frame on wireless interface crashes system, CVE-2007-5500 potential system hang, and CVE-2007-5904 CIFS overflows from server sending corrupt data.</LI><br />
<LI>02 Oct 2007: CVE-2007-4573 Xen 64bit with 32bit DomU, CVE-2006-5755 Xen, CVE-2007-4133 memory management DOS, and CVE-2007-5093 DOS when unplugging a webcam that is in use.</LI><br />
<LI>25 Sep 2007: CVE-2007-3731 ptrace causing Oops, CVE-2007-3739 memory management Oops, CVE-2007-3740 CIFS not honoring umask, CVE-2007-4573 ptrace of 32bit process on AMD64 bug, and CVE-2007-4849 JFFS2 (flash media) filesystem bug.</LI><br />
<LI>27 Aug 2007: CVE-2007-2172 IPv4 memory related issue (local DOS or compromise?), CVE-2007-2875 local user can read kernel memory if cpuset filesystem is mounted, CVE-2007-3105 buffer overflow in random number generator, CVE-2007-3843 CIFS, and CVE-2007-4308 AAC RAID.</LI><br />
<LI>11 Aug 2007: CVE-2007-1353 bluetooth, CVE-2007-3513 usblcd, CVE-2007-2525 PPPoE, CVE-2007-3642 H.323 connection tracking, CVE-2007-2172 IPv4 local exploit, CVE-2007-2453 slightly less random numbers, CVE-2007-2876 SCTP connection tracking, CVE-2007-3851 i965 batch buffer usage, and CVE-2007-3848 potential privilege escalation.</LI><br />
</OL></p>
<p><UL><br />
<LI>[1] <A HREF="http://etbe.coker.com.au/2007/01/05/core-files/">http://etbe.coker.com.au/2007/01/05/core-files/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=622&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_622" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/06/27/kernel-security-vs-uptime/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SE Linux Support in GPG</title>
		<link>http://etbe.coker.com.au/2008/06/06/se-linux-support-gpg/</link>
		<comments>http://etbe.coker.com.au/2008/06/06/se-linux-support-gpg/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 03:00:27 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Best Posts]]></category>

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

		<category><![CDATA[Most Popular]]></category>

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

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=604</guid>
		<description><![CDATA[In May 2002 I had an idea for securing access to GNUPG [1].  What I did was to write SE Linux policy to only permit the gpg program to access the secret key (and other files in ~/.gnupg).  This meant that the most trivial ways of stealing the secret key would be prevented. [...]]]></description>
			<content:encoded><![CDATA[<p>In May 2002 I had an idea for securing access to <A HREF="http://www.gnupg.org/">GNUPG [1]</A>.  What I did was to write SE Linux policy to only permit the gpg program to access the secret key (and other files in <B>~/.gnupg</B>).  This meant that the most trivial ways of stealing the secret key would be prevented.  However an attacker could still use gpg to encrypt it&#8217;s secret key and write the data to some place that is accessible, for example the command &#8220;<B>gpg -c &#45;-output /tmp/foo.gpg ~/.gnupg/secring.gpg</B>&#8220;.  So what we needed was for gpg to either refuse to encrypt such files, or to spawn a child process for accessing such files (which could be granted different access to the filesystem).  I filed the Debian bug report <A HREF="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=146345">146345 [2]</A> requesting this feature.</p>
<p>In March upstream added this feature, the Debian package is currently not built with &#45;-enable-selinux-support so this feature isn&#8217;t enabled yet, but hopefully it will be soon.  Incidentally the feature as currently implemented is not really SE Linux specific, it seems to me that there are many potential situations where it could be useful without SE Linux.  For example if you were using one of the path-name based MAC systems (which I dislike - see <A HREF="http://securityblog.org/brindle/2006/04/19/security-anti-pattern-path-based-access-control/">what my friend Joshua Brindle wrote about them for an explanation [3]</A>) then you could gain some benefits from this.  A situation where there is even smaller potential for benefit is in the case of an automated system which runs gpg which could allow an attacker to pass bogus commands to it.  When exploiting a shell script it might be easier to specify the wrong file to encrypt than to perform more sophisticated attacks.</p>
<p>When the feature in question is enabled the command &#8220;<B>gpg -c &#45;-output /tmp/foo.gpg ~/.gnupg/secring.gpg</B>&#8221; will abort with the following error:<br />
<B>gpg: can&#8217;t open `/root/.gnupg/secring.gpg&#8217;: Operation not permitted<br />
gpg: symmetric encryption of `/root/.gnupg/secring.gpg&#8217; failed: file open error</B></p>
<p>Of course the command &#8220;<B>gpg &#45;-export-secret-keys</B>&#8221; will abort with the following error:<br />
<B>gpg: exporting secret keys not allowed<br />
gpg: WARNING: nothing exported</B></p>
<p>Now we need to determine the correct way of exporting secret keys and modifying the GPG configuration.  It might be best to allow exporting the secret keys when not running SE Linux (or other supported MAC systems), or when running in permissive mode (as in those situations merely copying the files will work).  Although we could have an option in gpg.conf for this for the case where we want to prevent shell-script quoting hacks.</p>
<p>For editing the gpg.conf file and exporting the secret keys we could have a program similar in concept to crontab(1) which has PAM support to determine when it should perform it&#8217;s actions.  Also it seems to me that crontab(1) could do with PAM support (I&#8217;ve filed Debian bug report <A HREF="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484743">484743 [4]</A> requesting this).</p>
<p>Finally one thing that should be noted is that the <B>targeted</B> policy for SE Linux does not restrict GPG (which runs in the <B>unconfined_t</B> domain).  Thus most people who use SE Linux at the moment aren&#8217;t getting any benefits from such things.  This will change eventually.</p>
<p><UL><br />
<LI>[1] <A HREF="http://www.gnupg.org/">http://www.gnupg.org/</A></LI><br />
<LI>[2] <A HREF="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=146345">http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=146345</A></LI><br />
<LI>[3] <A HREF="http://securityblog.org/brindle/2006/04/19/security-anti-pattern-path-based-access-control/">http://securityblog.org/brindle/2006/04/19/security-anti-pattern-path-based-access-control/</A></LI><br />
<LI>[4] <A HREF="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484743">http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484743</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=604&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_604" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/06/06/se-linux-support-gpg/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IPSEC is Pain</title>
		<link>http://etbe.coker.com.au/2008/05/24/ipsec-is-pain/</link>
		<comments>http://etbe.coker.com.au/2008/05/24/ipsec-is-pain/#comments</comments>
		<pubDate>Sat, 24 May 2008 13:48:06 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=592</guid>
		<description><![CDATA[I&#8217;ve been trying to get ipsec to work correctly as a basic VPN between two CentOS 5 systems.  I set up the ipsec devices according to the IPSEC section of the RHEL4 security guide [1] (which is the latest documentation available and it seems that nothing has changed since).  The documentation is quite [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been trying to get ipsec to work correctly as a basic VPN between two CentOS 5 systems.  I set up the ipsec devices according to <A HREF="http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/security-guide/s1-ipsec-net2net.html">the IPSEC section of the RHEL4 security guide [1]</A> (which is the latest documentation available and it seems that nothing has changed since).  The documentation is quite good, but getting IPSEC working is really difficult.  One thing I really don&#8217;t like about IPSEC is the way that it doesn&#8217;t have a device, I prefer to have my VPN have it&#8217;s own device so that I can easily run tcpdump on the encrypted or the unencrypted stream (or two separate tcpdump sessions) if that&#8217;s necessary to discover the cause of the problem).</p>
<p>I&#8217;ve got IPSEC basically working, and I probably could get it working fully, but it doesn&#8217;t seem worth the effort.</p>
<p>While fighting with IPSEC at the more complex site (multiple offices which each have multiple networks, and switching paths to route around unreliable networks) I set up an IPSEC installation at a very simple site (two offices within 200 meters both with static public IP addresses, no dynamic routing or anything else complex).  The simple site STILL doesn&#8217;t work as well as desired, one issue that still concerns me is the arbitrary MTU sizes in some routing gear which (for some reason I haven&#8217;t diagnosed yet) lose packets if I have an MTU over 1470 bytes.</p>
<p>So today I set up a test network with <A HREF="http://openvpn.net/index.php/documentation/howto.html">OpenVPN [2]</A>.  It was remarkably simple, the server config file (/etc/openvpn/server.conf) is as follows:<br />
<B>dev tun<br />
ifconfig 10.8.0.1 10.8.0.2<br />
secret static.key<br />
comp-lzo</B></p>
<p>This means that the IP address 10.8.0.1 will be used for the &#8220;server&#8221; end of the tunnel, and 10.8.0.2 is the &#8220;client&#8221; end.  The secret is stored in /etc/openvpn/static.key (which is the same on both machines and is generated by &#8220;<B>openvpn &#45;-genkey &#45;-secret static.key</B>&#8220;).</p>
<p>The client config file (/etc/openvpn/client.conf) is as follows:<br />
<B>remote 10.5.0.2<br />
dev tun<br />
ifconfig 10.8.0.2 10.8.0.1<br />
secret static.key<br />
comp-lzo</B></p>
<p>Then I enable IP forwarding on both VPN machines, open UDP port 1194 (the command &#8220;<B>lokkit -q -p 1194:udp</B>&#8221; does this) and start the daemon on each end.  The script <B>/etc/init.d/openvpn</B> (in Dag Wieers package for CentOS 5 - which I believe is the standard script) will just take every file matching <B>/etc/openvpn/*.conf</B> as a service to start.</p>
<p>The end result is a point to point link that I can easily route other packets to, I can easily get dynamic routing daemons to add routes pointing to it. Nothing like the IPSEC configuration where the config file needs to have the IP address range hard-coded, I can just add routes whenever I want.</p>
<p>This isn&#8217;t necessarily going to be the way I deploy it.  The documentation notes that a disadvantage is &#8220;<B>lack of perfect forward secrecy &#8212; key compromise results in total disclosure of previous sessions</B>&#8220;.  But what gives me confidence is the fact that it was so easy to get it going, if I have problems in adding further features to the configuration it should be easy to debug.  As opposed to IPSEC where it&#8217;s all complex and if it doesn&#8217;t work then it&#8217;s all pain.</p>
<p>Also I tested this out with four Xen DomU&#8217;s, two running as VPN routers and two as clients on separate segments of the VPN.  They were connected with three bridge devices.  I&#8217;ll blog about how to set this up if there is interest.</p>
<p><UL><br />
<LI>[1] <A HREF="http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/security-guide/s1-ipsec-net2net.html">http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/security-guide/s1-ipsec-net2net.html</A></LI><br />
<LI>[2] <A HREF="http://openvpn.net/index.php/documentation/howto.html">http://openvpn.net/index.php/documentation/howto.html</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=592&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_592" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/05/24/ipsec-is-pain/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Security Flaws in Free Software</title>
		<link>http://etbe.coker.com.au/2008/05/21/security-flaws-in-free-software/</link>
		<comments>http://etbe.coker.com.au/2008/05/21/security-flaws-in-free-software/#comments</comments>
		<pubDate>Wed, 21 May 2008 12:00:10 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Best Posts]]></category>

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

		<category><![CDATA[Most Popular]]></category>

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=585</guid>
		<description><![CDATA[I just wrote about the system administration issues related to the recent Debian SSL/SSH security flaw [1].  The next thing we need to consider is how we can change things to reduce the incidence of such problems.
The problem we just had was due to the most important part of the entropy supply for the [...]]]></description>
			<content:encoded><![CDATA[<p><A HREF="http://etbe.coker.com.au/2008/05/18/debian-ssh-problems/">I just wrote about the system administration issues related to the recent Debian SSL/SSH security flaw [1]</A>.  The next thing we need to consider is how we can change things to reduce the incidence of such problems.</p>
<p>The problem we just had was due to the most important part of the entropy supply for the random number generator not being used due to a mistake in commenting out some code.  The only entropy that was used was the PID number of the process which uses the SSL library code which gives us 15 bits of entropy.  It seems to me that if we had zero bits of entropy the problem would have been discovered a lot sooner (almost certainly before the code was released in a stable version).  Therefore it seems that using a second-rate source of entropy (which was never required) masked the problem that the primary source of entropy was not working.  Would it make sense to have a practice of not using such second-rate sources of entropy to reduce the risk of such problems being undetected for any length of time?  Is this a general issue or just a corner case?</p>
<p><A HREF="http://np237.livejournal.com/17981.html">Joss makes some suggestions for process improvements [2]</A>.  He suggests that having a single .diff.gz file (the traditional method for maintaining Debian packages) that directly contains all patches can obscure some patches.  The other extreme is when you have a patch management system with several dozen small patches and the reader has to try and discover what each of them does.   For an example of this see the 43 patches which are included in the Debian PAM package for Etch, also note that the PAM system is comprised of many separate shared objects (modules), this means that the patching system lends itself to having one patch per module and thus 43 patches for PAM isn&#8217;t as difficult to manage as 43 patches for a complex package which is not comprised of multiple separate components  might be.  That said I think that there is some potential for separating out patches.  Having a distinction between different types of patches might help.  For example we could have a patch for Makefiles etc (including autoconf etc), a patch for adding features, and a patch for fixing bugs.  Then people reviewing the source for potential bugs could pay a lot of attention to bug fixes, a moderate amount of attention to new features, and casually skim the Makefile stuff.</p>
<p>The <A HREF="http://marc.info/?t=114651088900003&#038;r=1&#038;w=2">problem began with this mailing list discussion [3]</A>.  Kurt&#8217;s first message starts with &#8220;<B>When debbuging applications</B>&#8221; and ends with &#8220;<B>What do you people think about removing those 2 lines of code?</B>&#8220;.  The reply he received from Ulf (a member of the OpenSSL development team) is &#8220;<B>If it helps with debugging, I&#8217;m in favor of removing them</B>&#8220;.  It seems to me that there might have been a miscommunication there, Ulf may have believed that the discussion only concerned a debugging built and not a build that would eventually end up on millions of machines.</p>
<p>It seems possible that the reaction would have been different if Kurt had mentioned that he wanted to have a single source tree for both debugging and for regular use.  It also seems likely that his proposed change may have received more inspection if he had clearly stated that he was doing to include it in Debian where it would be used by millions of people.  When I am doing Debian development I generally don&#8217;t mention all the time &#8220;<B>this code will be used by millions of people so it&#8217;s important that we get it right</B>&#8220;, although I do sometimes make such statements if I feel that my questions are not getting the amount of consideration from upstream that a binary package destined for use by millions of people deserves.  Maybe it would be a good practice to clarify such things in the case of important packages.  For a package that is relevant to the security of the entire distribution (and possibly to other machines around the net - as demonstrated in this case) it doesn&#8217;t seem unreasonable to include a post-script mentioning the scope of the code use (it could be done with an alternate SIG if using a MUA that allows selecting from multiple SIGs in a convenient manner).</p>
<p>In <A HREF="http://www.links.org/?p=328">the response from the OpenSSL upstream [4]</A> it is claimed that the mailing list used was not the correct one.  <A HREF="http://advogato.org/person/branden/diary/5.html">Branden points out that the openssl-team mailing list address seems not to be documented anywhere [5]</A>.  One thing to be learned from this is that distribution developers need to be proactive in making contact with upstream developers.  You might think that building packages for a major distribution and asking questions about it on the mailing list would result in someone from the team noticing and mentioning any other things that you might need to do.  But maybe it would make sense to send private mail to one of the core developers, introduce yourself, and ask for advice on the best way to manage communication to avoid this type of confusion.</p>
<p>I think that it is ideal for distribution developers to have the phone numbers of some of the upstream developers.  If the upstream work is sponsored by the employer of one of the upstream developers then it seems reasonable to ask for their office phone number.  Sometimes it&#8217;s easier to sort things out by phone than by email.</p>
<p><A HREF="http://gwolf.org/node/1743">Gunnar Wolf describes how the way this bug was discovered and handled shows that the Debian processes work [6]</A>.  A similar bug in proprietary software would probably not be discovered nearly as quickly and would almost certainly not be fixed in such a responsible manner.</p>
<p>Update: <A HREF="http://www.openssl.org/about/">According to the OpenSSL project about page [7]</A>, Ulf is actually not a &#8220;core&#8221; member, just a team member.  I had used the term &#8220;core&#8221; in a slang manner based on the fact that Ulf has an official @openssl.org email address.</p>
<p><UL><br />
<LI>[1] <A HREF="http://etbe.coker.com.au/2008/05/18/debian-ssh-problems/">http://etbe.coker.com.au/2008/05/18/debian-ssh-problems/</A></LI><br />
<LI>[2] <A HREF="http://np237.livejournal.com/17981.html">http://np237.livejournal.com/17981.html</A></LI><br />
<LI>[3] <A HREF="http://marc.info/?t=114651088900003&#038;r=1&#038;w=2">http://marc.info/?t=114651088900003&#038;r=1&#038;w=2</A></LI><br />
<LI>[4] <A HREF="http://www.links.org/?p=328">http://www.links.org/?p=328</A></LI><br />
<LI>[5] <A HREF="http://advogato.org/person/branden/diary/5.html">http://advogato.org/person/branden/diary/5.html</A></LI><br />
<LI>[6] <A HREF="http://gwolf.org/node/1743">http://gwolf.org/node/1743</A></LI><br />
<LI>[7] <A HREF="http://www.openssl.org/about/">http://www.openssl.org/about/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=585&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_585" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/05/21/security-flaws-in-free-software/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Debian SSH Problems</title>
		<link>http://etbe.coker.com.au/2008/05/18/debian-ssh-problems/</link>
		<comments>http://etbe.coker.com.au/2008/05/18/debian-ssh-problems/#comments</comments>
		<pubDate>Sun, 18 May 2008 08:02:20 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Best Posts]]></category>

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

		<category><![CDATA[Most Popular]]></category>

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=583</guid>
		<description><![CDATA[It has recently been announced that Debian had a serious bug in the OpenSSL code [1], the most visible affect of this is compromising SSH keys - but it can also affect VPN and HTTPS keys.  Erich Schubert was one of the first people to point out the true horror of the problem, only [...]]]></description>
			<content:encoded><![CDATA[<p><A HREF="http://www.debian.org/security/2008/dsa-1571">It has recently been announced that Debian had a serious bug in the OpenSSL code [1]</A>, the most visible affect of this is compromising SSH keys - but it can also affect VPN and HTTPS keys.  <A HREF="http://blog.drinsama.de/erich/en/linux/2008051401-consequences-of-sslssh-weakness.html">Erich Schubert was one of the first people to point out the true horror of the problem, only 2^15 different keys can be created [2]</A>.  It should not be difficult for an attacker to generate 2^15 host keys to try all combinations for decrypting a login session.  It should also be possible to make up to 2^15 attempts to login to a session remotely if an attacker believes that an authorized key was being used - that would take less than an hour at a rate of 10 attempts per second (which is possible with modern net connections) and could be done in a day if the server was connected to the net by a modem.</p>
<p><A HREF="http://changelog.complete.org/posts/714-Thoughtfulness-on-the-OpenSSL-bug.html">John Goerzen has some insightful thoughts about the issue [3].</A>  I recommend reading his post.  One point he makes is that the person who made the mistake in question should not be lynched.  One thing I think we should keep in mind is the fact that people tend to be more careful after they have made mistakes, I expect that anyone who makes a mistake in such a public way which impacts so many people will be very careful for a long time&#8230;</p>
<p><A HREF="http://blog.sesse.net/blog/tech/2008-05-14-17-21_some_maths.html">Steinar H. Gunderson analyses the maths in relation to DSA keys, it seems that if a DSA key is ever used with a bad RNG then it can be cracked by someone who sniffs the network [4]</A>.  It seems that it is safest to just not use DSA to avoid this risk.  Another issue is that if a client supports multiple host keys (ssh version 2 can use three different key types, one for the ssh1 protocol, one for ssh2 with RSA, and one for ssh2 with DSA) then a man in the middle attack can be implemented by forcing a client to use a different key type - <A HREF="http://www.phrack.org/issues.html?id=11&#038;issue=59">see Stealth&#8217;s article in Phrack for the details [5]</A>.  So it seems that we should remove support for anything other than SSHv2 with RSA keys.</p>
<p>To remove such support from the ssh server edit <B>/etc/ssh/sshd_config</B> and make sure it has a line with &#8220;<B>Protocol 2</B>&#8220;, and that the only <B>HostKey</B> line references an RSA key.  To remove it from the ssh client (the important thing) edit <B>/etc/ssh/ssh_config</B> and make sure that it has something like the following:</p>
<p>Host *<br />
 Protocol 2<br />
 HostKeyAlgorithms ssh-rsa<br />
 ForwardX11 no<br />
 ForwardX11Trusted no</p>
<p>You can override this for different machines.  So if you have a machine that uses DSA only then it would be easy to add a section:</p>
<p>Host strange-machine<br />
 Protocol 2<br />
 HostKeyAlgorithms ssh-dsa</p>
<p>So making the default configuration of the ssh client on all machines you manage has the potential to dramatically reduce the incidence of MITM attacks from the less knowledgable users.</p>
<p>When skilled users who do not have root access need to change things they can always edit the file <B>~/.ssh/config</B> (which has the same syntax as <B>/etc/ssh/ssh_config</B>) or they can use command-line options to override it.  The command <B>ssh -o &#8220;HostKeyAlgorithms ssh-dsa&#8221; user@server</B> will force the use of DSA encryption even if the configuration file requests RSA.</p>
<p><A HREF="http://www.enricozini.org/2008/tips/ssh-host-key-fingerprint.html">Enrico Zini describes how to use <B>ssh-keygen</B> to get the fingerprint of the host key [6]</A>.  One thing I have learned from comments on this post is how to get a fingerprint from a known hosts file.  A common situation is that machine A has a known hosts file with an entry for machine B.  I want to get the right key in machine C and there is no way of directly communicating between machine A and machine C (EG they are in different locations with no network access).  In that situation the command &#8220;<B>ssh-keygen -l -f ~/.ssh/known_hosts</B>&#8221; can be used to display all the fingerprints of hosts that you have connected to in the past, then it&#8217;s a simple matter of grepping the output.</p>
<p><A HREF="http://www.docunext.com/blog/2008/05/14/my-security/">Docunext has an interesting post about ways of mitigating such problems [7]</A>.  One thing that they suggest is using fail2ban to block IP addresses that appear to be trying to do brute-force attacks.  It&#8217;s unfortunate that the version of fail2ban in Debian uses <B>/tmp/fail2ban.sock</B> for it&#8217;s Unix domain socket for talking to the server (the version in Unstable uses <B>/var/run/fail2ban/fail2ban.sock</B>).  They also mention patching network drivers to add entropy to the kernel random number generator.  One thing that seems interesting is the package <B>randomsound</B> (currently in Debian/Unstable) which takes ALSA sound input as a source of entropy, note that you don&#8217;t need to have any sound input device connected.</p>
<p>When considering fail2ban and similar things, it&#8217;s probably best to start by restricting the number of machines which can connect to your SSH server.  Firstly if you put it on a non-default port then it&#8217;ll take some brute-force to find it.  This will waste some of the attacker&#8217;s time and also make the less persistent attackers go elsewhere.  One thing that I am considering is having a few unused ports configured such that any IP address which connects to them gets added to my NetFilter configuration - if you connect to such ports then you can&#8217;t connect to any other ports for a week (or until the list becomes too full).  So if for example I had port N configured in such a manner and port N+100 used for ssh listening then it&#8217;s likely that someone who  port-scans my server would be blocked before they even discovered the SSH server.  Does anyone know of free software to do this?</p>
<p>The next thing to consider is which IP addresses may connect.  If you were to allow all the IP addresses from all the major ISPs in your country to connect to your server then it would still be a small fraction of the IP address space.  Sure attackers could use machines that they already cracked in your country to launch their attacks, but they would have to guess that you had such a defense in place, and even so it would be an inconvenience for them.  You don&#8217;t necessarily need to have a perfect defense, you only need to make the effort to reward ratio be worse for attacking you than for attacking someone else.  Note that I am not advocating taking a minimalist approach to security, merely noting that even a small increment in the strength of your defenses can make a significant difference to the risk you face.</p>
<p>Update: based on comments I&#8217;m now considering knockd to open ports on demand.  The <A HREF="http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki">upstream site for knockd is here [8]</A>, and <A HREF="http://www.ducea.com/2006/07/05/how-to-safely-connect-from-anywhere-to-your-closed-linux-firewall/">some documentation on setting it up in Debian is here [9]</A>.  The concept of knockd is that you make connections to a series of ports which act as a password for changing the firewall rules.  An attacker who doesn&#8217;t know those port numbers won&#8217;t be able to connect.  Of course anyone who can sniff your network will discover the ports soon enough, but I guess you can always login and change the port numbers once knockd has let you in.</p>
<p>Also thanks to Helmut for advice on ssh-keygen.</p>
<p><UL><br />
<LI>[1] <A HREF="http://www.debian.org/security/2008/dsa-1571">http://www.debian.org/security/2008/dsa-1571</A></LI><br />
<LI>[2] <A HREF="http://blog.drinsama.de/erich/en/linux/2008051401-consequences-of-sslssh-weakness.html">http://blog.drinsama.de/erich/en/linux/2008051401-consequences-of-sslssh-weakness.html</A></LI><br />
<LI>[3] <A HREF="http://changelog.complete.org/posts/714-Thoughtfulness-on-the-OpenSSL-bug.html">http://changelog.complete.org/posts/714-Thoughtfulness-on-the-OpenSSL-bug.html</A></LI><br />
<LI>[4] <A HREF="http://blog.sesse.net/blog/tech/2008-05-14-17-21_some_maths.html">http://blog.sesse.net/blog/tech/2008-05-14-17-21_some_maths.html</A></LI><br />
<LI>[5] <A HREF="http://www.phrack.org/issues.html?id=11&#038;issue=59">http://www.phrack.org/issues.html?id=11&#038;issue=59</A></LI><br />
<LI>[6] <A HREF="http://www.enricozini.org/2008/tips/ssh-host-key-fingerprint.html">http://www.enricozini.org/2008/tips/ssh-host-key-fingerprint.html</A></LI><br />
<LI>[7] <A HREF="http://www.docunext.com/blog/2008/05/14/my-security/">http://www.docunext.com/blog/2008/05/14/my-security/</A></LI><br />
<LI>[8] <A HREF="http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki">http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki</A></LI><br />
<LI>[9] <A HREF="http://www.ducea.com/2006/07/05/how-to-safely-connect-from-anywhere-to-your-closed-linux-firewall/">http://www.ducea.com/2006/07/05/how-to-safely-connect-from-anywhere-to-your-closed-linux-firewall/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=583&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_583" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/05/18/debian-ssh-problems/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Trust and My SE Linux Play Machine</title>
		<link>http://etbe.coker.com.au/2008/04/03/trust-and-play-machine/</link>
		<comments>http://etbe.coker.com.au/2008/04/03/trust-and-play-machine/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 03:35:31 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Best Posts]]></category>

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

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=554</guid>
		<description><![CDATA[When discussing the machine there are two common comments I get.  One is a suggestion that I am putting myself at risk, I think that the risk of visiting random web sites is significantly greater.  Another is a challenge to put the machine on my internal network if I really trust SE Linux, as noted I have made mistakes in the past and there have been Linux kernel bugs - but apart from that it's always best to have multiple layers of protection.]]></description>
			<content:encoded><![CDATA[<p>Currently my <A HREF="http://www.coker.com.au/selinux/play.html">SE Linux Play Machine [1]</A> is running as a Xen DomU.  So if someone cracks it they would also have to crack Xen to get access to directly change things on the hardware (EG modifying the boot process).  As <A HREF="http://etbe.coker.com.au/2008/04/02/se-linux-play-machine-passwords/">documented in my last post [2]</A> a user of my Play Machine recently managed to change my password.  Of course this was just two days after the <A HREF="http://www.avertlabs.com/research/blog/index.php/2008/02/13/analyzing-the-linux-kernel-vmsplice-exploit/">vmsplice() kernel security flaw had been discovered [3]</A>.  Of course any machine that offers shell access to remote users (or the ability to run CGI-BIN scripts or other programs that users can upload) is immediately vulnerable to such exploits and while <A HREF="http://doc.coker.com.au/computers/se-linux-saves/">SE Linux has blocked local kernel exploits in the past [4]</A> there will always be the possibility of kernel exploits that SE Linux can&#8217;t block or which can be re-written to work in a way that is not stopped by the SE Linux policy.  So it&#8217;s best to assume that SE Linux systems are vulnerable to kernel exploits.</p>
<p>At the time that the vmsplice() exploit was announced there was a claim that it could be used to de-stabilise a Xen Dom0 when run within a DomU.  It&#8217;s best to assume that any attack which can make some software perform in an unexpected manner can also be used to successfully attack it.  So at the time I was working on the assumption that the Dom0 could have been exploited.</p>
<p>Therefore I reinstalled the entire machine, I firstly installed a new Dom0 (on which I decided to run Debian/Unstable) and then I made a fresh install of Etch for the Play Machine.  There is a possibility that an attacker could compromise the hardware (changing the BIOS or other similar attacks), but this seems unlikely - I doubt that someone would go to such effort to attach hardware that I use for demonstrating SE Linux and for SE Linux development (it has no data which is secret).</p>
<p>If someone attacks my Play Machine they would have to first get root on the DomU in question and then crack Xen to get access to the hardware.  Then the machine is on a separate Ethernet segment which has less access to my internal network than the general Internet does (so they would not gain any real benefit).</p>
<p>One thing an attacker can do is launch a DOS attack on my machine.  One summer a Play Machine overheated and died, I suspect that the extra heat produced by a DOS attack contributed to that problem.  But losing a low-end machine I bought second-hand is not a big deal.</p>
<p>When discussing the machine there are two common comments I get.  One is a suggestion that I am putting myself at risk, I think that the risk of visiting random web sites is significantly greater.  Another is a challenge to put the machine on my internal network if I really trust SE Linux, as noted I have made mistakes in the past and there have been Linux kernel bugs - but apart from that it&#8217;s always best to have multiple layers of protection.</p>
<p><UL><br />
<LI>[1] <A HREF="http://www.coker.com.au/selinux/play.html">http://www.coker.com.au/selinux/play.html</A></LI><br />
<LI>[2] <A HREF="http://etbe.coker.com.au/2008/04/02/se-linux-play-machine-passwords/">http://etbe.coker.com.au/2008/04/02/se-linux-play-machine-passwords/</A></LI><br />
<LI>[3] <A HREF="http://www.avertlabs.com/research/blog/index.php/2008/02/13/analyzing-the-linux-kernel-vmsplice-exploit/">http://www.avertlabs.com/research/blog/index.php/2008/02/13/analyzing-the-linux-kernel-vmsplice-exploit/</A></LI><br />
<LI>[4] <A HREF="http://doc.coker.com.au/computers/se-linux-saves/">http://doc.coker.com.au/computers/se-linux-saves/</A></LI><br />
</UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=554&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_554" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/04/03/trust-and-play-machine/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SE Linux Play Machine and Passwords</title>
		<link>http://etbe.coker.com.au/2008/04/02/se-linux-play-machine-passwords/</link>
		<comments>http://etbe.coker.com.au/2008/04/02/se-linux-play-machine-passwords/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 05:34:27 +0000</pubDate>
		<dc:creator>etbe</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Best Posts]]></category>

		<category><![CDATA[Most Popular]]></category>

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

		<guid isPermaLink="false">http://etbe.coker.com.au/?p=553</guid>
		<description><![CDATA[My SE Linux Play Machine has been online again since the 18th of March.

On Monday the 11th of Feb I took it offline after a user managed to change the password for my own account.  Part of the problem was the way /bin/passwd determines whether it should change a password.
]]></description>
			<content:encoded><![CDATA[<p>My <A HREF="http://www.coker.com.au/selinux/play.html">SE Linux Play Machine [1]</A> has been online again since the 18th of March.</p>
<p>On Monday the 11th of Feb I took it offline after a user managed to change the password for my own account (their comment was &#8220;<B>ohls -lsa! i can change passwordls -lsals -lsa  HACKED!</B>&#8220;).  Part of the problem was the way <B>/bin/passwd</B> determines whether it should change a password.</p>
<p>The previous algorithm (and the one that is currently used in Debian/Etch) is that if the UID of the account that is having it&#8217;s password changed doesn&#8217;t match the UID of the process that ran <B>/bin/passwd</B> then an additional SE Linux check is performed (to see if it has permission to change other user&#8217;s passwords).  The problem here is that my Play machine has root (UID==0) as the guest account, and that according to the /bin/passwd program there is no difference between the <B>root</B> account (for unprivileged users) and the <B>bofh</B> account (which I use and which also has UID==0).  This means of course that users of the <B>root</B> account could change the password of my account.  My solution to this was to run <B>chcon</B> on the <B>/bin/passwd</B> program to give it a context that denied it the ability to change a password.  The problem was that I accidentally ran the SE Linux program <B>restorecon</B> (which restores file contexts to their default values) which allowed <B>/bin/passwd</B> to change passwords, and therefore allowed a user to change the password of my account.</p>
<p>The <B>semanage</B> tool that allows changing the default value of a file context does not permit changing the default for a file specification that matches one from the system policy (so the sys-admin can&#8217;t override compiled in values).</p>
<p>I have now fixed the problem (the fix is in my <A HREF="http://etbe.coker.com.au/2007/10/19/my-se-linux-etch-repository/">Etch SE Linux repository [2]</A> and has been accepted for Debian/Unstable and something based on it will go into the upstream branch of Shadow.  See <A HREF="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472575">the Debian bug report #472575 [3]</A> for more information.</p>
<p>The summary of the new code is that in any case where a password is not required to change the user&#8217;s password then SE Linux access checks will be performed.  The long version is below:</p>
<p>The new algorithm (mostly taken from the Red Hat code base which was written by Dan Walsh) is that you can only change a password if you are running as non-root (which means that the <B>pam_unix.so</B> code will have verified the current password) or if you are running as root and the previous SE Linux security context of the process is permitted access to perform the <B>passwd</B> operation in the <B>passwd</B> class (which means it is permitted to change other user&#8217;s passwords).</p>
<p>The previous context (the context before one of the <B>exec</B> family of system calls was called) is used for such access checks because we want to determine if the user&#8217;s shell (or other program used to launch <B>/bin/passwd</B>) was permitted to change other user&#8217;s passwords - executing a privileged program such as <B>/bin/passwd</B> causes a domain transition and the context is different) than the program that was used to execute it.  It&#8217;s much like a SETUID program calling <B>getuid(2)</B> to get the UID of the process which launched it.</p>
<p>To get the desired functionality for my Play Machine I don&#8217;t want a user to change their own password as the account is shared.  So I appended <B>password requisite pam_deny.so</B> to the file <B>/etc/pam.d/passwd</B> (as well as the <B>chfn</B> and <B>chsh</B> commands) so that hostile users can&#8217;t break things.  The new code in <B>/bin/passwd</B> will prevent users from taking over the machine if my PAM configuration ever gets broken, having multiple layers of protection is always a good thing.</p>
<p>The end result is that the Debian package and the upstream code base are improved, and my Debian Etch repository has the code in question.</p>
<p><UL><br />
<LI>[1] <A HREF="http://www.coker.com.au/selinux/play.html">http://www.coker.com.au/selinux/play.html</A></LI><br />
<LI>[2] <A HREF="http://etbe.coker.com.au/2007/10/19/my-se-linux-etch-repository/">http://etbe.coker.com.au/2007/10/19/my-se-linux-etch-repository/</A></LI><br />
<LI>[3] <A HREF="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472575">http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=472575</A></LI></p>
<p></UL></p>
<p class="akst_link"><a href="http://etbe.coker.com.au/?p=553&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_553" class="akst_share_link" rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://etbe.coker.com.au/2008/04/02/se-linux-play-machine-passwords/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
