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.
| Package | Affected versions | Patched versions |
|---|---|---|
rails-html-sanitizerRubyGems | < 1.4.3 | 1.4.3 |
Affected products
13- Rails/Html::Sanitizerdescription
- ghsa-coords12 versionspkg:gem/rails-html-sanitizerpkg:rpm/opensuse/ruby3.2-rubygem-rails-html-sanitizer&distro=openSUSE%20Tumbleweedpkg:rpm/opensuse/rubygem-rails-html-sanitizer&distro=openSUSE%20Leap%2015.3pkg:rpm/opensuse/rubygem-rails-html-sanitizer&distro=openSUSE%20Leap%2015.4pkg:rpm/opensuse/rubygem-rails-html-sanitizer&distro=openSUSE%20Tumbleweedpkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20Linux%20Enterprise%20High%20Availability%20Extension%2015pkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20Linux%20Enterprise%20High%20Availability%20Extension%2015%20SP1pkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20Linux%20Enterprise%20High%20Availability%20Extension%2015%20SP2pkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20Linux%20Enterprise%20High%20Availability%20Extension%2015%20SP3pkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20Linux%20Enterprise%20High%20Availability%20Extension%2015%20SP4pkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20OpenStack%20Cloud%20Crowbar%208pkg:rpm/suse/rubygem-rails-html-sanitizer&distro=SUSE%20OpenStack%20Cloud%20Crowbar%209
< 1.4.3+ 11 more
- (no CPE)range: < 1.4.3
- (no CPE)range: < 1.5.0-2.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.4.3-1.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.0.4-150000.4.3.1
- (no CPE)range: < 1.0.3-8.11.1
- (no CPE)range: < 1.0.3-8.11.1
Patches
145a5c10fed3dfix: modify safelist option if it contains both `select` and `style`
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- github.com/advisories/GHSA-pg8v-g4xq-hww9ghsaADVISORY
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AGRLWBEB3S5AU3D4TTROIS7O6QPHDTRH/mitrevendor-advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/NHDACMCLWE32BZZTSNWQPIFUAD5I6Q47/mitrevendor-advisory
- nvd.nist.gov/vuln/detail/CVE-2022-32209ghsaADVISORY
- github.com/rails/rails-html-sanitizer/commit/45a5c10fed3d9aa141594c80afa06d748fa0967dghsaWEB
- github.com/rubysec/ruby-advisory-db/blob/master/gems/rails-html-sanitizer/CVE-2022-32209.ymlghsaWEB
- groups.google.com/g/rubyonrails-security/c/ce9PhUANQ6sghsaWEB
- hackerone.com/reports/1530898ghsaWEB
- lists.debian.org/debian-lts-announce/2022/12/msg00012.htmlghsamailing-listWEB
- lists.debian.org/debian-lts-announce/2024/09/msg00045.htmlghsaWEB
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AGRLWBEB3S5AU3D4TTROIS7O6QPHDTRHghsaWEB
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/NHDACMCLWE32BZZTSNWQPIFUAD5I6Q47ghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/AGRLWBEB3S5AU3D4TTROIS7O6QPHDTRHghsaWEB
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NHDACMCLWE32BZZTSNWQPIFUAD5I6Q47ghsaWEB
News mentions
0No linked articles in our index yet.