<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.0.0 (http://www.squarespace.com/) on Sun, 04 Jan 2009 08:09:31 GMT--><feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><title>Ruby on Rails Security Project</title><subtitle>Journal</subtitle><id>http://www.rorsecurity.info/journal/</id><link rel="alternate" type="application/xhtml+xml" href="http://www.rorsecurity.info/journal/"/><link rel="self" type="application/atom+xml" href="http://www.rorsecurity.info/journal/atom.xml"/><updated>2008-11-19T14:54:52Z</updated><generator uri="http://www.squarespace.com/" version="Squarespace Site Server v5.0.0 (http://www.squarespace.com/)">Squarespace</generator><entry><title>Circumvent Rails CSRF Protection</title><id>http://www.rorsecurity.info/journal/2008/11/19/circumvent-rails-csrf-protection.html</id><link rel="alternate" type="text/html" href="http://www.rorsecurity.info/journal/2008/11/19/circumvent-rails-csrf-protection.html"/><author><name>Heiko</name></author><published>2008-11-19T08:46:46Z</published><updated>2008-11-19T08:46:46Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>There is a security-related bug in <span style="text-decoration: underline;">Ruby on Rails 2.1.x and all 2.2. pre-releases</span>. The CSRF protection given by<br />the protect_from_forgery method may possibly be circumvented by a crafted request.</p>
<p>The problem is that Rails by design will not check the <a href="http://guides.rubyonrails.org/security.html#_csrf_countermeasures" target="_blank">authenticity token</a> if the request has certain content types that are typically not generated by browsers. According to the <a href="http://groups.google.com/group/rubyonrails-security/browse_thread/thread/d741ee286e36e301?hl=en" target="_blank">original security message</a>, this list also includes "text/plain" which may be generated by browsers. This <a href="http://pseudo-flaw.net/content/web-browsers/form-data-encoding-roundup/" target="_blank">form data encoding roundup</a> gives an overview of what can be generated by today's browsers. See <a href="http://github.com/rails/rails/commit/099a98e9b7108dae3e0f78b207e0a7dc5913bd1a" target="_blank">this changset</a> for details of which content types will be checked.</p>
<p>&nbsp;</p>
<h2>Possible Exploit<br /></h2>
<p>The content type can be set with the enctype attribute in HTML forms:</p>
<p>&lt;form method="post" enctype="text/plain" action="&lt;%= some_post_action_path(@var) %&gt;"&gt;&lt;%= submit_tag "Start" %&gt;&lt;/form&gt;</p>
<p>This was found in this <a href="http://rails.lighthouseapp.com/projects/8994/tickets/1145-bug-invalidauthenticitytoken-incorrectly-raised-for-xml-controllerdestroy-request#ticket-1145-29" target="_blank">Lighthouse ticket</a>. The <a href="http://groups.google.com/group/rubyonrails-security/browse_thread/thread/d741ee286e36e301?hl=en" target="_blank">original security message</a> states that Rails does not parse the parameters for these requests. However, I was able to craft requests where all parameters where correctly parsed and used.</p>
<p>&nbsp;</p>
<h2>Temporary Solution</h2>
<p>Users of 2.1.x releases are advised to insert the following code into a file in config/initializers/</p>
<p>Mime::Type.unverifiable_types.delete(:text)</p>
<p>Or you apply <a href="http://github.com/rails/rails/commit/099a98e9b7108dae3e0f78b207e0a7dc5913bd1a" target="_blank">this patch</a> for the 2.1.x releases. Users of Edge Rails should upgrade to the latest version.</p>
<p>&nbsp;</p>
<h2>Fixes</h2>
<p>Fixes will be in Rails version <a href="http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/milestones" target="_blank">2.1.3 and 2.2.2</a>.</p>]]></content></entry><entry><title>Rails Security Guide and Book</title><id>http://www.rorsecurity.info/journal/2008/11/4/rails-security-guide-and-book.html</id><link rel="alternate" type="text/html" href="http://www.rorsecurity.info/journal/2008/11/4/rails-security-guide-and-book.html"/><author><name>Heiko</name></author><published>2008-11-04T11:10:38Z</published><updated>2008-11-04T11:10:38Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>That's it, the Ruby on Rails Security guide is ready. It is available as a Rails manual at <a href="http://guides.rubyonrails.org/security.html">http://guides.rubyonrails.org/security.html</a> and as a free e-book at <a href="http://www.rorsecurity.info/the-book/">http://www.rorsecurity.info/the-book/</a>. The first batch of <a href="http://guides.rubyonrails.org/">the new Rails Guides</a> also includes 14 other quality manuals ranging from "Getting started", routing, testing and debugging.</p>
<p>So far, the online version of the guide is one long page, I hope it will be seperated soon. Meanwhile you can read the e-book version of it. For those of you looking for a quick overview of good practice and countermeasures, scan the document for the fragments <span style="background-color: #fffcdb;">that are highlighted.</span></p>
<p>I will be officially announcing the Guide at the <a href="http://www.owasp.org/index.php/OWASP_EU_Summit_2008">OWASP EU Summit</a> in Portugal this week.</p>]]></content></entry><entry><title>Header Injection And Response Splitting</title><id>http://www.rorsecurity.info/journal/2008/10/20/header-injection-and-response-splitting.html</id><link rel="alternate" type="text/html" href="http://www.rorsecurity.info/journal/2008/10/20/header-injection-and-response-splitting.html"/><author><name>Heiko</name></author><published>2008-10-20T13:16:00Z</published><updated>2008-10-20T13:16:00Z</updated><content type="html" xml:lang="en-US"><![CDATA[<p>I thought about the redirect_to method when I saw <a href="http://railscasts.com/episodes/131-going