<?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>Pervasive Code &#187; security</title>
	<atom:link href="http://www.pervasivecode.com/blog/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pervasivecode.com/blog</link>
	<description>Jamie Flournoy's Software Development Blog</description>
	<lastBuildDate>Mon, 26 Jul 2010 05:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Proper Error Handling in Rails Controllers</title>
		<link>http://www.pervasivecode.com/blog/2009/07/27/proper-error-handling-in-rails-controllers/</link>
		<comments>http://www.pervasivecode.com/blog/2009/07/27/proper-error-handling-in-rails-controllers/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 04:56:24 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/?p=131</guid>
		<description><![CDATA[Rails controllers can get out of hand if you&#8217;re not very careful. Skinny Controller Fat Model is a great start. But what about handling errors? Isn&#8217;t it enough to just let Rails catch your exception and show a 500 Server Error page?
No, it&#8217;s not. Falling back on 500 Server Error for everything outside of the [...]]]></description>
			<content:encoded><![CDATA[<p>Rails controllers can get out of hand if you&#8217;re not very careful. <a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model">Skinny Controller Fat Model</a> is a great start. But what about handling errors? Isn&#8217;t it enough to just let Rails catch your exception and show a 500 Server Error page?</p>
<p>No, it&#8217;s not. Falling back on 500 Server Error for everything outside of the &#8220;happy path&#8221; through your code is sloppy coding.<br />
<span id="more-131"></span><br />
I say this for three reasons:</p>
<p><b>The 5xx response codes are for server-side errors.</b></p>
<p>If the code is working properly but the request is wrong (no such document, an invalid request, or insufficient user privileges for the requested operation), the 4xx response codes are more appropriate. You should only return a 5xx series error message when your application is broken.</p>
<p><b>A generic &#8220;oops&#8221; page hides the cause of the error from the user.</b></p>
<p>Maybe the user followed a bad link, that goes to a document that has been deleted. They should see a 404 Not Found response, not a 500 Server Error. This is especially important if the user agent is a web service client actively under development. And remember that you can still customize the response body, so a 404 can show a search or site map to help them find the content that was Not Found, and a 403 might suggest that the user upgrade their subscription so they can see the Forbidden content.</p>
<p><b>Failing to trap bogus input is a recipe for a security vulnerability.</b></p>
<p>Rails will detect ridiculous input in many cases, but it doesn&#8217;t know about your business rules.</p>
<p>For example, what if someone fires up Firebug and figures out your API, and deletes her ex-boyfriend&#8217;s account because you forgot to check that the ID being deleted matches the currently logged in user? Oops.</p>
<p>You know who else got pwn3d because they put their security rules in the client? AOL. Don&#8217;t be like AOL. They got <a href="http://en.wikipedia.org/wiki/AOHell">pwn3d big time</a>. Make sure your controller handles the &#8220;unhappy path&#8221; too, and responds appropriately.</p>
<p>You make sure your controller handles these cases by writing tests, and checking that the response is correct. To do this, you need unambiguous errors that clearly explain what the controller didn&#8217;t like about the request. </p>
<p>Your controller tests should <i>never</i> expect an exception. Exceptions belong inside the application (such as between a model and a controller), not at the boundary.</p>
<p>Instead, you should be using something like <code>assert_response :bad_request</code>, and providing a useful textual message in the page that will help the user understand what they did wrong.</p>
<p>A nice bonus of using the right HTTP error responses is that your tests are more readable. And since controller tests tend to be really verbose already (mine tend to be ~10x as many LOC as the controller itself), the extra readability is really nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2009/07/27/proper-error-handling-in-rails-controllers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Silencing pointless reverse DNS warnings from OpenSSH</title>
		<link>http://www.pervasivecode.com/blog/2008/05/22/silencing-pointless-reverse-dns-warnings-from-openssh/</link>
		<comments>http://www.pervasivecode.com/blog/2008/05/22/silencing-pointless-reverse-dns-warnings-from-openssh/#comments</comments>
		<pubDate>Thu, 22 May 2008 08:51:51 +0000</pubDate>
		<dc:creator>Jamie Flournoy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2008/05/22/silencing-pointless-reverse-dns-warnings-from-openssh/</guid>
		<description><![CDATA[If you&#8217;ve been using SSH for long you&#8217;ve probably seen this at least once: Address 11.22.33.44 maps to www.foobar.com, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
Sometimes this is helpful. Sometimes this is really annoying and incorrect. Assuming you are a moderately well informed sysadmin and know that this message [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been using SSH for long you&#8217;ve probably seen this at least once: <code>Address 11.22.33.44 maps to www.foobar.com, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!</code></p>
<p>Sometimes this is helpful. Sometimes this is really annoying and incorrect. Assuming you are a moderately well informed sysadmin and know that this message can safely be ignored, you might have been stumped trying to silence it. You may have tried every option in <code>man ssh_options</code> and even some of your own (<code>STFU on</code>?) I think I may be able to help.<br />
<span id="more-74"></span><br />
First, let&#8217;s make sure we understand the situation. OpenSSH is trying to protect you from an exploit. If you are connecting via SSH to www.foobar.com for the first time, you may be vulnerable to a man in the middle attack. If the forward and reverse DNS don&#8217;t match, that might be a sign that this sort of attack is being attempted.</p>
<p>If you&#8217;re sure you know what you&#8217;re doing, though, and your OpenSSH client is warning you about a situation that you already know about, then try the SSH option:
<pre>GSSAPIAuthentication no</pre>
<p>(I figured this out by using the <code>-vv</code> option to the SSH command line client. It says <code>Next authentication method: gssapi-with-mic</code> right before the error.)</p>
<p>In my case the client and server are already acquainted via mutual public key exchange (client has known_hosts for the server, and server has authorized_keys for the client) so whether or not the DNS entries look <a href="http://www.urbandictionary.com/define.php?term=hinky">hinky</a> is immaterial. I&#8217;m in the process of migrating from one hosting environment to another so I can&#8217;t &#8220;fix&#8221; the DNS situation for another couple of weeks. Meanwhile I&#8217;m getting these warnings every hour in an email to root, which is annoying, as it currently forwards to me. And since I&#8217;m not using GSSAPI, turning it off is fine also.</p>
<p>Please do make sure you know that your situation is secure before disabling warnings like this. OK now I&#8217;ve said it enough times, make the annoying warnings go away.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pervasivecode.com/blog/2008/05/22/silencing-pointless-reverse-dns-warnings-from-openssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
