CVE-2022-32209: Rails Cross-Site Scripting Vulnerability
MODERATECVE-2022-32209 is a MODERATE (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Rails libraries in the RubyGems ecosystem. The issue involves :html::sanitizer vulnerable to cross-site scripting. Remediation is available by upgrading affected packages to version 1.4.3.
CVE-2022-32209 at a Glance
Security Impact
CVSS: 6.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2022-32209
To remediate this vulnerability, upgrade all affected Rails dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade rails-html-sanitizer to 1.4.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for rails-html-sanitizer
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-32209, inspect your project dependencies for Rails:
inspect dependencies for rails-html-sanitizer
Analyze the terminal output to locate any version of Rails in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.3), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Rails, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-32209 Affected Rails Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
rails-html-sanitizer
|
RubyGems |
< 1.4.3
|
1.4.3
|
References
Frequently Asked Questions
What is CVE-2022-32209?
Which Rails versions are affected?
What version fixes CVE-2022-32209?
Is rails-html-sanitizer affected?
What is the CVSS score of CVE-2022-32209?
What CWE is associated with CVE-2022-32209?
How can I check RubyGems dependencies for CVE-2022-32209?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-pg8v-g4xq-hww9",
"modified" : "2025-11-04T16:39:03Z",
"published" : "2022-06-25T00:00:54Z",
"aliases" : [ "CVE-2022-32209" ],
"summary" : "Rails::Html::Sanitizer vulnerable to Cross-site Scripting",
"details" : "Versions of Rails::Html::Sanitizer prior to version 1.4.3 are vulnerable to XSS with certain configurations of Rails::Html::Sanitizer which allows an attacker to inject content when 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. \n\nThis may be done via application configuration: ```ruby# In config/application.rbconfig.action_view.sanitized_allowed_tags = [\"select\", \"style\"]```\n\nsee https://guides.rubyonrails.org/configuring.html#configuring-action-view\n\nOr it may be done with a `:tags` option to the Action View helper `sanitize`: ```<%= sanitize @comment.body, tags: [\"select\", \"style\"] %>``` \n\nsee https://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize \n\nIt may also be done with Rails::Html::SafeListSanitizer directly: \n```ruby# class-level optionRails::Html::SafeListSanitizer.allowed_tags = [\"select\", \"style\"]``` or with\n```ruby# instance-level optionRails::Html::SafeListSanitizer.new.sanitize(@article.body, tags: [\"select\", \"style\"])```\n\nAll users overriding the allowed tags by any of the above mechanisms to include both \"select\" and \"style\" are recommended to upgrade immediately. A workaround for this issue can be applied by removing either `select` or `style` from the overridden allowed tags.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "rails-html-sanitizer"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.4.3"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-32209"
}, {
"type" : "WEB",
"url" : "https://github.com/rails/rails-html-sanitizer/commit/45a5c10fed3d9aa141594c80afa06d748fa0967d"
}, {
"type" : "WEB",
"url" : "https://hackerone.com/reports/1530898"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/rails/rails-html-sanitizer"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rails-html-sanitizer/CVE-2022-32209.yml"
}, {
"type" : "WEB",
"url" : "https://groups.google.com/g/rubyonrails-security/c/ce9PhUANQ6s"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2022/12/msg00012.html"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2024/09/msg00045.html"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AGRLWBEB3S5AU3D4TTROIS7O6QPHDTRH"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/NHDACMCLWE32BZZTSNWQPIFUAD5I6Q47"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/AGRLWBEB3S5AU3D4TTROIS7O6QPHDTRH"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NHDACMCLWE32BZZTSNWQPIFUAD5I6Q47"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-07-05T18:10:35Z",
"nvd_published_at" : "2022-06-24T15:15:00Z"
}
}