VYPR
Moderate severityNVD Advisory· Published Jun 24, 2022· Updated Nov 3, 2025

CVE-2022-32209

CVE-2022-32209

Description

# Possible XSS Vulnerability in Rails::Html::SanitizerThere 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: ALLNot affected: NONEFixed Versions: v1.4.3## ImpactA 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:``ruby# In config/application.rbconfig.action_view.sanitized_allowed_tags = ["select", "style"]`see https://guides.rubyonrails.org/configuring.html#configuring-action-viewOr 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-sanitizeOr it may be done with Rails::Html::SafeListSanitizer directly:`ruby# class-level optionRails::Html::SafeListSanitizer.allowed_tags = ["select", "style"]`or`ruby# instance-level optionRails::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.## ReleasesThe

FIXED releases are available at the normal locations.## WorkaroundsRemove either

select or style from the overridden allowed tags.## CreditsThis vulnerability was responsibly reported by windshock.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

CVE-2022-32209 is an XSS vulnerability in Rails::Html::Sanitizer when both 'select' and 'style' tags are allowed, enabling script injection.

Vulnerability

CVE-2022-32209 is a cross-site scripting (XSS) vulnerability in the Rails::Html::Sanitizer library, which is used by Rails applications to sanitize HTML input. The flaw occurs when an application developer overrides the default allowed tags to include both select and style elements. In such configurations, the sanitizer fails to properly escape or remove dangerous content, allowing an attacker to inject arbitrary HTML and JavaScript [1][2].

Exploitation

An attacker can exploit this vulnerability by submitting crafted input that includes malicious code within select or style tags. The attack is only possible if the application explicitly allows both tags via configuration (e.g., config.action_view.sanitized_allowed_tags = ["select", "style"]) or via the :tags option in the sanitize helper. No authentication is required if the input is user-controllable, such as comments or profile fields [4].

Impact

Successful exploitation allows an attacker to execute arbitrary JavaScript in the context of the victim's browser. This can lead to session hijacking, data theft, defacement, or other malicious actions typically associated with stored XSS attacks [2].

Mitigation

The vulnerability is fixed in version 1.4.3 of the rails-html-sanitizer gem. Users who cannot upgrade immediately should remove either select or style from the overridden allowed tags as a workaround [1][4].

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
rails-html-sanitizerRubyGems
< 1.4.31.4.3

Affected products

13

Patches

1
45a5c10fed3d

fix: modify safelist option if it contains both `select` and `style`

https://github.com/rails/rails-html-sanitizerMike DalessioJun 9, 2022via ghsa
2 files changed · +41 1
  • lib/rails/html/sanitizer.rb+18 1 modified
    @@ -141,8 +141,25 @@ def sanitize_css(style_string)
     
           private
     
    +      def loofah_using_html5?
    +        # future-proofing, see https://github.com/flavorjones/loofah/pull/239
    +        Loofah.respond_to?(:html5_mode?) && Loofah.html5_mode?
    +      end
    +
    +      def remove_safelist_tag_combinations(tags)
    +        if !loofah_using_html5? && tags.include?("select") && tags.include?("style")
    +          warn("WARNING: #{self.class}: removing 'style' from safelist, should not be combined with 'select'")
    +          tags.delete("style")
    +        end
    +        tags
    +      end
    +
           def allowed_tags(options)
    -        options[:tags] || self.class.allowed_tags
    +        if options[:tags]
    +          remove_safelist_tag_combinations(options[:tags])
    +        else
    +          self.class.allowed_tags
    +        end
           end
     
           def allowed_attributes(options)
    
  • test/sanitizer_test.rb+23 0 modified
    @@ -581,6 +581,25 @@ def test_exclude_node_type_comment
         assert_equal("<div>text</div><b>text</b>", safe_list_sanitize("<div>text</div><!-- comment --><b>text</b>"))
       end
     
    +  def test_disallow_the_dangerous_safelist_combination_of_select_and_style
    +    input = "<select><style><script>alert(1)</script></style></select>"
    +    tags = ["select", "style"]
    +    warning = /WARNING: Rails::Html::SafeListSanitizer: removing 'style' from safelist/
    +    sanitized = nil
    +    invocation = Proc.new { sanitized = safe_list_sanitize(input, tags: tags) }
    +
    +    if html5_mode?
    +      # if Loofah is using an HTML5 parser,
    +      #   then "style" should be removed by the parser as an invalid child of "select"
    +      assert_silent(&invocation)
    +    else
    +      # if Loofah is using an HTML4 parser,
    +      #   then SafeListSanitizer should remove "style" from the safelist
    +      assert_output(nil, warning, &invocation)
    +    end
    +    refute_includes(sanitized, "style")
    +  end
    +
     protected
     
       def xpath_sanitize(input, options = {})
    @@ -641,4 +660,8 @@ def convert_to_css_hex(string, escape_parens=false)
       def libxml_2_9_14_recovery?
         Nokogiri.method(:uses_libxml?).arity == -1 && Nokogiri.uses_libxml?(">= 2.9.14")
       end
    +
    +  def html5_mode?
    +    ::Loofah.respond_to?(:html5_mode?) && ::Loofah.html5_mode?
    +  end
     end
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

14

News mentions

0

No linked articles in our index yet.