Sha256: 56dfc408707bde70d20f92d10eb58137df2472f5e73f6aaf0fd1ac98ed8c4d5b

Contents?: true

Size: 1.24 KB

Versions: 40

Compression:

Stored size: 1.24 KB

Contents

require 'brakeman/checks/base_check'

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

  @description = "Checks for mime type denial of service (CVE-2016-0751)"

  def run_check
    fix_version = case
               when version_between?("3.0.0", "3.2.22")
                 "3.2.22.1"
               when version_between?("4.0.0", "4.1.14")
                 "4.1.14.1"
               when version_between?("4.2.0", "4.2.5")
                 "4.2.5.1"
               else
                 return
               end

    return if has_workaround?

    message = msg(msg_version(rails_version), " is vulnerable to denial of service via mime type caching ", msg_cve("CVE-2016-0751"), ". Upgrade to ", msg_version(fix_version))

    warn :warning_type => "Denial of Service",
      :warning_code => :CVE_2016_0751,
      :message => message,
      :confidence => :medium,
      :gem_info => gemfile_or_environment,
      :link_path => "https://groups.google.com/d/msg/rubyonrails-security/9oLY_FCzvoc/w9oI9XxbFQAJ",
      :cwe_id => [399]
  end

  def has_workaround?
    tracker.find_call(target: :Mime, method: :const_set).any? do |match|
      arg = match[:call].first_arg

      symbol? arg and arg.value == :LOOKUP
    end
  end
end

Version data entries

40 entries across 40 versions & 3 rubygems

Version Path
brakeman-7.0.0 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-lib-7.0.0 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-min-7.0.0 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.2.2 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-lib-6.2.2 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-min-6.2.2 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.2.2.rc1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-min-6.2.1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-lib-6.2.1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.2.1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.2.0 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-lib-6.2.0 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-min-6.2.0 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.1.2 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-lib-6.1.2 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-min-6.1.2 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-min-6.1.1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-lib-6.1.1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.1.1 lib/brakeman/checks/check_mime_type_dos.rb
brakeman-6.1.0 lib/brakeman/checks/check_mime_type_dos.rb