Sha256: 63ab49d5e99ddc714e7ccddec2fc255f82fe8dd4f192c7dd97f1ce2b87d9bd99

Contents?: true

Size: 1.18 KB

Versions: 35

Compression:

Stored size: 1.18 KB

Contents

require 'brakeman/checks/base_check'

#Check for vulnerability in nested attributes in Rails 2.3.9 and 3.0.0
#http://groups.google.com/group/rubyonrails-security/browse_thread/thread/f9f913d328dafe0c
class Brakeman::CheckNestedAttributes < Brakeman::BaseCheck
  Brakeman::Checks.add self

  @description = "Checks for nested attributes vulnerability in Rails 2.3.9 and 3.0.0"

  def run_check
    version = tracker.config[:rails_version]

    if (version == "2.3.9" or version == "3.0.0") and uses_nested_attributes?
      message = "Vulnerability in nested attributes (CVE-2010-3933). Upgrade to Rails version "

      if version == "2.3.9"
        message << "2.3.10"
      else
        message << "3.0.1"
      end

      warn :warning_type => "Nested Attributes",
        :warning_code => :CVE_2010_3933,
        :message => message,
        :confidence => CONFIDENCE[:high],
        :file => gemfile_or_environment,
        :link_path => "https://groups.google.com/d/topic/rubyonrails-security/-fkT0yja_gw/discussion"
    end
  end

  def uses_nested_attributes?
    active_record_models.each do |name, model|
      return true if model[:options][:accepts_nested_attributes_for]
    end

    false
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
brakeman-2.6.3 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.6.3 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.6.2 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.6.2 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.6.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.6.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.6.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.6.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.5.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.5.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.4.3 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.4.3 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.4.2 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.4.2 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.4.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.4.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.4.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.4.0 lib/brakeman/checks/check_nested_attributes.rb
brakeman-min-2.3.1 lib/brakeman/checks/check_nested_attributes.rb
brakeman-2.3.1 lib/brakeman/checks/check_nested_attributes.rb