Sha256: dbce27c2fe45691c47ef3258c584747bf035d05f72a769c6c47c7ccc0b17125b

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

require 'brakeman/checks/base_check'

#Checks for uses of strip_tags in Rails versions before 2.3.13 and 3.0.10
#http://groups.google.com/group/rubyonrails-security/browse_thread/thread/2b9130749b74ea12
class Brakeman::CheckStripTags < Brakeman::BaseCheck
  Brakeman::Checks.add self

  @description = "Report strip_tags vulnerability in versions before 2.3.13 and 3.0.10"

  def run_check
    if (version_between?('2.0.0', '2.3.12') or 
        version_between?('3.0.0', '3.0.9')) and uses_strip_tags?

      if tracker.config[:rails_version] =~ /^3/
        message = "Versions before 3.0.10 have a vulnerability in strip_tags: CVE-2011-2931"
      else
        message = "Versions before 2.3.13 have a vulnerability in strip_tags: CVE-2011-2931"
      end

      warn :warning_type => "Cross Site Scripting",
        :message => message,
        :confidence => CONFIDENCE[:high],
        :file => gemfile_or_environment
    end
  end

  def uses_strip_tags?
    Brakeman.debug "Finding calls to strip_tags()"

    not tracker.find_call(:target => false, :method => :strip_tags).empty?
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
brakeman-1.6.2 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.6.1 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.6.0 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.6.0.pre1 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.5.3 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.5.2 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.5.1 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.5.0 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.4.0 lib/brakeman/checks/check_strip_tags.rb
brakeman-1.3.0 lib/brakeman/checks/check_strip_tags.rb