Rails 3.2.17, 4.0.3 and 4.1.0.beta2 have been released!

Riding Rails: Rails 3.2.17, 4.0.3 and 4.1.0.beta2 have been released!
CVE対策です。定期的にでますね。

CVE-2014-0080

Data Injection Vulnerability in Active Record (CVE-2014-0080) - Google グループ
PostgreSQL に配列として突っ込むときに、injectionされる可能性があったようです。
影響範囲はRails4系。

Workarounds

最新版いれれない人用。
patch見た方がわかりやすいですが、一応掲載。

module ActiveRecord 
  module ConnectionAdapters 
    class PostgreSQLColumn 
      module Cast 
        alias :old_quote_and_escape :quote_and_escape 

        ARRAY_ESCAPE = "\\" * 2 * 2 # escape the backslash twice for PG arrays 
        def quote_and_escape(value) 
          case value 
          when "NULL", Numeric 
            value 
          else 
            value = value.gsub(/\\/, ARRAY_ESCAPE) 
            value.gsub!(/"/,"\\\"") 
            "\"#{value}\"" 
          end 
        end 
      end 
    end 
  end 
end 

 

CVE-2014-0081

XSS Vulnerability in number_to_currency, number_to_percentage and number_to_human (CVE-2014-0081) - Google グループ
number_to_currency, number_to_percentage and number_to_human に脆弱性があったようです。
影響範囲は3、4系どちらもです。

Workarounds

最新版いれれない人用。

# before
<%= number_to_currency(1.02, format: params[:format]) %> 
# after
<%= number_to_currency(1.02, format: h(params[:format])) %> 

h追加するだけです。

 

CVE-2014-0082

Denial of Service Vulnerability in Action View when using render :text (CVE-2014-0082) - Google グループ
render :text の脆弱性です。
影響範囲は3系です。
headerに特殊文字をついかすると、symbolに変換されてGCされなくなって サービス落ちるというやつのようです。

Workarounds

最新版いれれない人用。

ActiveSupport.on_load(:action_view) do 
  ActionView::Template::Text.class_eval do 
    def formats 
      [@mime_type.respond_to?(:ref) ? @mime_type.ref : @mime_type.to_s] 
    end 
  end 
end