Class: Dawn::Kb::OwaspRorCheatSheet::CheckForSafeRedirectAndForward

Inherits:
Object
  • Object
show all
Includes:
PatternMatchCheck
Defined in:
lib/dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward.rb

Constant Summary

Constants included from PatternMatchCheck

PatternMatchCheck::EXCLUSION_LIST

Constants included from BasicCheck

BasicCheck::ALLOWED_FAMILIES

Instance Attribute Summary

Attributes included from PatternMatchCheck

#attack_pattern, #attack_pattern_is_regex, #avoid_comments, #negative_search, #root_dir

Attributes included from BasicCheck

#applies, #aux_links, #check_family, #cve, #cvss, #cwe, #debug, #evidences, #fixes_version, #kind, #message, #mitigated, #name, #osvdb, #owasp, #priority, #release_date, #remediation, #ruby_version, #ruby_vulnerable_versions, #severity, #status, #target_version, #title

Instance Method Summary collapse

Methods included from PatternMatchCheck

#must_exclude?

Methods included from BasicCheck

#applies_to?, #cve_link, #cvss_score, families, #family, #family=, #lint, #mitigated?, #nvd_link, #osvdb_link, #rubysec_advisories_link

Methods included from Utils

#__debug_me_and_return, #debug_me, #debug_me_and_return_false, #debug_me_and_return_true

Constructor Details

#initializeCheckForSafeRedirectAndForward

Returns a new instance of CheckForSafeRedirectAndForward.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward.rb', line 8

def initialize
  message = <<-EOT
Web applications often require the ability to dynamically redirect users based
on client-supplied data. To clarify, dynamic redirection usually entails the
client including a URL in a parameter within a request to the application. Once
received by the application, the user is redirected to the URL specified in the
request.

For example: http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout

The above request would redirect the user to http://www.example.com/checkout.

The security concern associated with this functionality is leveraging an
organization's trusted brand to phish users and trick them into visiting a
malicious site, in our example, "badhacker.com".

Example: http://www.example.com/redirect?url=http://badhacker.com

The most basic, but restrictive protection is to use the :only_path option.
Setting this to true will essentially strip out any host information.
  EOT

  super({
    :name=>"Owasp Ror CheatSheet: Check for safe redirect and forward",
    :kind=>Dawn::KnowledgeBase::PATTERN_MATCH_CHECK,
    :applies=>["rails"],
    :glob=>"*.rb",
    :aux_links=>["https://www.owasp.org/index.php/Ruby_on_Rails_Cheatsheet"],
    :message=>message,
    :attack_pattern => ["redirect_to"],
    :mitigation=>"The most basic, but restrictive protection is to use the :only_path option. Setting this to true will essentially strip out any host information.",
    :severity=>:info,
    :check_family=>:owasp_ror_cheatsheet
  })
  # @debug = true

end

Instance Method Details

#vuln?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
# File 'lib/dawn/kb/owasp_ror_cheatsheet/check_for_safe_redirect_and_forward.rb', line 45

def vuln?
  super
  ret = []
  @evidences.each do |ev|
    ret << ev unless ev[:matches].include? ":only_path => true"
  end
  @evidences = ret unless ret.empty?
  return @evidences.empty?
end