Class: Brakeman::CheckSanitizeConfigCve
- Inherits:
-
BaseCheck
- Object
- BaseCheck
- Brakeman::CheckSanitizeConfigCve
- Defined in:
- lib/brakeman/checks/check_sanitize_config_cve.rb
Instance Method Summary collapse
-
#check_config ⇒ Object
Look for config.action_view.sanitized_allowed_tags = ["select", "style"].
-
#check_safe_list_allowed_tags ⇒ Object
Look for Rails::Html::SafeListSanitizer.allowed_tags = ["select", "style"].
-
#check_sanitize_calls ⇒ Object
Look for sanitize ..., tags: ["select", "style"] and Rails::Html::SafeListSanitizer.new.sanitize(..., tags: ["select", "style"]).
- #cve_warning(confidence: :weak, result: nil) ⇒ Object
- #run_check ⇒ Object
Instance Method Details
#check_config ⇒ Object
Look for config.action_view.sanitized_allowed_tags = ["select", "style"]
52 53 54 55 56 57 58 59 |
# File 'lib/brakeman/checks/check_sanitize_config_cve.rb', line 52 def check_config sanitizer_config = tracker.config.rails.dig(:action_view, :sanitized_allowed_tags) if sanitizer_config and sanitizer_config @specific_warning = true cve_warning confidence: :high end end |
#check_safe_list_allowed_tags ⇒ Object
Look for Rails::Html::SafeListSanitizer.allowed_tags = ["select", "style"]
77 78 79 80 81 |
# File 'lib/brakeman/checks/check_sanitize_config_cve.rb', line 77 def tracker.find_call(target: :'Rails::Html::SafeListSanitizer', method: :allowed_tags=).each do |result| check_result result, result[:call].first_arg end end |
#check_sanitize_calls ⇒ Object
Look for sanitize ..., tags: ["select", "style"] and Rails::Html::SafeListSanitizer.new.sanitize(..., tags: ["select", "style"])
65 66 67 68 69 70 71 72 73 |
# File 'lib/brakeman/checks/check_sanitize_config_cve.rb', line 65 def check_sanitize_calls tracker.find_call(method: :sanitize, target: nil).each do |result| result end tracker.find_call(method: :sanitize, target: :'Rails::Html::SafeListSanitizer.new').each do |result| result end end |
#cve_warning(confidence: :weak, result: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/brakeman/checks/check_sanitize_config_cve.rb', line 24 def cve_warning confidence: :weak, result: nil return if result and not original? result = msg(msg_version(@gem_version, 'rails-html-sanitizer'), " is vulnerable to cross-site scripting when ", msg_code('select'), " and ", msg_code("style"), " tags are allowed ", msg_cve("CVE-2022-32209") ) unless result << ". Upgrade to 1.4.3 or newer" end warn :warning_type => "Cross-Site Scripting", :warning_code => :CVE_2022_32209, :message => , :confidence => confidence, :gem_info => gemfile_or_environment(:'rails-html-sanitizer'), :link_path => "https://groups.google.com/g/rubyonrails-security/c/ce9PhUANQ6s/m/S0fJfnkmBAAJ", :cwe_id => [79], :result => result end |
#run_check ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/brakeman/checks/check_sanitize_config_cve.rb', line 8 def run_check @specific_warning = false @gem_version = tracker.config.gem_version :'rails-html-sanitizer' if version_between? "0.0.0", "1.4.2", @gem_version check_config check_sanitize_calls unless @specific_warning # General warning about the vulnerable version cve_warning end end end |