<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cosine Jeremiah and his Musings &#187; Security</title>
	<atom:link href="http://cosine.org/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://cosine.org</link>
	<description>Life and Ruby and Security</description>
	<lastBuildDate>Sat, 10 Apr 2010 08:48:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Rails, Django, and Just-Barely-Enough CSRF Protection</title>
		<link>http://cosine.org/2010/04/10/rails-django-just-barely-enough-csrf-protection/</link>
		<comments>http://cosine.org/2010/04/10/rails-django-just-barely-enough-csrf-protection/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 08:48:46 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://cosine.org/?p=89</guid>
		<description><![CDATA[This week I found what I thought was a bug in Rails 2.3: it does not check the anti-CSRF authenticity token for AJAX requests. Due to years of experience with Rails I knew that this was not the previous behavior I have come to expect, so I dug around and learned that this behavior was [...]]]></description>
			<content:encoded><![CDATA[<p>This week I found what I thought was a bug in Rails 2.3: it does not check the anti-CSRF authenticity token for AJAX requests.  Due to years of experience with Rails I knew that this was not the previous behavior I have come to expect, so I dug around and learned that this behavior was intentionally changed some months back.  Due to same-origin policy for XMLHttpRequests, the existence of the X-Requested-With header is considered sufficient validation of the request.  Some details of the commit and comments on it can be found following <a href="http://github.com/rails/rails/commit/523f3ba8daf4968267eb4597bc88359a6337cf90#comments">this Github link</a>.  Much thanks to my friend Cory Scott of <a href="http://www.matasano.com/">Matasano</a> for bringing this to my attention.</p>
<p>Okay, fine&mdash;sort of.  I have a beef with this.</p>
<p>Good security practice is about implementing layers of security, and this flies in the face of that.  If certain other vulnerabilities are present, the most obvious one being HTTP response splitting, then CSRF is once again possible.  Any vulnerability that could allow custom headers to be inserted in a CSRF request now makes them possible because the authenticity token is bypassed by a custom header.</p>
<p>In my opinion, if a site has data worth protecting with an anti-CSRF authenticity token, there&#8217;s no reason not to use it for all requests that can alter that data.  Doing the bare minimum is what I call <em>Just-Barely-Enough Security</em>.</p>
<p>Note that Rails 3.0 handles CSRF protection differently (within Rack), and I have not examined it; the above comments apply only to Rails 2.x.</p>
<p>So it turns out that Rails is not the only web framework out there where the CSRF protection was in the just-barely-enough category.  I have also been working on a Django 1.1 project recently, and in doing so I have found another category of just-barely-enough security (fixed in Django 1.2).  Django 1.1 generates the authenticity token in a somewhat weak manner, but it is not weak enough that it is exploitable by itself.  The weakness is that the authenticity token is the MD5 hash of a site-wide secret concatenated by the session ID (in contrast, Rails 2.3 and Django 1.2 generate a completely random token for each session).  Because of how MD5 hashes are computed, an attacker could potentially learn the state of the MD5 computation up to the point of hashing the site-wide secret and himself compute any authenticity token given a session ID without further consulting the Django server.  However, this is not an issue by default because Django&#8217;s session fixation protection prevents it from responding with session IDs that it did not generate, so the attacker cannot build up the necessary information to perform the attack.  But if something were to be configured wrong on the Django server and a session fixation attack were to be possible, then the attacker would have more avenues for exploitation than just using session fixation on the victim directly.</p>
<p>Even worse would be a situation where the session fixation issue was found and repaired, but not before an attacker gleaned the necessary information to generate authenticity tokens for the site.  The site administrator would think he closed the security hole, but his site may still be exploitable based on previously leaked information.  That would be rather unfortunate.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2010/04/10/rails-django-just-barely-enough-csrf-protection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Chisec 16 and C</title>
		<link>http://cosine.org/2008/03/03/chisec-16/</link>
		<comments>http://cosine.org/2008/03/03/chisec-16/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 12:00:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[chisec]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/03/03/chisec-16/</guid>
		<description><![CDATA[Thursday, February 28 was a long day for me, but in a good way. It started almost like any normal morning, except I had to wake up 20 minutes early to handle the morning care and feeding of my animals. That task is one my wife usually performs, but she had to run out extra [...]]]></description>
			<content:encoded><![CDATA[<p>Thursday, February 28 was a long day for me, but in a good way.  It started almost like any normal morning, except I had to wake up 20 minutes early to handle the morning care and feeding of my animals.  That task is one my wife usually performs, but she had to run out extra early for her own work.</p>
<p>My morning at work went relatively fast.  I had very few scheduled tasks because of meetings dotting my schedule and my vice president&#8217;s group was all going out to play <a href="http://www.whirlyball.com/">Whirlyball</a> for the afternoon.  Additionally, due to my company&#8217;s sales team scoring a big contract, the company was serving free Lou Malnati&#8217;s pizza for lunch.</p>
<p>Whirlyball was probably the most fun of the day, but it is what happened afterward that is the most interesting.  I arrived at Houlihan&#8217;s at 6:30, preparing to socialize with other security professionals at Chisec 16 starting at 7:00.  I did not wait long.  I had hardly sat down when Maniac showed up, always full of interesting conversation and even an <a href="http://en.wikipedia.org/wiki/ASUS_Eee_PC">Asus Eee PC</a>, something I had never seen before.  It was not long before the room was full of other security professionals from all over the Chicago area.</p>
<p>With 20&ndash;30 people in a room, you do not get to talk to everyone.  I primarily spoke with a couple guys from the University of Chicago and some consultants from no less than three different firms.  It was <a href="http://www.matasano.com/log/thomas-ptacek/">Thomas Ptacek</a> that gave me the biggest surprise of the evening.</p>
<p>Tom told me that it is getting increasingly rare to find computer people that know C.  I had never thought about it, but I could see why this would be a problem.  I have been using C since 1994, and I simply consider it a staple of my computer abilities.  It is like part of the foundation.  It is through C that I know how a shell interacts with an operating system, or how any program interacts with other components of the system.  My knowledge of C is how I learned about the general structure of a running process in memory, and from that I understand how things like buffer overflow attacks actually work.  It is through C that I even know how Ruby handles its garbage collection, at a low level.  In regard to modern computer architecture, if you do not know C, then I would be incredulous if you told me that you <em>really</em> understand computer architecture.  I am not sure that knowledge of C++ can really convey the same understanding, except that someone could do so by paying close attention to the subset of C++ that is C.</p>
<p>I wonder&#8230; do you know C?  If I were to compile a list of important languages that all computer programmers should learn, C would be high on the list, if not the top language.  Certainly there are other important languages out there that expand ones mind around advanced programming topics, such as Ruby, Lisp, and ML, but down at the linker level C is the language that all other languages communicate with the operating system or the hardware&mdash;application binary interfaces (ABIs) are designed around how C compilers generate object files.  <em>It is </em>that<em> important.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/03/03/chisec-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Missing in Oracle Best Practices</title>
		<link>http://cosine.org/2008/02/12/security-missing-oracle-practices/</link>
		<comments>http://cosine.org/2008/02/12/security-missing-oracle-practices/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 16:12:44 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[soa]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2008/02/12/security-missing-oracle-practices/</guid>
		<description><![CDATA[Recently Oracle released a 272 page document outlining some recommended best practices when implementing SOA with its suite: http://download.oracle.com/technology/tech/soa/soa_best_practices_1013x_drop3.pdf I was going to review it for its security best practices and WS-Security recommendations&#8230; but there are not any. Take that to mean what you will.]]></description>
			<content:encoded><![CDATA[<p>Recently Oracle released a 272 page document outlining some recommended best practices when implementing SOA with its suite:</p>
<p><a href="http://download.oracle.com/technology/tech/soa/soa_best_practices_1013x_drop3.pdf">http://download.oracle.com/technology/tech/soa/soa_best_practices_1013x_drop3.pdf</a></p>
<p>I was going to review it for its security best practices and WS-Security recommendations&#8230; but there are not any.  Take that to mean what you will.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2008/02/12/security-missing-oracle-practices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WS-Security versus SOA over SSL</title>
		<link>http://cosine.org/2007/10/25/wss-vs-ssl/</link>
		<comments>http://cosine.org/2007/10/25/wss-vs-ssl/#comments</comments>
		<pubDate>Thu, 25 Oct 2007 12:00:22 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/25/wss-vs-ssl/</guid>
		<description><![CDATA[I have had some thoughts recently about the security of SOA (Service Oriented Architecture). When using SOA, the services are often made available using SOAP (Simple Object Access Protocol) messages communicated using HTTP. Naturally, it is important to keep data secure as it is transmitted from requester to servicer and vice versa. Should one use [...]]]></description>
			<content:encoded><![CDATA[<p>I have had some thoughts recently about the security of <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">SOA</a> (Service Oriented Architecture).  When using SOA, the services are often made available using <a href="http://en.wikipedia.org/wiki/SOAP">SOAP</a> (Simple Object Access Protocol) messages communicated using HTTP.  Naturally, it is important to keep data secure as it is transmitted from requester to servicer and vice versa.  Should one use SSL to secure SOAP?  Or should we recommend WS-Security, a standard means of transforming a SOAP message to add confidentiality and integrity to the message, instead&mdash;if we limit it to one or the other, that is.  Let us do a quick comparison of each solution:</p>
<p><b>1. SSL is ubiquitous and most everyone knows how to use it, whereas WS-Security is largely an &#8220;unknown&#8221; to most organizations.</b></p>
<p><b>2. Both SSL and WS-Security are easy to &#8220;drop in&#8221; to a typical web service architecture, though SSL is somewhat easier due to the previous observation.</b></p>
<p><!-- adman --></p>
<p>Both SSL and WS-Security have programs or libraries that make adding them to an existing web service a reasonable task.  </p>
<p>Adding SSL to a web service can be as easy as putting <a href="http://stunnel.mirt.net/">Stunnel</a> or other SSL termination software in front of the service.  However, to integrate SSL&#8217;s authentication features one would need to have the results of the SSL handshake passed into the application somehow.  More often a server ends up using weaker credentials, such as username and password, inside the SSL connection to establish the identity of its users.</p>
<p>With WS-Security, implementation can be done by adding a few calls to an appropriate WS-Security library, such as <a href="http://ws.apache.org/wss4j/">WSS4J</a> (Java) or <a href="http://rubyforge.org/projects/wss4r">WSS4R</a> (Ruby).</p>
<p><b>3. SSL provides security for an entire connection; WS-Security secures each message one by one.</b></p>
<p>If an application keeps a connection open to make multiple requests of a web service, then SSL would provide better performance than WS-Security.  Exactly how much better may depend on your servers&#8217; average load.  The difference in computation is due to SSL using mostly symmetric key encryption after the initial handshake at the start of the connection, whereas WS-Security needs to perform asymmetric key encryption on each message (one computation for handling encryption and one computation for handling the signature).  Symmetric key encryption is a lot faster than asymmetric key encryption, and while both technologies switch to using symmetric key encryption as fast as possible to provide the best performance, WS-Security is unable to avoid those asymmetric key computations on every message.</p>
<p>On the other hand, since security is applied on a message-by-message basis with WS-Security, an application is not susceptible to possible channel hijacking or HTTP splitting attacks that could occur with SSL.  If either of these things were to happen when WS-Security was in use then its security features would still protect the message and the data.</p>
<p><b>4. SSL requires an immediate communication with the endpoint to securely transmit data; WS-Security can protect a message that is queued up or stored on intermediate servers without additional concerns.</b></p>
<p>With SSL, the SOAP messages themselves remain unencrypted but are transmitted through a secure tunnel (the SSL link).  If that message ends up being stored on a disk (queued) prior to use, then it is unprotected from being read or tampered with by anyone who can obtain access to that disk.  If you think this is unlikely then you should know that attackers are often able to leverage poorly configured web, FTP, Citrix, remote desktop, and Windows file sharing servers to access disk.  This is one of several reasons that encryption of data at rest has become more important recently, and &#8220;at rest&#8221; refers to any time data hits a disk or a tape, not just when it resides within a database.</p>
<p>On the other hand, WS-Security imposes its protections upon the message itself, so if the message were to be copied by an adversary he could not read it.  If the attacker could find a way to get write access to the disk containing the WS-Security protected message waiting in queue, any attempt to tamper with the message is detected by WS-Security&#8217;s integrity protection features.</p>
<p><b>Comparison Summary</b></p>
<p>SSL (pros):</p>
<ol>
<li>SSL is ubiquitous&mdash;it is easy to find people with experience using it.</li>
<li>Easy to &#8220;drop in&#8221; to a typical web service architecture.</li>
<li>Provides encryption for an entire connection.</li>
<li>Client may authenticate the server during SSL handshake.</li>
<li>Server may authenticate the client during SSL handshake.</li>
</ol>
<p>SSL (cons):</p>
<ol>
<li>Connections must be active to transport data and responses.  In other words, the endpoints must have a direct channel to each other.</li>
<li>Once authenticated with the SSL handshake, any data transported on the connection is trusted.  This might leave a channel open that can be hijacked and used in similar fashion to a cross-site request forgery attack.</li>
<li>Data is vulnerable to capture and tampering if left unencrypted on a disk by queuing software; extra precautions may be necessary to protect it.</li>
</ol>
<p>WS-Security (pros):</p>
<ol>
<li>Easy to &#8220;drop in&#8221; to a typical web service architecture.</li>
<li>Provides encryption for a single message.</li>
<li>Client may be assured the server is the message recipient by virtue of the public key used to encrypt the message.  Likewise, the server is assured that the client is the recipient of the reply by virtue of the public key used to encrypt the reply.</li>
<li>Server may be assured the client is the message sender by virtue of the public key used to decrypt the message signature.  Likewise, the client is assured that the server is the sender of the reply by virtue of the public key used to decrypt the reply signature.</li>
<li>Messages may be time limited to prevent expired messages from being processed.</li>
<li>Messages are innately protected if left on disk and queued during transmission to the consumer.</li>
</ol>
<p>WS-Security (cons):</p>
<ol>
<li>WS-Security is not ubiquitous.  You will likely need to train your development staff how to use it.</li>
<li>Each individual message and its response requires processor expensive asymmetric key encryption to occur even if a communications channel is maintained.  This is negligible on small loads, but systems with hundreds, thousands, or yet more messages per second may become loaded.</li>
</ol>
<p>After reviewing the differences I suggest that WS-Security should be the preferred choice of most enterprises.  Do note that I suggest you do both SSL and WS-Security (for defense in depth and to provide some security by obscurity against those that would sniff your packets), but if you were to limit it to one or the other then I would prefer WS-Security.  The issue that convinced me was the security of messages left in queue on disks.  This situation happens rather frequently (swap files, anyone?) and is often done unbeknown to the original application architect as the system grows and the message delivery mechanism is changed.  WS-Security simply provides security from end to end without worrying that every step of the way is secured appropriately as well; SSL only promises security between the endpoints of the SSL tunnel.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/25/wss-vs-ssl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Internal Machine Security</title>
		<link>http://cosine.org/2007/10/06/internal-machine-security/</link>
		<comments>http://cosine.org/2007/10/06/internal-machine-security/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 00:09:18 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/10/06/internal-machine-security/</guid>
		<description><![CDATA[Sorry for the delay in posts here, but I have been sick the past week, and getting back into my regular routine has been challenging since. Also, rather that just post random musings of the day like many other blogs, I try to provide useful original content based on my experience. However, today I will [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry for the delay in posts here, but I have been sick the past week, and getting back into my regular routine has been challenging since.  Also, rather that just post random musings of the day like many other blogs, I try to provide useful original content based on my experience.</p>
<p>However, today I will do as many other blogs do and point to some interesting content from elsewhere that I recently came across.  There are two recent articles by <a href="http://www.root.org/~nate/">Nate Lawson</a> that are very interesting; you may find them <a href="http://rdist.root.org/2007/09/27/pc-memory-architecture-overview/">here</a> and <a href="http://rdist.root.org/2007/09/28/protecting-memory-from-dma/">here</a>, and I suggest you read them.  They discuss the security of internal system components&mdash;hardware security.</p>
<p>As security practitioners continue to struggle with networks and applications, we still have the same issues affecting components of our hardware.  The exact same issues, in fact:  authorization, authentication, and security versus performance to name a few.  I smile at the thought of a conference room somewhere in the bowels of Intel or AMD where engineers and managers discuss threat models and risk equations and make decisions on what to implement and how to implement PC hardware features based on costs and risks in a manner no different than how a web application&#8217;s security is discussed at a software company.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/10/06/internal-machine-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scrutinizing SSH</title>
		<link>http://cosine.org/2007/09/18/scrutinizing-ssh/</link>
		<comments>http://cosine.org/2007/09/18/scrutinizing-ssh/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 12:00:15 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/09/18/scrutinizing-ssh/</guid>
		<description><![CDATA[In my previous post titled Bolting on Security, I mentioned that port 22 is generally not scrutinized as much as 445 when being allowed through a firewall. Obviously the situation varies from incident to incident, but I wanted to say that port 22 really should be looked at more closely. All is not always roses [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://www.cosine.org/2007/09/14/bolting-security/">previous post titled Bolting on Security</a>, I mentioned that port 22 is generally not scrutinized as much as 445 when being allowed through a firewall.  Obviously the situation varies from incident to incident, but I wanted to say that port 22 really should be looked at more closely.  All is not always roses and peaches when you allow port 22, but I am going to explain some of the saving graces of SSH that can make it less threatening in some hairy situations.</p>
<p><b>The Threats</b></p>
<p>Let us first start with what is wrong with allowing SSH through a firewall.  Then we will address each problem one by one.  The problems are:</p>
<ol>
<li>Buffer overflow bugs have led to system compromise.</li>
<li>Shell access can often be obtained when none is necessary.</li>
<li>SSH supports weak forms of authentication&mdash;like passwords.</li>
<li>SSH allows the forwarding of connections between the client and the server.</li>
<li>SSH helps facilitate X11 forwarding, allowing graphical programs to run remotely.</li>
</ol>
<p><b>Buffer Overflows</b></p>
<p>This is your greatest threat to giving up root access to your server, but fortunately there is something you can do to reduce the risk of break-in to negligible levels.  That something is to turn on <em>privilege separation</em>.  The only SSH daemon that supports privilege separation is <a href="http://www.openssh.com/">OpenSSH</a> and its more recent derivatives.  Fortunately, OpenSSH is a full featured SSH server so even if you are not using it, you should be able to switch to it without much difficulty.</p>
<p><!-- adman --></p>
<p>Note that despite Sun SSH being a derivative of OpenSSH, Sun has chosen not to implement privilege separation and thus you would need to replace it.  I have badgered people at Sun about this.  I can tell you they had a reasonable excuse for omitting it from Solaris 9, but they really dropped the ball with Solaris 10.  I hope they can do better for Solaris 11.  Your mileage may vary on other operating systems, but the free ones generally use OpenSSH by default.</p>
<p>The reason privilege separation is so good is that it causes the majority of the SSH server code to run with no privileges in a chrooted jail.  The little bit of SSH that runs with full root privilege is scrutinized much more closely by the OpenBSD team and security researchers, so it is considered very safe.  I do not know of any exploitable vulnerabilities ever found in the privileged code after OpenSSH introduced privilege separation a few years ago (though I may have missed one).</p>
<p>To activate it, create an sshd user (the unprivileged account) and a /var/empty directory (the jail).  Then set the <code>UsePrivilegeSeparation</code> option to &#8220;yes&#8221; in sshd_config and restart your server.  You can test if privilege separation is active by looking at your process list after you connect.  When privilege separation is in use there will always be two extra processes for each SSH connection, one privileged owned by root, and one unprivileged owned by a regular account (authenticated user) or the sshd account (unauthenticated user).  Without privilege separation there is always just one extra process per connection.</p>
<p>Since you need to be using OpenSSH or a derivative to use privilege separation, I will assume you are using it for the rest of this post.</p>
<p><b>Shell Access When None is Necessary</b></p>
<p>Sometimes you only want to give someone the ability to transfer files via SCP or SFTP, two protocols that use SSH.  Traditionally you have to give full access to a shell to allow only file transfers with SSH.</p>
<p>One solution that has been around for quite some time is a program called <a href="http://sublimation.org/scponly/wiki/index.php/Main_Page">scponly</a>.  You use scponly as the default shell for &#8220;file transfer only&#8221; accounts, and it disallows command line and command access.  This program has previously had a few security problems that has occasionally allowed an authenticated user to &#8220;break out&#8221; into a shell, but overall has been very good.  The maintainers take its security seriously.</p>
<p><b>Password Authentication</b></p>
<p>Password authentication is great if you&mdash;oh who am I kidding!?  Password authentication is bad, and if you are trying to keep things apart by a firewall and there is a good chance that an attacker will start trying out passwords against your open port, then you better have something better than password authentication protecting the accounts.</p>
<p>SSH can be configured to disallow password authentication and require stronger credentials.  Just set the <code>PasswordAuthentication</code> option to &#8220;no&#8221; and those pesky little weak passwords will not be a problem.  Of course you will need to set up something else, such as SSH keys, Kerberos, or a challenge-response mechanism.  If you are in a high-security situation, you should consider using some form of two-factor authentication.</p>
<p><b>Support for Forwarding Connections</b></p>
<p>SSH can be used to forward connections, effectively bridging two networks to a limited extent.  If you are scrutinizing the security of an SSH server on the other side of a firewall, you will want to turn this off.  Do so by setting <code>AllowTcpForwarding</code> to &#8220;no&#8221;.</p>
<p>However, perhaps there is one port in particular that you do want to forward with SSH through your firewall.  This could be used to encrypt an insecure channel as it travels over an untrusted network, or it can allow an &#8220;outsider&#8221; to connect to a service inside your firewall.  Whatever the reason, you have a means of limiting what is allowed through at the server side.  This is done with the <code>PermitOpen</code> option on newer versions of OpenSSH&mdash;it can be used to limit what target systems and ports the server allows clients to forward to.  Even if you have full control of the client system, it always helps to add a layer of security on the server side, too.</p>
<p><b>Support for Forwarding X11 Displays</b></p>
<p>When it was released in the mid-90s, one of the biggest problems facing Unix users was how to run their X11 graphical applications securely.  The security of an X program was usually dependent on weak host-level security, and as a result anyone with a login on the system with the X client (the program) could also run an X client to snoop or annoy the user.  There was also a cookie-based authentication available, but it was difficult to teach users how to use it.</p>
<p>Along came SSH, and not only did it replace Telnet by providing a secure shell connection, it also provided a means to automatically configure the cookie-based authentication for X11 <em>and</em> forwarded the traffic over the encrypted channel.  Good for you when connecting to your company server internally.  Bad for you when you do not fully trust a user or an account that needs access to the system through a firewall.</p>
<p>This one is easy to disable, too.  Just set the <code>X11Forwarding</code> option to &#8220;no&#8221;.</p>
<p><b>Summary</b></p>
<p>Do not be afraid to allow SSH through your firewall, but take reasonable precautions and know your SSH server.  Know how to disable the features you do not need.  Get the SSH client to use the strongest form of authentication available.  Read the man pages for ssh_config and sshd_config and be familiar with many of their options.  Someday, when you need to boost the security of a connection somewhere, you will be glad you did.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/09/18/scrutinizing-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bolting on Security</title>
		<link>http://cosine.org/2007/09/14/bolting-security/</link>
		<comments>http://cosine.org/2007/09/14/bolting-security/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 12:00:33 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/09/14/bolting-security/</guid>
		<description><![CDATA[To build security in your project, you need to make it a consideration from the start. Bolting it on afterward is always a recipe for disaster, and unless you start over with a complete application rewrite you are likely to fail to secure your application in some subtle manner or another. If you are in [...]]]></description>
			<content:encoded><![CDATA[<p>To build security in your project, you need to make it a consideration from the start.  Bolting it on afterward is always a recipe for disaster, and unless you start over with a complete application rewrite you are likely to fail to secure your application in some subtle manner or another.  If you are in a hurry to get Version 1.0 out to meet a limited opportunity or to meet a costly deadline to miss, it may be acceptable to a business to provide incomplete security in an application to get the product out the door.  However, the application needs to have been designed for its security profile from the start or its security can never be completed.</p>
<p>For example, let us say I have an application that needs strong password controls to be secure, but the developers are running out of time to ship.  For Version 1.0, I, as a decision maker for the business, might want to drop the password controls on the application.  However, I must be certain that the password controls remain in the architecture design or else the application will end up deployed and used in a manner that would defeat ever trying to add password controls later.  In particular, if I need a mechanism in the application that allows it to facilitate a user changing his expired password but I then deploy the application to users without any authentication at all, then I will likely find myself completely unable to add the strong password controls later.  Firstly, I would need to somehow find out what users I have.  Since none have ever authenticated, I have no idea who is even using the system!  And now I am expected to add strong password controls?</p>
<p>This kind of thing happens all the time, but often more subtly.  Many of the Microsoft protocols suffered security issues for years because they had to provide backward compatibility with older Windows desktops.  I am not even certain to what degree the Windows 2003 servers protocols still suffer from many of those same issues, but I know that allowing traffic through a firewall on port 445 between Windows hosts is still something to be eyed with great suspicion.  It is somewhat because that one port allows so many services: file sharing, printing, and authentication are the most common.  But one can accomplish many of the same things on a Unix system over port 22 with SSH, and that port is not one that needs to be scrutinized nearly as much.  Perhaps it is because the SSH protocol is much better documented than the Microsoft protocols, or at least much better understood by many more people.  Perhaps it is because Windows systems are more often the targets of viruses.</p>
<p>Anyway, while I wish that every application could build in security in every release, I understand that a security-starved Version 1.0 will occasionally need to see the light of day.  When you are involved in such a Version 1.0, just remember to keep security in your architecture.  Allow it manifest in Version 1.1 or even Version 2.0 if necessary by keeping the goal in mind.  Just do not expect that you can cut it out of your architecture completely and then bolt it on later&mdash;you cannot; the smartest people in the world have already tried, and we know how your story will end.  Security cannot be bolted on as an afterthought.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/09/14/bolting-security/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Security Risk Assessments</title>
		<link>http://cosine.org/2007/08/28/security-risk-assessments/</link>
		<comments>http://cosine.org/2007/08/28/security-risk-assessments/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 12:00:54 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/08/28/security-risk-assessments/</guid>
		<description><![CDATA[Risk assessments are one of the main tasks I am faced with day-to-day with my security work. Most of the time it comes in as a request to &#8220;approve&#8221; some architecture. In my head, this is basically a security risk assessment where I also getting to decide for the business that the benefit of allowing [...]]]></description>
			<content:encoded><![CDATA[<p>Risk assessments are one of the main tasks I am faced with day-to-day with my security work.  Most of the time it comes in as a request to &#8220;approve&#8221; some architecture.  In my head, this is basically a security risk assessment where I also getting to decide for the business that the benefit of allowing the architecture is greater than the associated risk.  Usually I can just make a quick judgment call and give a &#8220;thumbs up&#8221; or help the user with tweaking his architecture to produce an acceptably secure solution, but sometimes I have to write out my reasoning for disapproving something.  Then the mangers that end up deciding that we move forward on the given architecture have adequate knowledge of the risk.</p>
<p>Recently I had started using Microsoft&#8217;s DREAD framework for performing written security risk assessments.  I liked it because at the end of my assessment I can deliver a number to my management.  Low numbers are good, and high numbers are bad.  For about two months and about six written assessments (not many, I know) I was very happy with the numbers the DREAD framework was giving me when I used it.  I felt the numbers were adequately expressing the risk to the organization.</p>
<p>Then, earlier this month, I did one more for a project that I felt held insignificant risk to the organization, but I did not give it the usual rubber stamp approval because the project ignored some good practices that I wanted to insist upon (when I say ignored I mean thumbed their nose up at me when I told them they should do it).  I thought that if they were going to go against my recommendations that we should all have an accurate risk assessment of what that meant.  However, the resulting score out of DREAD was high, and as I said before, does not accurately represent the true risk of this project.  The reason DREAD failed here was that its score is the result of an <em>addition</em> instead of a <em>multiplication</em> of the various risk factors (most models I have seen use multiplication), so one low score means little in the face of some other high factors.</p>
<p><span id="more-27"></span>I scratched my head, delivered my DREAD report along with my thoughts that the score was higher than the true risk, and moved along to other projects.  Today, however, I came across <a href="http://taosecurity.blogspot.com/2007/08/thoughts-on-fair.html">this article</a> by Richard Bejtlich.  In it he provides some criticism of <a href="http://fairwiki.riskmanagementinsight.com/">FAIR</a>, another security risk assessment framework currently being promoted by its originator(s).  What really caught my attention is that he essentially argues that risk assessment is the wrong path for us in the security industry.  I have to admit it took me a long time to climb on board with the whole risk assessment bandwagon myself, but I have never seen someone with this much experience argue against it.  As I read I realized that I never really believed in the whole risk assessment model, and that I really only use it as a means of selling security to my management&mdash;an important task, no doubt, but is it perhaps the wrong approach?  Certainly managers need this to be able to reduce risk into dollars and cents for the business?</p>
<p>The problem is that risk assessments are based on guesses.  Not just any guesses, though; they are based on <em>wild-ass</em> guesses.  We are supposed to say &#8220;do X instead of Y for COST dollars against our budget or else we can expect hackers to come in and cost us GUESS.&#8221;  But maybe they will not know we are here and hack someone else instead.  The reality is that we have no idea what the odds of being breached are, and we have no idea what the cost will be if we are breached.  We have no idea what the motivation of our attacker(s) might be, and we have no idea what that motivation will spur them to do.  What are the odds of being breached in some manner we did not think of?  After all, if we had thought of it we probably would have closed the door on that mechanism, right?  So what good is a risk assessment on a problem we already know about?</p>
<p>We really need to be focusing on best practices and engineering the systems to be as paranoid of everything as possible.  To encrypt or not to encrypt?  <em>You encrypt!</em>  To trust or not to trust?  If you have to ask, <em>don&#8217;t trust!</em>  Why can we not build systems like this every time?  For an organization that lives and breathes encryption, the incremental cost of encrypting data and connections dwindles toward zero over time.  You just do encryption exactly like you just drink coffee.  Does anyone lament that we no longer use Telnet now?  There was a fixed cost for moving people to SSH, and now the cost to keep everyone using SSH is negligible.  The costs of security should be focused on new threats instead of ignoring them until we can finish securing our browsers from the latest Javascript abuse (and whatever else plagues us this week).  And best of all, those pesky auditors can become your friends, and you can answer questions about your security practices without trying to dance around the truth.  Wouldn&#8217;t that be nice?</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/08/28/security-risk-assessments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Connectivity Problems</title>
		<link>http://cosine.org/2007/08/21/debugging-connectivity-problems/</link>
		<comments>http://cosine.org/2007/08/21/debugging-connectivity-problems/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 12:00:27 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/08/21/debugging-connectivity-problems/</guid>
		<description><![CDATA[The Application is down! No, wait! Our Unix administrators just checked the server and it is running. They swear by it, and say it is the network team&#8217;s equipment dropping packets. The network team checks their systems and swear they are passing the traffic, and it must be an application configuration issue. The application folks, [...]]]></description>
			<content:encoded><![CDATA[<p>The Application is down!  No, wait!  Our Unix administrators just checked the server and it is running.  They swear by it, and say it is the network team&#8217;s equipment dropping packets.  The network team checks their systems and swear they are passing the traffic, and it must be an application configuration issue.  The application folks, who originally reported the problem, throw up their hands and go back to the systems administrators for more help.  Before long the teams are in a quagmire of blame and nothing is getting done towards fixing the issue.  How can we step around that?  What should we be doing to fix the Application?  If you are the systems administrator then let us try and verify what the network guys are saying.  If they really are dropping packets then let us bring some confirmation of that to the table.</p>
<p>Firstly, check your routing tables and your basic network configuration.  More than one Unix administrator on a rampage of righteous indignation against their network team has found himself swallowing his own pride when it was discovered that he had errors in his routing table.  So check your IP address, your netmask, and your default router first.  All good?  Now check if you need or have any other routes in your routing table.  All good here, too?  Excellent!  If you are new to Unix and need help finding this information, read the man pages for ifconfig and netstat to get started.  I would love to give some examples but it differs very much from Unix variant to Unix variant.  In general, though, use &#8220;netstat -nr&#8221; for viewing the routing table and &#8220;ifconfig -a&#8221; for seeing all of the network interface configuration information.</p>
<p>Now that you IP configuration is confirmed, let us move on to the connection in question.  Firstly, you have to identify the port and protocol of the connection.  If you are running a standard protocol, such as HTTP, then you can likely assume port 80, but perhaps you do not know?  We have a couple options.</p>
<p><span id="more-24"></span>There are a myriad of tools to see what connections and proto-connections exist on the system.  I like <a href="ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/">lsof</a> because I can view the connections for each individual process.  So let us say I have that HTTP server I mentioned above running on my Unix server, but I am not sure if it is running on port 80 or some other port.  I can start the web server process, note what its process ID is with ps, and then use lsof to view its listening sockets to see what port the clients should connect to.</p>
<p>I am using Mac OS X today, which has a BSD style ps command:</p>
<pre>
% <b>ps auxw | grep httpd</b>
root     13888   0.0 -0.3    41732   5348  ??  Ss   Tue05PM   0:15.24 /usr/sbin/httpd
www      14549   0.0 -0.0    32636    796  ??  S    Wed09AM   0:00.00 /usr/sbin/httpd
</pre>
<p>When using a System V style ps I use &#8220;ps -ef&#8221; instead of &#8220;ps auxw&#8221;.  The process ID here for httpd is 13888 (I could also use 14549 because they share the port, in a sense, but that may not always be the case).  So let us run lsof to see what ports are open:</p>
<pre>
% <b>sudo lsof -Pnp 13888 | egrep &#39;TCP|UDP&#39;</b>
httpd   13888 root   16u    IPv4 0x76fe710      0t0       TCP *:80 (LISTEN)
</pre>
<p>It <em>is</em> port 80!  And in particular it is <em>TCP</em> port 80.  Note that this is opposed to <em>UDP</em> port 80, which is another beast altogether that we will address below.  For now let us move on to testing this connection.</p>
<p><b>Testing TCP Connectivity</b></p>
<p>The most widespread tool for checking if there is a firewall between two systems blocking a particular TCP port is telnet.  It is not the best utility, but it does the job and is ubiquitous; you will find it on almost all Unix and Windows systems, and sometimes even VMS and mainframes.</p>
<p>To use telnet, just get to a command line and type &#8220;telnet&#8221; followed by the target system and port number:</p>
<p><code>telnet my-web-server.example.com 80</code></p>
<p>If all is well and you can reach the server, you should see something like this:</p>
<pre>
% <b>telnet my-web-server.example.com 80</b>
Trying 192.168.1.10...
Connected to my-web-server.example.com.
Escape character is &#39;^]&#39;.
</pre>
<p>If the service is down, but there is no firewall intervention, you will see something along the lines of &#8220;connection refused&#8221; like below:</p>
<pre>
% <b>telnet my-web-server.example.com 80</b>
Trying 192.168.1.10...
telnet: connect to address 192.168.1.10: Connection refused
telnet: Unable to connect to remote host
</pre>
<p>But what if there is a firewall in between dropping all the packets?  You would see the message attempting to make the connection, and then telnet will seem to just freeze for many seconds.  After some time it will report a failure, but if you see it freezing for more than ten seconds then you can terminate the connection attempt with control-C.  Here is what it looks like:</p>
<pre>
% <b>telnet my-web-server.example.com 80</b>
Trying 192.168.1.10...
<em>(At this point telnet will stop and wait for a few minutes.)</em>
telnet: connect to address 192.168.1.10: Operation timed out
</pre>
<p>Note that even if it looks like a firewall is dropping the packets, there may be any number of other causes:</p>
<ol>
<li>Host-based firewall on source host blocking outbound traffic.</li>
<li>Host-based firewall on destination host blocking inbound traffic.</li>
<li>Target host is down.</li>
<li>Either host has an error in its routing table.</li>
</ol>
<p><b>Testing UDP Connectivity</b></p>
<p><!-- adman --></p>
<p>Sometimes applications use UDP instead of TCP for their communications.  This can be tricky to handle if trying to determine if you have a network issue between nodes.  The reason is that UDP does not require the other host to reply; if you send a packet that is received you see the same thing as if you send a packet that never reaches its destination.  Note that if you send a UDP packet that arrives to a system <em>not</em> accepting packets then you do get a different behavior that you can measure, because in that case the system will notify you that it is not accepting packets there.</p>
<p>So first make a little extra effort to ensure both hosts are up and that the routing table works between them.  You can do this by probing any TCP port (open or closed) or with an ICMP ping.  As long as <em>those</em> packets can get through you know your routing tables are okay (note this does not rule out host-based firewalls as a problem as specific ports may be filtered).</p>
<p>We can try to send a generic packet to the other host with either ping or traceroute&mdash;those two are widely available&mdash;or netcat if you have it.  Netcat is the best if it is available:</p>
<pre>
% <b>nc -vvuz my-cifs-server.example.com 137</b>
my-cifs-server.example.com [192.168.1.20] 137 (netbios-ns) open
 sent 0, rcvd 0
</pre>
<p>The means of getting ping or traceroute to send a single UDP packet to a specific port varies per system and is even impossible in some (all?) versions of Windows.  Because of these differences, I recommend installing netcat and using it if you need to debug UDP connections (it is also better than telnet for debugging TCP connections).</p>
<p>Since we really only know that we do not have a network issue if the port shows up as &#8220;closed&#8221; we have to do more research to confirm a network problem.  Note that if you have the luxury of being able to shutdown the UDP service on the destination host then you should do so for testing so you can observe the closed state.</p>
<p>The next tool you need to fully debug a broken UDP connection is a packet sniffer.  I recommend <a href="http://www.wireshark.org/">Wireshark</a> if you are on Windows, or <a href="http://www.tcpdump.org/">tcpdump</a> if you are on any non-Solaris Unix system.  On Solaris, use the built-in &#8220;snoop&#8221; command.  Each of these has a somewhat different usage:</p>
<p><code>tcpdump -i en1 &#39;host my-cifs-server.example.com and udp and port 137&#39;</code><br /> <code>snoop -d ce0 &#39;host my-cifs-server.example.com and udp and port 137&#39;</code><br /> Wireshark is usually run in a GUI, particularly on Windows.</p>
<p>Get your packet sniffer running and start talking to your port.  If you do not see your packets going out, you are doing something wrong.  Go back and figure out if you are sniffing the wrong interface or have an error in your usage.  If you do see your packets going out but none returning, then it is still inconclusive, but at least you know you are sniffing the right thing.  If you do see return packets, your connection is open and you can proceed with troubleshooting your application instead of the network.</p>
<p>The key here is to get the other server to send packets back in response to packets sent.  If you can do that then you know the connection works.  Unfortunately, many servers just ignore stuff they consider garbage, like the packets we were sending with netcat.</p>
<p>In our case, we are trying to connect to a NetBIOS name service running on UDP port 137.  Some such servers reply to garbage with garbage (success for us!) and some just drop the packets, leaving us confused.  To get these guys stirred up we need to generate some real NetBIOS name service traffic from our workstations or servers.  In this case, we would log into our Windows workstation and try to connect to a file share on the server; we could also run the nbtstat command instead.  In either case, with our sniffer armed and ready we will hope it is enough to generate a reply.  If there is truly a NetBIOS name service running on the remote port, we should see evidence of it in the sniffer output.  If not, then it is at this point that we can turn towards the network and in good conscience assume all is well from the server side (because you did check your host-based firewall settings, right?).</p>
<p>Debugging network connectivity issues does not have to be a nightmare.  With the right tools, knowledge, and experience doing so you can be a pro at determining if an issue needs resolution in your application, on the OS it is running on, or the network.  Be the hero that <em>knows</em> instead of guesses what is happening out there, because the resolution often follows.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/08/21/debugging-connectivity-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Secure FTP in All its Forms</title>
		<link>http://cosine.org/2007/08/18/secure-ftp-forms/</link>
		<comments>http://cosine.org/2007/08/18/secure-ftp-forms/#comments</comments>
		<pubDate>Sat, 18 Aug 2007 12:00:32 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/08/18/secure-ftp-forms/</guid>
		<description><![CDATA[It is the File Transfer Protocol. FTP has been an important part of the Internet for more than 20 years. Businesses depend on it to transfer data from system to system and from business to business. In today&#8217;s world of SOX, HIPPA, PCI, and other standards and regulations companies are not only required to get [...]]]></description>
			<content:encoded><![CDATA[<p>It is the File Transfer Protocol.  FTP has been an important part of the Internet for more than 20 years.  Businesses depend on it to transfer data from system to system and from business to business.  In today&#8217;s world of SOX, HIPPA, PCI, and other standards and regulations companies are not only required to get the data moved, but to move it securely.  &#8220;We need secure FTP,&#8221; cry the business units.</p>
<p>However, in the rush to address the needs to secure file transmissions we ended up with multiple protocols.  And even among those protocols there are multiple standards regarding how to operate them.  To connect a client to a server both sides have to select the same technology, and simply saying &#8220;we want/do secure FTP&#8221; just leaves implementors in a quandary about <em>which kind</em> of secure FTP.</p>
<p><span id="more-22"></span><b>SFTP &mdash; FTP over SSH</b></p>
<p>SFTP (S <em>before</em> FTP) is the protocol that describes an FTP-like protocol that is secured over an SSH channel.  SSH&#8217;s standard port is 22, and so SFTP&#8217;s standard port is also 22.  SFTP is very &#8220;firewall friendly&#8221; because all communications run over a single connection.  On the down side, most implementations of SFTP carry with them a full implementation of SSH, and SSH is traditionally used for shell access.  For a typical business connection, allowing shell access is highly undesirable.  The most recent versions of SSH servers are beginning to realize an &#8220;SFTP only&#8221; configuration is a good feature to support, so this situation is fast improving.</p>
<p><b>FTPS &mdash; FTP over SSL</b></p>
<p>FTPS (S <em>after</em> FTP) is a different protocol entirely.  FTPS is a super-set of the same FTP protocol that the Internet has relied upon for years and years, but it allows for encryption of the connection over an SSL or TLS encrypted socket.  This protocol is harder to allow through firewalls because it follows the same process of opening additional connections from server to client or from client to server as the unencrypted version of the FTP protocol.</p>
<p><b>Implicit FTPS</b></p>
<p>To further complicate things a little, the FTPS protocol can be run in an &#8220;implicit&#8221; mode or an &#8220;explicit&#8221; mode.  The implicit mode was used originally; it is an SSL encrypting socket wrapped around the entire communication starting at the point of initial connection.  To differentiate this original FTPS from unencrypted FTP, the encrypted FTPS was assigned a standard port of 990.  If you see an FTPS server running on port 990, that is almost certainly an implicit FTPS server.  It is called &#8220;implicit&#8221; because the directive to encrypt the connection is implied by using port 990.  Note that this mode is far less common than the explicit mode.</p>
<p><b>Explicit FTPS</b></p>
<p>Soon after FTPS was in use some smart people decided it would be best if we could have an FTP server that could support unencrypted as well as encrypted connections, and do it all over the same port.  To accommodate this the &#8220;explicit&#8221; FTPS protocol connection begins as a normal unencrypted FTP session over FTP&#8217;s standard port 21.  The client then explicitly informs the server that it wants to encrypt the connection by sending an &#8220;AUTH TLS&#8221; command to the server.  At that point the FTPS-enabled server and the client begin the SSL or TLS handshake and further communications happen encrypted.  Note that most (if not all) explicit FTPS servers can be optionally configured to <em>require</em> encryption, so it will deny clients that attempt to transfer data unencrypted.  Often this can be configured on a user by user basis.</p>
<p>Of these three &#8220;secure FTP&#8221; protocols, only explicit FTPS is defined by an RFC.  In this case it is <a href="http://www.ietf.org/rfc/rfc4217.txt">RFC 4217</a>, released in 2005, even though all these protocols had been in use for years prior.</p>
<p>By the way, I have not discussed what encryption algorithms each of these modes use.  They all can use AES if you want, and they often have other good options, too.  Do not worry about the algorithm when simply selecting which protocol to use; they are all good from this standpoint.</p>
<p><b>Comparison</b></p>
<p>Which kind of secure FTP should you use?  It really depends on your business, software availability, and network firewall situation.  I personally have no preference for or against any of these protocols on their base merits.  Here is a table recapping some of the differences:</p>
<table border="1">
<tr>
<th>Secure FTP Type</th>
<th>SFTP</th>
<th>Explicit FTPS</th>
<th>Implicit FTPS</th>
</tr>
<tr>
<th>Encryption by</th>
<td>SSH</td>
<td>SSL or TLS</td>
<td>SSL or TLS</td>
</tr>
<tr>
<th>Common Authentication Options</th>
<td>password, SSH key pair, hosts-based authentication,<br />
      GSSAPI (Kerberos and Active Directory)</td>
<td>password, SSL certificate</td>
<td>password, SSL certificate</td>
</tr>
<tr>
<th>Default Port</th>
<td>22</td>
<td>21 and more for data connections</td>
<td>990 and more for data connections</td>
</tr>
<tr>
<th>Firewall Implications</th>
<td>easy; just allow 22</td>
<td>difficult; see below</td>
<td>difficult; see below</td>
</tr>
<tr>
<th>Additional Host Security Implications</th>
<td>might allow access to shell (possibly undesired)</td>
<td>none</td>
<td>none</td>
</tr>
<tr>
<th>Availability of Software</th>
<td>common, comes with many SSH and FTP packages</td>
<td>common, comes with most FTP packages</td>
<td>uncommon</td>
</tr>
</table>
<p><b>Firewall Implications</b></p>
<p><!-- adman --></p>
<p>I have been mentioning some firewall implications for the FTP over SSL variants, but let us go into more detail.  The FTP protocol initially opens one connection to authenticate the user and for the user to issue commands to the server.  This is all well and good until the user wants to view the contents of a directory or transfer a file.  Once either of those activities are requested, there is another connection made.  To make things even more fun, the connection can be either from client to server (called <em>passive mode</em>) or from server to client (called <em>active mode</em>).  I will just simply call these passive and active data connections, respectively, based on the name of the mode of transfer.</p>
<p>When FTP is always unencrypted, firewalls have been using a little trick to allow the active and passive data connections.  They can snoop your connection and see what ports are being decided upon for these connections, and then they quickly allow the connection to get through once.  That option is not available when the connection is encrypted.  Thus, firewalls need another way to figure things out.</p>
<p>The active data connections (from server back to client) turn out to be relatively easy to firewall from the server side.  They always use port 20 (for explicit FTPS) or port 989 (for implicit FTPS) as the <em>source port</em> of the connection (this can be configured to be a different port in many servers).  A firewall protecting an FTPS server can just confirm that there exists at least one FTPS connection to that server, and assume that outbound connections with the right source port are okay.  Most firewalls just end up being configured to always allow these connections based on the source port, and that is usually okay, too.</p>
<p>The passive data connections, by default on most servers, could be anything inbound between 49152 and 65535 (or sometimes between 1024 and 65535, depending on OS and server).  Most organizations do not want to allow this many ports through the firewall to the server.  Fortunately, the better FTPS servers also allow this range to be configured.  Select a fixed range large enough to handle your traffic load and configure your FTPS server to only use that range for its passive ports.  Then allow those ports through the firewall in addition to the main connection at 21 or 990.</p>
<p>If you want to serve the greatest number of clients with your FTPS server, you will want to support both active and passive mode connections.  Some clients can figure out how to get one type but not the other through their firewalls.  You can never guess which one it will be, though passive mode is more likely because all they have to do is allow the connections <em>out</em> from their network.  If for some reason your organization decides to only support one mode and not the other, make sure your clients have some means of being notified!  Even better if you can configure your FTP server to simply deny an attempt to open data connections using the mode your firewalls do not permit.</p>
<p>Note that even if you are not using SFTP or FTPS, there are other means of securing FTP connections defined in <a href="http://www.ietf.org/rfc/rfc2228.txt">RFC 2228</a>.  Someone could, in theory, refer to a &#8220;secure FTP&#8221; connection that uses another means besides SSH or SSL to secure the connection via the extensions to the FTP protocol defined by that RFC.  In practice (excepting Kerberized FTP), I have seen <em>only</em> the types of secure FTP I described above.</p>
<p>I wrote this article to help you decide which type of secure FTP to use.  You need to know all these issues to make the best decision for your company:  SFTP versus FTPS, implicit versus explicit, and active versus passive.  Perhaps even more important is that you need to know how to correctly communicate your decisions to other technical implementers, and you need to understand the right questions to ask of others intending to implement (or already have implemented) &#8220;secure FTP&#8221; but who do not know about the differences between these forms.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/08/18/secure-ftp-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force and Excellence</title>
		<link>http://cosine.org/2007/08/13/force-excellence/</link>
		<comments>http://cosine.org/2007/08/13/force-excellence/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 06:47:00 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/08/13/force-excellence/</guid>
		<description><![CDATA[I read a quote this week that sums up a large part of why policies often fail to achieve their objectives: Just remember: people tend to resist that which is forced upon them. People tend to support that which they help to create. &#8212;Vince Pfaff Policies fail because they are forced upon people without any [...]]]></description>
			<content:encoded><![CDATA[<p>I read a quote this week that sums up a large part of why policies often fail to achieve their objectives:</p>
<blockquote><p>Just remember: people tend to resist that which is forced upon them.  People tend to support that which they help to create. &mdash;Vince Pfaff</p></blockquote>
<p>Policies fail because they are forced upon people without any input to address their needs and concerns.  This is counter to a culture of excellence, a mindset where people are enabled to perform their best and do so because they love what they do.</p>
<p>Policies were born out of a need to prohibit undesired activity.  We have names for the desired activities we want instead: best business practices, security controls, change management, and others.  These are good things indeed, but it does not change that policies exist to prohibit activity.  In the great attempt to stop bad things from happening, policies usually end up just preventing excellence from blooming in their &#8220;squish activities first, ask questions later&#8221; manner.</p>
<p><span id="more-18"></span>Policies are often like a law in a corporation and are enforced by the culture of the organization, if not by the threat of disciplinary action.  In any case, if someone has a need counter to a policy and does so by direct violation then he will find just how much force the organization can muster to defend the policy, though it may not come immediately if the violation is swept under the table.  If you have oppressive policies in your organization, you can be certain there are violations happening out of sight.  One way or another, those violations will cause problems of their own in time.</p>
<p>In a natural state, an individual will strive for excellence.  People all have something they are very good at, and they want to do it.  People that match their careers up to their desires have an awesome potential.  This is why new businesses are able to flourish and even show up the established behemoths.  A startup is highly focused and filled with people with lots of passion and drive for the product they make.  These people have little, if any, policy to stand in the way of their excellence, and when we see them in the news their excellence has already flowered into something beautiful.</p>
<p>Of course, not all startups succeed, but due to those that do we know it happens.  This point is important because if the large corporation that is being challenged was really a center of excellence then the startup should have <em>no</em> chance of ever succeeding.  An established company has a customer base already, and presumably some credentials in the field.  The established company already has the same focus as the startup&mdash;let us say they both make Widgets&mdash;and it has a lot more money and resources it can devote to producing those Widgets than the startup.  However, as the startup proceeds people notice that the new company&#8217;s Widgets are better or more convenient or have whatever it is people want in a Widget.  Why did not that innovation come from the established company?  The difference in the Widgets is due to the difference in individual excellence displayed by employees at each company.  Some people say that luck has something to do with it, too, but that is really an excuse for someone that does not work hard to make their own luck.</p>
<p>Policies are not the only cause of the erosion of excellence.  Actually, bad policies are more a symptom of bad management, which itself will erode excellence more than policies can.  However, the policies are often the visible agent of the oppression of excellence when bad management presides over an organization.  The real story behind bad policies is the bad management behind them, and the subject of bad management takes us back to Pfaff&#8217;s quote above.  Bad managers force orders upon their employees.  Good managers become co-creators with their employees.</p>
<p>The roles of policies under bad management are enforcement and control.  The roles of policies under good management is facilitating excellence and documenting foregone conclusions.  These are policies that are documentation of decided practices instead of being the ruler to slap the back of the hand; these policies might be used to remind people of their own decisions (and referred to just like a checklist) instead of telling them what someone else already decided for them.  What do the policies at your company do?</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/08/13/force-excellence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security of Ruby&#8217;s Kernel#rand</title>
		<link>http://cosine.org/2007/08/07/security-ruby-kernel-rand/</link>
		<comments>http://cosine.org/2007/08/07/security-ruby-kernel-rand/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 02:07:05 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/08/07/security-ruby-kernel-rand/</guid>
		<description><![CDATA[Last night I was at the Chicago Area Ruby Group, and there was a presentation by Trevor Turk on his El Dorado project. While he was showing us the code I saw the method that generates the application&#8217;s authentication token. I could not help but notice that the security of the authentication tokens depends greatly [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I was at the <a href="http://www.chirb.org/">Chicago Area Ruby Group</a>, and there was a presentation by <a href="http://almosteffortless.com/">Trevor Turk</a> on his <a href="http://code.google.com/p/eldorado/source">El Dorado</a> project.  While he was showing us the code I saw the method that generates the application&#8217;s authentication token.  I could not help but notice that the security of the authentication tokens depends greatly on the security of Ruby&#8217;s Kernel#rand method.  Traditionally default rand functions are a bit light on security, and so I wondered if that was also true of Ruby&#8217;s Kernel#rand.</p>
<p>Only one way to find out!  I downloaded a fresh copy of the source code for Ruby 1.8.6 and started poking around in random.c, where the function in question lives.  My findings are mixed, and I have good news and bad news to report!</p>
<p><span id="more-16"></span>The good news is that if the Unix character device /dev/urandom is available then the random number generator is seeded with a value based from a read from that device.  The /dev/urandom device is a &#8220;secure&#8221; pseudo-random number generator device, so the resulting random numbers are going to be pretty good.  Note that you are still at the mercy of how well your operating system implements the algorithm for /dev/urandom and how <em>that</em> number generator gets seeded, but generally it works pretty well.</p>
<p>The bad news is that if /dev/urandom does not exist then your random numbers come from a podge of the current time, process id, and a sequence.  That will get you a random number good enough for shuffling your deck of cards in a friendly game of Euchre, but you do not want to depend on it for your bank account&#8217;s security.</p>
<p>Should you use Kernel#rand on a system without /dev/urandom?  That depends.  How secure do you want your application to be?  If there is any level of money or privacy involved, then I think you better make sure Ruby can find your /dev/urandom device.  You also better verify that your operating system&#8217;s /dev/urandom algorithm is implemented well.</p>
<p>What if there are large amounts of money involved?  All I have spoken of so far is the security of the seed to the random number generator.  How good is the random number generator itself?  For high security applications, does it matter how good our seed value is if we fail to use a good algorithm to crunch it?</p>
<p>Once again there is good news and bad news on that front.  Ruby uses the <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">Mersenne Twister</a> random number algorithm developed in 1997 by Makoto Matsumoto.  Wouldn&#8217;t you know it that a Japanese algorithm is in use in a programming language from the same islands? <img src='http://cosine.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   The bad news is that it is not an algorithm that is naturally suited for secure applications&mdash;speed of number generation is its primary focus.  After being seeded the number generator will fall into a pattern.  The good news is that you need to generate lots of numbers before that pattern emerges, and it turns out that it can be used in secure applications with some limitations.  Please note that I am not a cryptographer, so I am gleaning this information from an external <a href="http://en.wikipedia.org/wiki/Mersenne_twister">source</a> or <a href="http://www.quadibloc.com/crypto/co4814.htm">two</a>.  Use it at your own risk.</p>
<p>But before you run out and use Kernel#rand on your new banking application, heed one more note of caution.  High security applications should not be depending on /dev/urandom for seeding another random number generator.  If you are going to be feeding a random number generator, why not get a real random number?  Systems that have /dev/urandom also have a /dev/random.  This latter device generates random numbers that do not get filtered through a random number generator.  Assuming your system has a good means of obtaining random bits to regurgitate to /dev/random and your application does not consume them too quickly (reads on /dev/random will block if it runs out of bits), you should seed your random number generator directly from /dev/random for your highest security applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/08/07/security-ruby-kernel-rand/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Idea for Process Teams</title>
		<link>http://cosine.org/2007/08/02/idea-process-teams/</link>
		<comments>http://cosine.org/2007/08/02/idea-process-teams/#comments</comments>
		<pubDate>Fri, 03 Aug 2007 01:14:06 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/08/02/idea-process-teams/</guid>
		<description><![CDATA[My previous post on Process Hell generated some thoughts from my friend Ryan at his blog in a posting called Policy, Subjectivity and Inteligence. It seems last year he had some similar thoughts in another post titled The &#8220;What isn&#8217;t easily measurable, doesn&#8217;t exist&#8221; Rule. I think he was spot on with why many costs [...]]]></description>
			<content:encoded><![CDATA[<p>My previous post on <a href="/2007/07/31/policy-hell/">Process Hell</a> generated some thoughts from my friend Ryan at his blog in a posting called <a href="http://ryan-technorabble.blogspot.com/2007/07/policy-subjectivity-and-intelligence.html">Policy, Subjectivity and Inteligence</a>.  It seems last year he had some similar thoughts in another post titled <a href="http://ryan-technorabble.blogspot.com/2006/08/rule.html">The &#8220;What isn&#8217;t easily measurable, doesn&#8217;t exist&#8221; Rule</a>.  I think he was spot on with why many costs are ignored by policy makers:</p>
<blockquote><p>It is easy for them [policy makers] to ignore the side effects, such as wasted bureaucratic efforts, delays to real progress, and other general dysfunctions. The side effects are outside of their purview, and highly difficult to measure. These two factors lead to application of the &#8220;What isn&#8217;t easily measurable, doesn&#8217;t exist&#8221; rule.</p></blockquote>
<p>I did some brainstorming about what kinds of changes an upper manager could make to the organization that would provide some relief to the situation without going through the tedious and expensive task of identifying costs that generally go unaccounted for.  I aimed for something simple enough that a brave manager can try it out with little effort but could really distinguish his company from most others (and hopefully in a positive way).</p>
<p><span id="more-14"></span>The idea is that the policy management team is made somewhat subservient to the teams affected by policy.  There is a policy committee that is comprised of the policy team and representatives from various affected areas.  The representatives each have one vote on policy decisions, and the policy team members have no vote but exist to facilitate creation, management, and follow-through of the resulting policies.  In communicating to the policy committee, management is able to specify <em>what</em> policies must exist but cannot specify any content for those policies.  Finally, any team that finds a particular policy too much of a burden may release their own version to address the issue.  If the team version cannot be reconciled with the official version within four weeks (times may vary by organization) then that team is no longer bound by the official policy and instead uses their version.</p>
<p>How did I arrive at this?  I focused first and foremost on keeping power in the hands of the affected teams.  If a company cannot measure the pain induced by policies upon its employees, then simply giving those employees power to correct the issueâ€”even at the cost of potentially losing conformityâ€”seems like sufficient counterbalance to me.  People do not want to stand out and be different.  They do not want to be tasked with managing their own version of a policy.  They will conform with the official version until it becomes cost prohibitive to do so, and they will likely put in healthy efforts at having the existing policy updated first.  Only when they feel their attempts at compromise are insufficiently met will they want to branch their policy.</p>
<p>Would this approach work?  I recognize that it might bring problems of its own.  A company may end up with a situation where every department ends up with its own version of almost every policy.  But then again, is that really a bad thing?  I do not think so.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/08/02/idea-process-teams/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Policy Hell</title>
		<link>http://cosine.org/2007/07/31/policy-hell/</link>
		<comments>http://cosine.org/2007/07/31/policy-hell/#comments</comments>
		<pubDate>Tue, 31 Jul 2007 23:46:33 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.cosine.org/2007/07/31/policy-hell/</guid>
		<description><![CDATA[One thing that I learned in five years of working for an FDA regulated company: policies are usually written to address fears instead of to solve problems or provide a return on investment. Often when one challenges the usefulness of a troublesome policy the answer is that Something Bad might happen if we did not [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that I learned in five years of working for an FDA regulated company:  policies are usually written to address fears instead of to solve problems or provide a return on investment.  Often when one challenges the usefulness of a troublesome policy the answer is that Something Bad <em>might</em> happen if we did not have the policy.  Never mind that the odds are miniscule of Something Bad happening.  Never mind that the cost of Something Bad is less than the cost of maintaining the policy and training the employees on it.  Never mind that the existence of the policy does not even prevent Something Bad; your company just hopes it makes Something Bad less likely.  Fear has taken over, and we must avoid Something Bad at all costs.</p>
<p>I do not mean to belittle all those policies out there, but I would be very surprised if more than 10% of policies in medium-to-large companies provide a net positive return on investment.</p>
<p><span id="more-12"></span><strong>Return on Investment</strong></p>
<p>The core of the problem is properly identifying the return on investment by quantifying both positive and negative influences of each policy and official procedure.  Most security organizations and managers do not do this well.  Instead of considering the benefits of a policy and contrasting them to the costs, they ignore the costs and narrow their focus on an illusionary idea, often false, of the benefit.</p>
<p>Why does this happen?  Why is it that people are unable to adequately assess the value of the policy? <strong>It is that most people cannot quantify costs.</strong>  Time equals money, but many people do not know how to perform calculations across that equation.  Time is the largest cost ignored by policy makers.</p>
<p><strong>Identifying Costs</strong></p>
<p>Some costs of policies and procedures are:</p>
<p>Additional capital and expense costs accrued directly against the budget: a change control procedure might require tracking tools that are bought and paid for directly against the budget.  These are generally noticed and the only costs reported in a typical situation.</p>
<p>Additional time to follow procedure:  if a policy requires that all documentation be in the same format, such as particular settings for font, margins, headers, footers, and standard sections (pseudo-justification of which is that everything looks neat and organized for auditors), then everyone that needs to create or modify a policy must be trained on those rules.  Additionally, if templates are not provided then everyone must spend time manually formatting the documents to fit the standard.  If one is lucky enough to have templates available, then one must not ignore the costs of creating and maintaining <em>those</em>.</p>
<p>Delays imposed:  sometimes one must wait until certain times for updates due to over-reaching policies.  If one has many sequential tasks to perform, he could be significantly delayedâ€”even by weeksâ€”by trivial work.</p>
<p>Necessary changes never implemented:  I regularly see situations where necessary work to prevent future losses is ignored because the policies make it too much of a hassle to get it done.  Management is simply not informed of the undone deed except perhaps in passing.  No one follows upâ€”to do so would add yet more burdensome tasks to an already overworked employee (overworked because their management thinks the process overhead on their activities is a fraction of what it actually is).</p>
<p><strong>Minimize Policies</strong></p>
<p>All I can suggest for now is to be very vigilant of all your policies.  Can you trim them back?  Can any be merged together?  Do they cover too much?  Do they present too much of a burden?  Can you lighten known burdens with minimal trimming of the policy&#8217;s benefit?  If you want to empower your IT staff, be their heroâ€”not their agitator.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/07/31/policy-hell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby, Rails, Applicaton Security, and more!</title>
		<link>http://cosine.org/2007/06/20/ruby-rails-applicaton-security/</link>
		<comments>http://cosine.org/2007/06/20/ruby-rails-applicaton-security/#comments</comments>
		<pubDate>Thu, 21 Jun 2007 03:28:01 +0000</pubDate>
		<dc:creator>Cosine Jeremiah</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://www.cosine.org/musings/2007/06/23/ruby-rails-applicaton-security-and-more/</guid>
		<description><![CDATA[I&#8217;ve decided that cosine.org should be dedicated to my favorite computer topics: Ruby, Rails, application security, and OpenBSD. This is all awesome stuff. Stuff that is awesomely interesting to me. However my level of knowledge in these topics varies a bit, and it creates a perplexing situation for me. Firstly, my recent computer research efforts [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided that cosine.org should be dedicated to my favorite computer topics:  Ruby, Rails, application security, and OpenBSD.  This is all awesome stuff.  Stuff that is awesomely interesting to me. However my level of knowledge in these topics varies a bit, and it creates a perplexing situation for me.</p>
<p><span id="more-6"></span> Firstly, my recent computer research efforts have been to learn yet more about application security.  I know what I know very well, but I also know when I feel a weakness in my knowledgeâ€”and I <em>need</em> to do more with application security to advance my knowledge there.  I have all the basics now; the next step is application.</p>
<p>Additionally, I need to do more with Rails.  I know Ruby very well, and it is absolutely the best programming language I have ever used. I have dabbled with Rails know the basics, but I need to do something useful with it so I have an ongoing Rails project to care for.  Without something like that my knowledge in Rails has not broken a mediocre level, and I have fallen behind in recent advances that the Rails core team has delivered recently.  An update to this very website into a Rails powered site is very likely! <img src='http://cosine.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>In summary, the two areas I want to target my development is application security and Rails.  Tune in to see what I decide to do with each of these.  Drop me a line if you want to chat about it!  I love talking about these subjects, so I will love to talk.</p>
]]></content:encoded>
			<wfw:commentRss>http://cosine.org/2007/06/20/ruby-rails-applicaton-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

