Sha256: 2ede2729e5ea589c8382479514885e6ef43e0db4900d0ffb2f2ddb925eb9192e

Contents?: true

Size: 990 Bytes

Versions: 48

Compression:

Stored size: 990 Bytes

Contents

require 'brakeman/checks/base_check'

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

  @description = "Searches for evaluation of user input through template injection"

  #Process calls
  def run_check
    Brakeman.debug "Finding ERB.new calls"
    erb_calls = tracker.find_call :target => :ERB, :method => :new, :nested => true

    Brakeman.debug "Processing ERB.new calls"
    erb_calls.each do |call|
      process_result call
    end
  end

  #Warns if eval includes user input
  def process_result result
    return unless original? result

    if input = include_user_input?(result[:call].arglist)
      warn :result => result,
        :warning_type => "Template Injection",
        :warning_code => :erb_template_injection,
        :message => msg(msg_input(input), " used directly in ", msg_code("ERB"), " template, which might enable remote code execution"),
        :user_input => input,
        :confidence => :high
    end
  end
end

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
brakeman-min-5.1.0 lib/brakeman/checks/check_template_injection.rb
brakeman-min-5.0.4 lib/brakeman/checks/check_template_injection.rb
brakeman-lib-5.0.4 lib/brakeman/checks/check_template_injection.rb
brakeman-5.0.4 lib/brakeman/checks/check_template_injection.rb
brakeman-5.0.2 lib/brakeman/checks/check_template_injection.rb
brakeman-lib-5.0.2 lib/brakeman/checks/check_template_injection.rb
brakeman-min-5.0.2 lib/brakeman/checks/check_template_injection.rb
brakeman-5.0.1 lib/brakeman/checks/check_template_injection.rb
brakeman-lib-5.0.1 lib/brakeman/checks/check_template_injection.rb
brakeman-min-5.0.1 lib/brakeman/checks/check_template_injection.rb
brakeman-5.0.0 lib/brakeman/checks/check_template_injection.rb
brakeman-min-5.0.0 lib/brakeman/checks/check_template_injection.rb
brakeman-lib-5.0.0 lib/brakeman/checks/check_template_injection.rb
brakeman-4.10.1 lib/brakeman/checks/check_template_injection.rb
brakeman-lib-4.10.1 lib/brakeman/checks/check_template_injection.rb
brakeman-min-4.10.1 lib/brakeman/checks/check_template_injection.rb
brakeman-min-5.0.0.pre1 lib/brakeman/checks/check_template_injection.rb
brakeman-lib-5.0.0.pre1 lib/brakeman/checks/check_template_injection.rb
brakeman-5.0.0.pre1 lib/brakeman/checks/check_template_injection.rb
brakeman-4.10.0 lib/brakeman/checks/check_template_injection.rb