Sha256: 144c92de465fcb7cb9060b4a31fdc26a87e2e8af10e6d44e7a7b3fc14797153e

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'checks/base_check'
require 'processors/lib/find_call'

#Check for vulnerability in translate() helper that allows cross-site scripting
#http://groups.google.com/group/rubyonrails-security/browse_thread/thread/2b61d70fb73c7cc5
class CheckTranslateBug < BaseCheck
  Checks.add self

  def run_check
    if (version_between?('2.3.0', '2.3.99') and OPTIONS[:escape_html]) or 
        version_between?('3.0.0', '3.0.10') or
        version_between?('3.1.0', '3.1.1')

      if uses_translate?
        confidence = CONFIDENCE[:high]
      else
        confidence = CONFIDENCE[:med]
      end

      version = tracker.config[:rails_version]

      if version =~ /^3\.1/
        message = "Versions before 3.1.2 have a vulnerability in the translate helper."
      elsif version =~ /^3\.0/
        message = "Versions before 3.0.11 have a vulnerability in translate helper."
      else
        message = "Rails 2.3.x using the rails_xss plugin have a vulnerability in translate helper."
      end

      warn :warning_type => "Cross Site Scripting",
        :message => message,
        :confidence => confidence,
        :file => gemfile_or_environment
    end
  end

  def uses_translate?
    not tracker.find_call([], :translate).empty?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brakeman-0.9.1 lib/checks/check_translate_bug.rb