Sha256: 337fe64247482fb28010ed7409c0da960d5edc431a3dce7b4b16f8616fa57587

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

require 'brakeman/checks/base_check'

class Brakeman::CheckRenderDoS < Brakeman::BaseCheck
  Brakeman::Checks.add self

  @description = "Warn about denial of service with render :text (CVE-2014-0082)"

  def run_check
    if version_between? "3.0.0", "3.0.20" or
       version_between? "3.1.0", "3.1.12" or
       version_between? "3.2.0", "3.2.16"

      tracker.find_call(:target => nil, :method => :render).each do |result|
        if text_render? result
          warn_about_text_render
          break
        end
      end
    end
  end

  def text_render? result
    node_type? result[:call], :render and
    result[:call].render_type == :text
  end

  def warn_about_text_render
    message = "Rails #{tracker.config[:rails_version]} has a denial of service vulnerability (CVE-2014-0082). Upgrade to Rails version 3.2.17"

    warn :warning_type => "Denial of Service",
      :warning_code => :CVE_2014_0082,
      :message => message,
      :confidence => CONFIDENCE[:high],
      :link_path => "https://groups.google.com/d/msg/rubyonrails-security/LMxO_3_eCuc/ozGBEhKaJbIJ",
      :gem_info => gemfile_or_environment
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
brakeman-3.0.5 lib/brakeman/checks/check_render_dos.rb
brakeman-min-3.0.5 lib/brakeman/checks/check_render_dos.rb
brakeman-3.0.4 lib/brakeman/checks/check_render_dos.rb
brakeman-min-3.0.4 lib/brakeman/checks/check_render_dos.rb
brakeman-min-3.0.3 lib/brakeman/checks/check_render_dos.rb
brakeman-3.0.3 lib/brakeman/checks/check_render_dos.rb
brakeman-min-3.0.2 lib/brakeman/checks/check_render_dos.rb
brakeman-3.0.2 lib/brakeman/checks/check_render_dos.rb
brakeman-min-3.0.1 lib/brakeman/checks/check_render_dos.rb
brakeman-3.0.1 lib/brakeman/checks/check_render_dos.rb
brakeman-3.0.0 lib/brakeman/checks/check_render_dos.rb
brakeman-min-3.0.0 lib/brakeman/checks/check_render_dos.rb