<?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>Startup Security &#187; Rails</title>
	<atom:link href="http://startupsecurity.info/blog/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://startupsecurity.info</link>
	<description>Security, for Startups</description>
	<lastBuildDate>Wed, 16 Dec 2009 18:42:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails :limit bug history</title>
		<link>http://startupsecurity.info/blog/2008/11/26/rails-limit-bug-history/</link>
		<comments>http://startupsecurity.info/blog/2008/11/26/rails-limit-bug-history/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 00:23:00 +0000</pubDate>
		<dc:creator>Damon Cortesi</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[SQL Injection]]></category>

		<guid isPermaLink="false">http://startupsecurity.info/?p=111</guid>
		<description><![CDATA[At my presentation last night on web application security, I demo&#8217;ed a SQL Injectable Ruby on Rails application. 
One of the questions that resulted from that, somewhat in shock, was how long this bug had existed in a public open-source project. Referring back to the original discoverer, it seems this bug has persisted through the [...]]]></description>
			<content:encoded><![CDATA[<p>At my <a href="/blog/2008/11/24/event-hacking-and-compliance-in-a-web-20-world/">presentation last night on web application security</a>, I demo&#8217;ed a SQL Injectable Ruby on Rails application. </p>
<p>One of the questions that resulted from that, somewhat in shock, was how long this bug had existed in a public open-source project. Referring back to the <a href="http://blog.innerewut.de/2008/6/16/why-you-should-upgrade-to-rails-2-1">original discoverer</a>, it seems this bug has persisted through the lifetime of the Rails project (i.e. Rails 1.2 and 2.0 were vulnerable as well). </p>
<p>Looking back in time, we can actually see the <a href="http://github.com/rails/rails/commit/ee8d110068e958b400987b5f224e14e292fd0558">March 2005 commit</a> where the limit functionality was added to the MySQL adapter. If you have javascript enabled, I&#8217;ve pulled out the relevant bits below. The interesting thing to notice is that some sanitization is performed if both a limit and offset parameter exist, but if only the limit parameter exists&#8230;no sanitization is done.</p>
<p><script src="http://gist.github.com/29636.js"></script></p>
<p>There is some good discussion about how to <a href="http://www.rorsecurity.info/2008/09/08/sql-injection-issue-in-limit-and-offset-parameter/">exploit this :limit bug on the Ruby on Rails Security Project blog</a>.</p>
<p>Finally, we can see where this SQL Injection was <a href="http://github.com/rails/rails/commit/3282bf3b5016f0c9028cfff1012e8c31a13b40b7">fixed</a> earlier this year. And if you&#8217;re curious, here&#8217;s what <a href="http://github.com/rails/rails/tree/3282bf3b5016f0c9028cfff1012e8c31a13b40b7/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb#L117">sanitize_limit</a> does. </p>
<p>That being said, I suppose we could enter into the old argument of whether closed or open-source is a more secure model. But realistically, bugs exist in any project &#8211; it&#8217;s the process and integration of security into that specific project&#8217;s development that determine it&#8217;s resulting security and risk profile. </p>
]]></content:encoded>
			<wfw:commentRss>http://startupsecurity.info/blog/2008/11/26/rails-limit-bug-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
