<?xml version="1.0" encoding="UTF-8"?>
<newsinformation>
  <created-at type="datetime">2009-06-09T00:56:39Z</created-at>
  <description>&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt;A security problem has been reported with the digest authentication code in Ruby on Rails. This vulnerability can allow users to bypass your password protection. This vulnerability has been publicly disclosed on several websites, users are advised to take the mitigating steps described below immediately.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt;The issue comes from the handling of the block passed to &lt;ins&gt;authenticate_or_request_with_http_digest&lt;/ins&gt;. This block must return the user&amp;rsquo;s password in the clear, or a sha1 hash of the user&amp;rsquo;s password. Unfortunately the documentation was unclear on this and the examples cited would return &lt;strong&gt;nil&lt;/strong&gt; if the user was not found.  The correct behaviour if the user doesn&amp;rsquo;t exist is to return &lt;strong&gt;false&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt;If the return value was nil, rails proceeded to verify this value against the provided password. Because of this an attacker can provide an invalid username and no password and authentication will succeed.&lt;/span&gt;&lt;/p&gt;
&lt;h2 style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt;Fixed Versions&lt;/span&gt;&lt;/h2&gt;
&lt;p style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt;We have altered the behaviour of the relevant code to make &lt;ins&gt;nil&lt;/ins&gt; an authentication failure. This fix has been pushed to 2-3-stable and will be present in 2.3.3 due to be released in the next few days. All versions of edge rails after commit &lt;/span&gt;&lt;a href=&quot;http://github.com/rails/rails/commit/1ad57cfe2fbda58439e4b7f84008ad23bc68e8b0&quot;&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt;1ad57cfe2fbda58439e4b7f84008ad23bc68e8b0&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Comic Sans MS;&quot;&gt; contain the fix.&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;Steps to Protect your application.&lt;/h2&gt;
&lt;p&gt;Users can protect themselves without upgrading by simply ensuring that their authentication blocks never return nil. To take an example from the documentation:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;authenticate_or_request_with_http_digest(REALM) do |username|&lt;br /&gt;  USERS[username]&lt;br /&gt;end&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Should instead be something like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;authenticate_or_request_with_http_digest(REALM) do |username|&lt;br /&gt;  USERS[username] || false&lt;br /&gt;end&lt;/code&gt;&lt;/pre&gt;</description>
  <id type="integer">5</id>
  <news-date type="datetime">2009-06-09T00:55:00Z</news-date>
  <title>Security Problem with authenticate_with_http_digest</title>
  <updated-at type="datetime">2009-06-09T01:15:59Z</updated-at>
</newsinformation>
