Sha256: 434addc63c6cb68ae2475b8c65e3c498498c3491d8e2e6480652da89d6c17f79

Contents?: true

Size: 1.21 KB

Versions: 37

Compression:

Stored size: 1.21 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 = rails_version

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

      if version == "2.3.9"
        message << msg_version("2.3.10")
      else
        message << msg_version("3.0.1")
      end

      warn :warning_type => "Nested Attributes",
        :warning_code => :CVE_2010_3933,
        :message => message,
        :confidence => :high,
        :gem_info => gemfile_or_environment,
        :link_path => "https://groups.google.com/d/topic/rubyonrails-security/-fkT0yja_gw/discussion",
        :cwe_id => [20]
    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

37 entries across 37 versions & 3 rubygems

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