rails-html-sanitizer 1.0.0

8 security vulnerabilities found in version 1.0.0

Inefficient Regular Expression Complexity in rails-html-sanitizer

high severity CVE-2022-23517
high severity CVE-2022-23517
Patched versions: >= 1.4.4

Summary

Certain configurations of rails-html-sanitizer < 1.4.4 use an inefficient regular expression that is susceptible to excessive backtracking when attempting to sanitize certain SVG attributes. This may lead to a denial of service through CPU resource consumption.

Mitigation

Upgrade to rails-html-sanitizer >= 1.4.4.

Possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer

medium severity CVE-2022-32209
medium severity CVE-2022-32209
Patched versions: >= 1.4.3

There is a possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer. This vulnerability has been assigned the CVE identifier CVE-2022-32209.

Versions Affected: ALL Not affected: NONE Fixed Versions: v1.4.3

Impact

A possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer may allow an attacker to inject content if the application developer has overridden the sanitizer's allowed tags to allow both select and style elements.

Code is only impacted if allowed tags are being overridden. This may be done via application configuration:

# In config/application.rb
config.action_view.sanitized_allowed_tags = ["select", "style"]

see https://guides.rubyonrails.org/configuring.html#configuring-action-view

Or it may be done with a :tags option to the Action View helper sanitize:

<%= sanitize @comment.body, tags: ["select", "style"] %>

see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize

Or it may be done with Rails::Html::SafeListSanitizer directly:

# class-level option
Rails::Html::SafeListSanitizer.allowed_tags = ["select", "style"]

or

# instance-level option
Rails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: ["select", "style"])

All users overriding the allowed tags by any of the above mechanisms to include both "select" and "style" should either upgrade or use one of the workarounds immediately.

Workarounds

Remove either select or style from the overridden allowed tags.

Possible XSS vulnerability with certain configurations of rails-html-sanitizer

medium severity CVE-2022-23520
medium severity CVE-2022-23520
Patched versions: >= 1.4.4

Summary

There is a possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer. This is due to an incomplete fix of CVE-2022-32209.

  • Versions affected: ALL
  • Not affected: NONE
  • Fixed versions: 1.4.4

Impact

A possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer may allow an attacker to inject content if the application developer has overridden the sanitizer's allowed tags to allow both "select" and "style" elements.

Code is only impacted if allowed tags are being overridden using either of the following two mechanisms:

  1. Using the Rails configuration config.action_view.sanitized_allow_tags=:
# In config/application.rb
config.action_view.sanitized_allowed_tags = ["select", "style"]

(see https://guides.rubyonrails.org/configuring.html#configuring-action-view)

  1. Using the class method Rails::Html::SafeListSanitizer.allowed_tags=:
# class-level option
Rails::Html::SafeListSanitizer.allowed_tags = ["select", "style"]

All users overriding the allowed tags by either of the above mechanisms to include both "select" and "style" should either upgrade or use one of the workarounds immediately.

NOTE: Code is not impacted if allowed tags are overridden using either of the following mechanisms:

  • the :tags option to the Action View helper method sanitize.
  • the :tags option to the instance method SafeListSanitizer#sanitize.

Workarounds

Remove either "select" or "style" from the overridden allowed tags.

Possible XSS vulnerability with certain configurations of rails-html-sanitizer

medium severity CVE-2022-23519
medium severity CVE-2022-23519
Patched versions: >= 1.4.4

Summary

There is a possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer.

  • Versions affected: ALL
  • Not affected: NONE
  • Fixed versions: 1.4.4

Impact

A possible XSS vulnerability with certain configurations of Rails::Html::Sanitizer may allow an attacker to inject content if the application developer has overridden the sanitizer's allowed tags in either of the following ways:

  • allow both "math" and "style" elements,
  • or allow both "svg" and "style" elements

Code is only impacted if allowed tags are being overridden. Applications may be doing this in four different ways:

  1. using application configuration:
# In config/application.rb
config.action_view.sanitized_allowed_tags = ["math", "style"]
# or
config.action_view.sanitized_allowed_tags = ["svg", "style"]

see https://guides.rubyonrails.org/configuring.html#configuring-action-view

  1. using a :tags option to the Action View helper sanitize:
<%= sanitize @comment.body, tags: ["math", "style"] %>
<%# or %>
<%= sanitize @comment.body, tags: ["svg", "style"] %>

see https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize

  1. using Rails::Html::SafeListSanitizer class method allowed_tags=:
# class-level option
Rails::Html::SafeListSanitizer.allowed_tags = ["math", "style"]
# or
Rails::Html::SafeListSanitizer.allowed_tags = ["svg", "style"]
  1. using a :tags options to the Rails::Html::SafeListSanitizer instance method sanitize:
# instance-level option
Rails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: ["math", "style"])
# or
Rails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: ["svg", "style"])

All users overriding the allowed tags by any of the above mechanisms to include (("math" or "svg") and "style") should either upgrade or use one of the workarounds immediately.

Workarounds

Remove "style" from the overridden allowed tags, or remove "math" and "svg" from the overridden allowed tags.

XSS vulnerability in rails-html-sanitizer

medium severity CVE-2018-3741
medium severity CVE-2018-3741
Patched versions: >= 1.0.4

There is a possible XSS vulnerability in rails-html-sanitizer. The gem allows non-whitelisted attributes to be present in sanitized output when input with specially-crafted HTML fragments, and these attributes can lead to an XSS attack on target applications.

This issue is similar to CVE-2018-8048 in Loofah.

Possible XSS vulnerability in rails-html-sanitizer

medium severity CVE-2015-7580
medium severity CVE-2015-7580
Patched versions: >= 1.0.3

There is a possible XSS vulnerability in the white list sanitizer in the rails-html-sanitizer gem. This vulnerability has been assigned the CVE identifier CVE-2015-7580.

Versions Affected: All. Not affected: None. Fixed Versions: v1.0.3

Impact

Carefully crafted strings can cause user input to bypass the sanitization in the white list sanitizer which will can lead to an XSS attack.

Vulnerable code will look something like this:

<%= sanitize user_input, tags: %w(em) %>

All users running an affected release should either upgrade or use one of the workarounds immediately.

Releases

The FIXED releases are available at the normal locations.

Workarounds

Putting the following monkey patch in an initializer can help to mitigate the issue:

class Rails::Html::PermitScrubber
  alias :old_scrub :scrub
  alias :old_skip_node? :skip_node?

  def scrub(node)
    if node.cdata?
      text = node.document.create_text_node node.text
      node.replace text
      return CONTINUE
    end
    old_scrub node
  end

  def skip_node?(node); node.text?; end
end

Patches

To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset.

  • 1-0-whitelist_sanitizer_xss.patch - Patch for 1.0 series

Credits

Thanks to Arnaud Germis, Nate Clark, and John Colvin for reporting this issue.

Moderate severity vulnerability that affects rails-html-sanitizer

medium severity CVE-2015-7579
medium severity CVE-2015-7579
Affected versions: < 1.0.3

Cross-site scripting (XSS) vulnerability in the rails-html-sanitizer gem 1.0.2 for Ruby on Rails 4.2.x and 5.x allows remote attackers to inject arbitrary web script or HTML via an HTML entity that is mishandled by the Rails::Html::FullSanitizer class.

Possible XSS vulnerability in rails-html-sanitizer

medium severity CVE-2015-7578
medium severity CVE-2015-7578
Patched versions: >= 1.0.3

There is a possible XSS vulnerability in rails-html-sanitizer. This vulnerability has been assigned the CVE identifier CVE-2015-7578.

Versions Affected: All. Not affected: None. Fixed Versions: 1.0.3

Impact

There is a possible XSS vulnerability in rails-html-sanitizer. Certain attributes are not removed from tags when they are sanitized, and these attributes can lead to an XSS attack on target applications.

All users running an affected release should either upgrade or use one of the workarounds immediately.

Releases

The FIXED releases are available at the normal locations.

Workarounds

There are no feasible workarounds for this issue.

Patches

To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset.

  • 1-0-sanitize_data_attributes.patch - Patch for 1.0 series

Credits

Thanks to Ben Murphy and Marien for reporting this.

No officially reported memory leakage issues detected.


This gem version does not have any officially reported memory leaked issues.

No license issues detected.


This gem version has a license in the gemspec.

This gem version is available.


This gem version has not been yanked and is still available for usage.